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 typing-extensions as dependency and pin mypy version #1557

Merged
merged 3 commits into from Oct 20, 2021

Conversation

nicarl
Copy link
Contributor

@nicarl nicarl commented Oct 20, 2021

What does this changes

The PR adds typing-exntesions as a dependency in setup.py and pins the version of mypy to 0.910.

What was wrong

@obieler raised the issue that from typing_extensions import Literal does not work on python 3.6 and 3.7 without installing typing-extensions (#1536).
Furthermore the mypy version was not pinned. It is advised to pin the mypy version to avoid that new typing errors appear due to changes in mypy, which would make the CI and errors harder to reproduce (https://sethmlarson.dev/blog/2021-10-18/tests-arent-enough-case-study-after-adding-types-to-urllib3).

How this fixes it

typing-extensions is added as a dependency and solves this issue.

typing-extensions, which contains the `Literal` type for python 3.6 and 3.7 is not included by default. Adding mypy as dependency solves this issue as it has typing-extensions as a dependency (depending on the python version).
It is recommended to pin the mypy version to avoid errors popping up when mypy gets updated. This would break the CI and make mypy type checking not deterministic.
@fcurella
Copy link
Collaborator

Fixes #1556

@fcurella
Copy link
Collaborator

In install_requires, I'd rather require just typing-extensions than the whole mypy.

Q: if we do that, does it make the --install-types option in mypy --install-types redundant?

@nicarl
Copy link
Contributor Author

nicarl commented Oct 20, 2021

In install_requires, I'd rather require just typing-extensions than the whole mypy.

Q: if we do that, does it make the --install-types option in mypy --install-types redundant?

Valid point concerning the dependency, better to add just typing-extensions.
We still require the --install-types flag, as some libraries do not contain types themselves but stubs exists. They need to be installed from https://github.com/python/typeshed. For our case python-dateutil has only stubs which need to be installed.

(details can be found here: https://mypy.readthedocs.io/en/stable/installed_packages.html#using-installed-packages)

@nicarl nicarl changed the title Add mypy as dependency and pin version Add typing-extensions as dependency and pin mypy version Oct 20, 2021
@fcurella
Copy link
Collaborator

Thank you!

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

Successfully merging this pull request may close these issues.

None yet

2 participants