-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
Difference between running mypy directly vs with pre-commit run -a #1580
Comments
~generally there'll be two differences -- the first is outlined in the last bit of this (mypy in pre-commit is run in isolation so it will not have access to your dependencies unless you add them to the second is that mypy from pre-commit is run with files as positional arguments -- there's some known bugs in mypy where it will hide / break in different ways depending on how arguments are passed to it (unfortunately) -- most of these are due to import cycles and some of the mypy plugins (namedtuples for example are particularly problematic) so to get exactly what pre-commit runs you could do something like: # make an isolated environment
virtualenv mypyenv
# mypyenv/bin/pip install ... (whatever is in additional dependencies)
mypyenv/bin/pip install mypy==0.782
mypyenv/bin/mypy $(git ls-files -- Edgar | grep '\.py$') |
Nailed it! 👍 In my case all the errors were related to |
Just for reference, mirrors-mypy's default arguments can also make the output different. :) https://github.com/pre-commit/mirrors-mypy/issues/48 |
This comment has been minimized.
This comment has been minimized.
Oops, I wanted to remove my previous comment few minutes after writing but github outage prevented me from doing so. Meanwhile I was able to narrow down the issue with pip-tools and it appears to be caused by pip 21.0 which changed lots of typing used by pip-tools. Ceiling pip to <21.0 does avoid errors with mypy, at least until someone can upgrade the code. As pip was never pinned when running mypy under pre-commit, we now know why it failed only on some environments on not on others. |
Another difference is that pre-commit only runs on staged/committed files. Took me a while to realize I simply had to |
Hi,
I'm seeing different output when I execute
mypy
directly vs runningpre-commit run mypy -a
. I've tried a few things, including looking at the docs and tweaking the options, but still can't really understand what's happening.At the root of the repository all code is in
Edgar/
.Running
mypy
:Running
pre-commit run -a mypy
:Both commands above were executed from a clean checkout (no modified files).
The docs say
-a/--all-files
should run the hook against all files in the repository, for that reason I was expecting the same output from both commands.Here's the mypy configuration in
.pre-commit-config.yaml
:I'm using pre-commit 2.7.1.
Any idea of what the problem might be @asottile?
Cheers!
The text was updated successfully, but these errors were encountered: