typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

psutil: Type `ad_value` as `object`

Open vnmabus opened this issue 6 months ago • 2 comments

After #14063, calls to psutil.process_iter and psutil.Process.as_dict are being reported by Pyright, as the ad_value parameter is untyped.

However, given that (from the documentation) this is just a placeholder value to use when an error is raised while fetching some attribute, I think that typing it as object is appropriate.

vnmabus avatar May 20 '25 10:05 vnmabus

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar May 20 '25 10:05 github-actions[bot]

Considering that the supplied type influenced the result type (but we can't express that relation properly)

Can't we? Wouldn't be possible to create a (fake) Process subclass that include the info field as a generic TypedDict and use overload to see if we have to return that subclass or the normal class?

vnmabus avatar May 20 '25 11:05 vnmabus