Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.9k
psutil: Typead_value
asobject
#14106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Afterpython#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.
According tomypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Considering that the supplied type influenced the result type (but we can't express that relation properly),Any
is a bit more appropriate. Also, we need to document uses ofAny
, see suggestions below.
@@ -175,7 +175,7 @@ class Process: | |||
info: dict[str, Any] | |||
def oneshot(self) -> AbstractContextManager[None]: ... | |||
def as_dict( | |||
self, attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = None, ad_value=None | |||
self, attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = None, ad_value: object =None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
self,attrs:list[str]|tuple[str, ...]|set[str]|frozenset[str]|None=None,ad_value:object=None | |
self, | |
attrs:list[str]|tuple[str, ...]|set[str]|frozenset[str]|None=None, | |
ad_value:Any=None,# arbitrary value used as result in case of error |
@@ -236,7 +236,7 @@ class Popen(Process): | |||
def pids() -> list[int]: ... | |||
def pid_exists(pid: int) -> bool: ... | |||
def process_iter( | |||
attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = None, ad_value=None | |||
attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = None, ad_value: object =None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
attrs:list[str]|tuple[str, ...]|set[str]|frozenset[str]|None=None,ad_value:object=None | |
attrs:list[str]|tuple[str, ...]|set[str]|frozenset[str]|None=None, | |
ad_value:Any=None,# arbitrary value used as result in case of error |
Can't we? Wouldn't be possible to create a (fake) |
After#14063, calls to
psutil.process_iter
andpsutil.Process.as_dict
are being reported by Pyright, as thead_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.