Skip to content

Conversation

@guoci
Copy link
Contributor

@guoci guoci commented Oct 28, 2025

No description provided.

@github-actions
Copy link
Contributor

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

@AlexWaygood AlexWaygood changed the title add type stub for sys.reload_environ add type stub for os.reload_environ Oct 29, 2025
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you. It looks like the reason why we forgot to add this is that the CPython team forgot to add this function to __all__ when they added it. This then meant that our tests didn't flag it as missing from the module. (In general, if __all__ is defined in a module, our tests only complain if something is missing from the stub if that thing is included in __all__.)

Would you be interested in also making a PR to CPython to add "reload_environ" to os.__all__? Feel free to tag me on the PR and I can help get it merged

@AlexWaygood AlexWaygood merged commit 1bfd069 into python:main Oct 29, 2025
63 checks passed
@guoci
Copy link
Contributor Author

guoci commented Oct 29, 2025

@AlexWaygood Should I do this to the other recent typeshed missing stubs as well?

@AlexWaygood
Copy link
Member

@AlexWaygood Should I do this to the other recent typeshed missing stubs as well?

I think this is the only one where the reason why it wasn't picked up by our tests was that it wasn't included in __all__.

  • sys.__all__ does not exist:
    • the reason why sys.androidapilevel wasn't picked up by our tests despite it being missing is that it only exists on Android, and we don't have any CI jobs in typeshed that run on Android.
    • sys._current_exceptions wasn't flagged as being missing because it starts with a leading underscore, and if a module doesn't have __all__ defined then all symbols that start with leading underscores are assumed to be private by our tests (this one was an exception, since it is documented)
  • sysconfig.__all__ does exist, but I think it's probably intentional that _get_preferred_schemes doesn't exist in __all__ -- the docs for that method say "End users should not use this function". I think since it is documented, probably the best thing is to add it to the stubs... but given that "end users should not use this function", I'm not really sure why it's documented 😆

@guoci
Copy link
Contributor Author

guoci commented Oct 29, 2025

What about enum.show_flag_values (#14928)?

@AlexWaygood
Copy link
Member

Good point! Yep, that one should also probably be added to __all__ at runtime!

@AlexWaygood
Copy link
Member

@guoci how did you find these, out of interest?

@guoci
Copy link
Contributor Author

guoci commented Oct 30, 2025

@AlexWaygood I wrote a script that matches the CPython reStructuredText documentation against the typeshed type stubs. My goal is to automate the process of integrating typeshed’s type information into the CPython docs.

@AlexWaygood
Copy link
Member

Very cool -- you could consider contributing something like that script to stubtest, which is the tool we use in our CI to detect when something is present at runtime but not present in the stub. If something appears in CPython's documentation, that's a pretty good reason to make sure we include it in the stubs. We could probably make sure all objects that are explicitly documented are included in this set here as things that should always be included in the stubs.

@guoci
Copy link
Contributor Author

guoci commented Oct 30, 2025

Sure!

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.

2 participants