Mypy improvement#677
Conversation
14406ac to
55bbc0e
Compare
|
|
||
|
|
||
| if sys.version_info < (3, 8): | ||
| from typing_extensions import Literal |
There was a problem hiding this comment.
Aliasing things like Literal is not supported in pyright. I'll add a comment where Literal is being used to show how it should be imported to prevent typing_extensions from becoming a runtime dependency.
There was a problem hiding this comment.
We are only supporting mypy check in our pipelines right now and I stick to how mypy works (never worked with pyright, but it sounds like it's not compatible with mypy).
There was a problem hiding this comment.
pyright and mypy work pretty hard to be compatible with one another. pyright does an early scan for some special forms to speed things up, and the Literal import is one of those. This is one of the few differences (aside from pyright supporting more PEPs) between pyright and mypy. The other thing to take into account is that pyright is the type checker that is included by default with Visual Studio Code's Python extension.
|
|
||
| if sys.version_info < (3, 8): | ||
| from typing_extensions import Literal | ||
| from typing_extensions import SupportsIndex |
There was a problem hiding this comment.
This makes typing_extensions a runtime dependency. Is that desired?
There was a problem hiding this comment.
Probably not 😆. I will need to rework this PR anyway since typing fails depending on the version of Python it's run on.
|
|
||
| if TYPE_CHECKING: | ||
| from typing import Literal | ||
| from pendulum.utils._compat import Literal |
There was a problem hiding this comment.
This should be changed to from typing_extensions import Literal so that pyright is supported
|
|
||
| if TYPE_CHECKING: | ||
| from typing import Literal | ||
| from pendulum.utils._compat import Literal |
There was a problem hiding this comment.
This should be changed to from typing_extensions import Literal so that pyright is supported
|
Closing in favor of #680 |
Pull Request Check List
Mypy 0.990 added
show_error_codesas enabled by default and our# type: ignorecomments had wrong codes which caused a failure in #674.Second commit moves
mypyusage away frompre-commit, since when it's being run frompre-commit, it might miss some typing issues coming from dependencies. See python-poetry/cleo#254 (comment)