-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Please revert new source finding behaviour or add some way to exclude paths #9981
Comments
@intgr Thanks for reporting the issue! These all seem real regressions. It may be worth disabling the new functionality until there are ways to work around them. Brainstorming:
@hauntsaninja What do you think? |
I was about to open a similar task and found this one. In my case a fixture file that is in the test tree and was not caught with 0.790 (because one of the intermediate directories doesn't have the In my case the structure that works on 0.790 and fails on 0.800 is:
With:
With 0.800 gives:
While with 0.790:
|
@JukkaL Yeah, we should add an ignore option (#4675 (comment)). So concretely:
Finally, note 1 isn't a new issue (you can repro with mypy 0.790). |
* The mypy package has a regression that makes the test fail. Forcing for now the maximum version for it until it's fixed upstream. * See also: python/mypy#9981 Change-Id: If3557afab24c4c2819ab2b95538236446e6012dd
@hauntsaninja Sounds good! There is still the question of whether we should release a new version with this new option, or should we first revert the change in a bugfix release. Even if we decide to add the option, we can just cherry-pick the new feature on top the the 0.800 release branch to speed up the release process (it would still be 0.810 instead of 0.801 because there's a new feature). I'm fine with both options, but we should do something pretty soon (maybe by early next week). |
Also, maybe we should ignore all directories starting with a dot, such as |
I'll try and get a PR in sometime before Saturday evening. Yup, we already do that (not new to v0.800): Line 106 in 4d5a1bc
|
Resolves python#4675, resolves python#9981 Additionally, we always ignore site-packages and node_modules. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note.
Resolves python#4675, resolves python#9981 Additionally, we always ignore site-packages and node_modules. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note.
I ran into an issue which seems related to item 2 in the post starting this thread, that "Having init.py files under any directory that's not a valid Python module name.". In 0.790, a directory name |
mypy v0.800 didn't really change the "invalid module name" logic. If you're getting an error now, but weren't getting one with mypy v0.790, it's probably because mypy was not checking your code at all. It's not clear to me from your message what your directory structure is. It sounds like:
In which case, rename |
Yeah, I had simplified the test case too much, fixed it now. The real example I saw was like you mention in your last comment; the code was entirely ignored by the previous mypy version. |
See comment for details.
See comment for details.
Thanks @hauntsaninja for looking at this. Here is my structure:
|
Yeah, you need to remove that stray That is, with mypy 0.790 on your tree, |
Thank you, that resolved! |
Resolves #4675, resolves #9981. Additionally, we always ignore site-packages and node_modules, and directories starting with a dot. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note. Co-authored-by: hauntsaninja <>
Resolves #4675, resolves #9981. Additionally, we always ignore site-packages and node_modules, and directories starting with a dot. Also note that this doesn't really affect import discovery; it only directly affects passing files or packages to mypy. The additional check before suggesting "are you missing an __init__.py" didn't make any sense to me, so I removed it, appended to the message and downgraded the severity to note. Co-authored-by: hauntsaninja <>
I hate to be that guy again :) but I would be very pleased to see this release. |
#10062 is the issue to follow for the release with this change. Jukka should be releasing soon :) |
Bug Report
I think the PR "find_sources: find build sources recursively" #9614 is a good and worthwhile change. But in practice it causes surprising regressions for many users. It's not just spurious warnings, mypy often refuses to run entirely ("Found 1 error in 1 file (errors prevented further checking)").
In many cases, there aren't good work-arounds, short of restructuring one's project directory tree.
I think the magnitude of this issue is large enough that the best course of action is to revert the change and issue a hotfix release, until some work-around for those cases is created.
There are many examples of common things that throw off mypy:
__init__.py
files under any directory that's not a valid Python module name.node_modules
directory, some of which may have Python 2.7 code that causes syntax errors..py
file names.Some more examples in comments here: #4675 (comment)
To Reproduce
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: