Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
vnmabus wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromvnmabus:patch-1
Open

Conversation

vnmabus
Copy link

After#14063, calls topsutil.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 asobject is appropriate.

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.
@github-actionsGitHub Actions
Copy link
Contributor

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

Copy link
Collaborator

@srittausrittau left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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

@vnmabus
Copy link
Author

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 theinfo field as a genericTypedDict and useoverload to see if we have to return that subclass or the normal class?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@srittausrittausrittau requested changes

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@vnmabus@srittau

[8]ページ先頭

©2009-2025 Movatter.jp