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

__all__ in a stub will easily go out of date #7284

Closed
AlexWaygood opened this issue Feb 19, 2022 · 1 comment · Fixed by python/mypy#12214
Closed

__all__ in a stub will easily go out of date #7284

AlexWaygood opened this issue Feb 19, 2022 · 1 comment · Fixed by python/mypy#12214
Labels
project: policy Organization of the typeshed project

Comments

@AlexWaygood
Copy link
Member

Stubtest does not check that the elements in a stub file's __all__ match the elements in the runtime's __all__. It's also not obvious (to me, at least) how stubtest could be patched so that it would check that the elements match.

If __all__ is a tuple, stubtest will raise an error if the stub's __all__ is a different length to the runtime's __all__, but it will not raise an equivalent error if __all__ is a list.

flake8 will raise an error if a name in __all__ is not defined in the file. flake8-pyi on master (not yet released) will also raise an error if __all__ is merely annotated as list[str] without being defined. But flake8 will not raise an error if a name is missing from __all__.

All this means that the __all__ definitions in typeshed are liable to become outdated very easily if new elements are added to __all__ in future Python versions. I'm not sure exactly what the solution is.

@AlexWaygood
Copy link
Member Author

Suggested solution here: python/mypy#12214

But it's too noisy at the moment, due to the number of modules that have __all__ at runtime, but not in the stub. So, it might have to wait a while.

@srittau srittau added the project: policy Organization of the typeshed project label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: policy Organization of the typeshed project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants