-
-
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
bug: strict = true is incompatible with per-module configuration #11401
Comments
I tried inserting all the flags that Possible solutions:
I have absolutely no idea how hard either of those last two options might be, so updating the docs seems like a good option. |
Same here. We tried to move slowly to |
Any update on this? Was also hoping to use this strategy to onboard a larger project with proper type hinting. |
This also presents an issue when type-checking tests where looser type checking might be desirable on account of dependencies lacking types... For example, those which make use of decorators (e.g.
[[tool.mypy.overrides]]
module = ["tests.*"]
strict = false Throwing this into consideration, although this isn't a blocking issue for me personally as I can just be (somewhat) more specific (e.g. |
That's what I ended up having to do for my main application packages I haven't gotten around to yet. The namespace package is configured to be |
The workaround for the "slowly migrating untyped code" use case is to expand the
This is strict in |
Hello guys, It has been 3 years ago since this issue was opened and for the maintainers who understand the code... is it really so difficult to fix this issue and not frustrate people? Because of this issue, the proper adoption and DRY solution for the code is impossible. Either you duplicate all strict parameters like @vbraun suggested (and fingers crossed that they will not be updated, though it is stated in the docs that it is mutable without any notification). How to handle this situation? Probably we will go with solution provided by @vbraun , but it is not DRY and error prone in case the set of strict parameters will be updated. Best regards, |
Is there a PR? If PRs are being ignored, then it's arguably worth pestering. But there's no duty for anyone to add the features you want — "you've had three years to do the work I asked for" is not helpful. |
…o override the strict option for some modules (python/mypy#11401).
To Reproduce
Create the following file structure:
Both
my_module/__init__.py
andtests/__init__.py
contain:Which should trigger an error when run with
strict
but otherwise pass.In
mypy.ini
:That is, I want strict mode in my source code but not my tests.
Then I run this using
mypy .
Expected Behavior
I expect to get an error for my source code but not my tests:
Actual Behavior
I get an error for both my source code and tests.
It seems like
strict = False
in the per module section is ignored.If I add an explicit
allow_untyped_defs = True
to themypy-tests.*
section:That seems to be processed fine (I now get no errors for my tests but still get errors for my source).
So I believe the config file is valid, mypy is picking up that the options only apply to
tests.*
.I also tried flipping the enable/disable:
But I get the same result.
This also seems to be the case with
pyproject.toml
configs.The text was updated successfully, but these errors were encountered: