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

docopt.pyi is missing all classes from docopt.py #9833

Closed
sodul opened this issue Mar 2, 2023 · 4 comments · Fixed by #9839
Closed

docopt.pyi is missing all classes from docopt.py #9833

sodul opened this issue Mar 2, 2023 · 4 comments · Fixed by #9839
Labels
stubs: incomplete Annotations or sub-modules missing from an existing package or module

Comments

@sodul
Copy link

sodul commented Mar 2, 2023

When installing types-docopt (any version but also up to the latest 0.6.11.2) we get mypy errors when we reference any of the classes in docopt.py such as:

[types-docopt==0.6.11.2](error: Module has no attribute "DocoptExit"  [attr-defined])

In that case we were referencing docopt.DocoptExit.

@sodul sodul changed the title docopt.py is missing all classes from docopt.py docopt.pyi is missing all classes from docopt.py Mar 2, 2023
@srittau srittau added the stubs: incomplete Annotations or sub-modules missing from an existing package or module label Mar 2, 2023
@srittau
Copy link
Collaborator

srittau commented Mar 2, 2023

The docopt module seems to be missing quite a few items. Any PRs to improve the situation are welcome!

@AlexWaygood
Copy link
Member

The reason why our tests haven't flagged these classes as being missing from the stub is that docopt has a very minimal __all__ at runtime, and we generally only provide stubs for the public interface of a runtime package unless somebody specifically asks for other things to be included. But, as @srittau says — if you need these things, feel free to make a PR!

@sodul
Copy link
Author

sodul commented Mar 4, 2023

@AlexWaygood thanks for the explanation. In our case mypy is complaining in a unittest which accesses the docopt.DocoptExit exception. We'll just add a # type: ignore comment.

@sodul
Copy link
Author

sodul commented Mar 6, 2023

Thanks @hauntsaninja. I followed up and filed a report with the docopt project. I personally believe that exceptions that are raised to the caller code should be made public so they can be captured and handled properly so as not to force others to catch Exception.

docopt/docopt#510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: incomplete Annotations or sub-modules missing from an existing package or module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants