Support module-level `strict` config flag
Description
The current behavior of strict = True in a module-level config section actually enables all strictness flags globally, which seems like a bug. This change changes a module-level strict = True option to act as though all of the per-module strictness flags were enabled.
Test Plan
In addition to adding a basic unit test (the strict flag is hard to test since it is essentially a macro flag) I tested manually using a config file like this:
[mypy]
strict = True
[mypy-foo.*]
strict = False
I then confirmed that strictness flags were applied to non-foo packages (I removed some type hints and saw an error) and that strictness was not applied to the foo package (removed some type hints and saw no errors).
Personally I expected the strict config flag to behave this way already, so I don't think a change to the docs is needed.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
FYI the CI pipelines seem to be failing due to: https://github.com/pypa/setuptools/issues/3102
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
I pushed a fix for CI in https://github.com/python/mypy/pull/12181
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
Any update on this? The current behavior feels like a bug to me too, I'd love to see this fixed :)
Diff from mypy_primer, showing the effect of this PR on open source code:
CPython (Argument Clinic) (https://github.com/python/cpython)
+ Warning: --strict-concatenate is deprecated; use --extra-checks instead
CPython (cases_generator) (https://github.com/python/cpython)
+ Warning: --strict-concatenate is deprecated; use --extra-checks instead
AutoSplit (https://github.com/Toufool/AutoSplit)
+ src/AutoSplit.py:25:1: error: Module "capture_method" does not explicitly export attribute "CaptureMethodBase" [attr-defined]
pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/algorithms.py:190: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/algorithms.py:195: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/algorithms.py:199: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jws.py:182: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jws.py:228: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jwt.py:236: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jwt.py:287: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
Diff from mypy_primer, showing the effect of this PR on open source code:
CPython (Argument Clinic) (https://github.com/python/cpython)
+ Warning: --strict-concatenate is deprecated; use --extra-checks instead
CPython (cases_generator) (https://github.com/python/cpython)
+ Warning: --strict-concatenate is deprecated; use --extra-checks instead
AutoSplit (https://github.com/Toufool/AutoSplit)
+ src/AutoSplit.py:25:1: error: Module "capture_method" does not explicitly export attribute "CaptureMethodBase" [attr-defined]
pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/algorithms.py:190: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/algorithms.py:195: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/algorithms.py:199: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jws.py:182: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jws.py:228: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jwt.py:236: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jwt.py:287: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
Diff from mypy_primer, showing the effect of this PR on open source code:
AutoSplit (https://github.com/Toufool/AutoSplit)
+ src/AutoSplit.py:25:1: error: Module "capture_method" does not explicitly export attribute "CaptureMethodBase" [attr-defined]
pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/algorithms.py:190: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/algorithms.py:195: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/algorithms.py:199: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jws.py:182: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jws.py:228: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jwt.py:236: error: Function is missing a type annotation for one or more arguments [no-untyped-def]
+ jwt/api_jwt.py:287: error: Function is missing a type annotation for one or more arguments [no-untyped-def]