Set up mypy pre-commit hook for incremental adoption#4510
Conversation
5c3e69c to
ee6a18b
Compare
neersighted
left a comment
There was a problem hiding this comment.
LGTM, with the addition of some explanatory comments and a rebase onto current master.
ee6a18b to
3b65c91
Compare
Not sure why That this was committed without some hook noticing and complaining suggests that what you are trying to do - which I am all in favour of! - is not working. Suggestions:
|
|
Hi @dimbleby, mypy is being run by a GitHub workflow, it's a pre-conmit hook. The pre-commit hook passes some additional command line arguments too, so the command won't be quite equivalent to what you're running manually. For local development you probably want
|
|
Thanks, I dug in a bit further. The difference is that the virtual environment in which precommit runs mypy does not include tomlkit - so it simply sees a missing import, and is configured to ignore that. Whereas running mypy in the proper environment, it does know about tomlkit and does recognise all those type errors. Perhaps I am still misunderstanding precommit, but if it is really running mypy in an environment that does not include project dependencies, that seems as though it will hurt mypy's ability to spot problems? |
|
Here is a blog post that seems to confirm that this time I am onto something, and proposing some workarounds / solutions. |
|
Thanks @dimbleby, I'll have a dig. There's no question the current configuration is missing a lot of errors- that's not entirely an accident. The plan is to tighten up the configuration incrementally over time. Would be great to see a pull request from you plugging some of these gaps! |
|
Yeah, I'll pick off a couple of the trivial ones to show good faith...! I have mostly found contributing to poetry a somewhat disheartening experience, but perhaps better luck this time. |
See my "governence" issue... |
as per the comment here - python-poetry/poetry#4510
as per the comment here - python-poetry/poetry#4510
as per the comment here - python-poetry/poetry#4510
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
At first glance this pull request might seem a little daft, as i've added a mypy pre-commit hook, and then configured mypy to ignore errors in everything.
There's a method in my madness
this project has many hundreds of type errors and eliminating them would be a significant challenge. A more practical approach is to white-list the current set of files, and then incrementally reduce the scope of that whitelist over time. Or to put it another way, tackle the type errors in one file at a time, and in all new modules.
The plan would be