proselint
proselint copied to clipboard
RFC: Type checking in CI and development
Rationale
Type checking in CI and development would ensure that our code runs with minimal runtime errors related to dynamic typing. It would also make it easier to do things like creating configuration structures that are statically typed.
Drawbacks
- ~~Many Python developers are not used to type hinting and may be confused by it~~ | Resolved by @carlsmedstad's comment
- It will add time to CI
- Imports get messy and add runtime weight - any amount of generics, unions, etc, must be imported
The comment that lead to this issue.
This coupled with using
mypy
I use pyright
locally as it is much more complete and flexible than mypy
- I hadn't thought much about including it in CI, as Python tends to not be type-checked much if at all (given its nature as a dynamically typed language) and many people are not used to it, but I can open an RFC issue for that.
Originally posted by @Nytelife26 in this comment on #1200
My input on this:
Many Python developers are not used to type hinting and may be confused by it
My feeling is that a lot of Python projects are moving to partly or fully typed code-bases and that this is the future of Python. While it might be new to some developers, it makes the code so much more self-documenting that I think it is a net-positive in terms of how approachable the project is.
Where I work we use exclusively fully-typed Python, which is achieved by running mypy
in the CI with the following config:
[mypy]
ignore_missing_imports = True
warn_redundant_casts = True
warn_unused_ignores = True
disallow_incomplete_defs = True
disallow_untyped_defs = True
disallow_untyped_calls = True
You have a good point. In addition, doing this will let more people learn about type hinting. Even TypeScript as the evolutionary stage of JavaScript is showing a move from dynamically typed languages in favour of ones that allow strong typing.
I believe pyright
would be the better tool to use, as it is significantly faster than mypy
and more featured. That leads me to another drawback of typing in Python at its current state, though, which I will mention in the issue.
@suchow Thoughts on this?