Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add settable info property on psutil.Process, default to empty dict #2267

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ringohoffman
Copy link

@ringohoffman ringohoffman commented Jun 7, 2023

Summary

Motivation

This example from the docs raises type errors since info is not defined in the __init__:

https://psutil.readthedocs.io/en/latest/#psutil.process_iter:

import psutil
for proc in psutil.process_iter(['pid', 'name', 'username']):
    print(proc.info)  # Cannot access member "info" for type "Process"; Member "info" is unknown

Description

This PR is an alternate implementation of #10195, addressing @giampaolo's comment: #2260 (comment)

I suppose it's less surprising for the user if info attribute is always set. I wonder if it's more correct for it to be an empty dict {} rather than None though.

Which I agree with.

Here is the typeshed update corresponding to this PR: python/typeshed#10275

@ringohoffman ringohoffman force-pushed the add-settable-info-property branch 3 times, most recently from 4198714 to 83b0965 Compare June 7, 2023 00:42
ringohoffman added a commit to ringohoffman/typeshed that referenced this pull request Jun 7, 2023
@ringohoffman
Copy link
Author

@giampaolo how’s this looking?

@ringohoffman
Copy link
Author

@giampaolo have you had a chance to check this out?

@qthequartermasterman
Copy link

@giampaolo Is there any plan to look at this? I would like to use it in a project of mine.

@ringohoffman
Copy link
Author

@giampaolo any chance you can look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants