mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Support module-level `strict` config flag

Open icgood opened this issue 3 years ago • 9 comments

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.

icgood avatar Feb 14 '22 00:02 icgood

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 14 '22 01:02 github-actions[bot]

FYI the CI pipelines seem to be failing due to: https://github.com/pypa/setuptools/issues/3102

icgood avatar Feb 14 '22 23:02 icgood

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 15 '22 06:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 15 '22 06:02 github-actions[bot]

I pushed a fix for CI in https://github.com/python/mypy/pull/12181

hauntsaninja avatar Feb 15 '22 10:02 hauntsaninja

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 15 '22 14:02 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Feb 17 '22 04:02 github-actions[bot]

Any update on this? The current behavior feels like a bug to me too, I'd love to see this fixed :)

vxgmichel avatar Oct 21 '22 20:10 vxgmichel

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]

github-actions[bot] avatar Oct 17 '24 07:10 github-actions[bot]

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]

github-actions[bot] avatar Oct 30 '24 05:10 github-actions[bot]

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]

github-actions[bot] avatar Oct 30 '24 06:10 github-actions[bot]