Skip to content

Commit c95d8b4

Browse files
authored
Make strict in config a boolean (#8636)
Note that setting strict = False does not invert any of the options touched by strict; instead it is the same as if strict was not set at all. Closes #8633.
1 parent ec15ae8 commit c95d8b4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

mypy/config_parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def split_and_match_files(paths: str) -> List[str]:
8686
'package_root': lambda s: [p.strip() for p in s.split(',')],
8787
'cache_dir': expand_path,
8888
'python_executable': expand_path,
89+
'strict': bool,
8990
} # type: Final
9091

9192

@@ -209,7 +210,7 @@ def parse_section(prefix: str, template: Options,
209210
options_key = key[3:]
210211
invert = True
211212
elif key == 'strict':
212-
set_strict_flags()
213+
pass # Special handling below
213214
else:
214215
print("%sUnrecognized option: %s = %s" % (prefix, key, section[key]),
215216
file=stderr)
@@ -240,6 +241,10 @@ def parse_section(prefix: str, template: Options,
240241
except ValueError as err:
241242
print("%s%s: %s" % (prefix, key, err), file=stderr)
242243
continue
244+
if key == 'strict':
245+
if v:
246+
set_strict_flags()
247+
continue
243248
if key == 'silent_imports':
244249
print("%ssilent_imports has been replaced by "
245250
"ignore_missing_imports=True; follow_imports=skip" % prefix, file=stderr)

test-data/unit/check-flags.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,22 @@ def f(c: A) -> None: # E: Missing type parameters for generic type "A"
11651165
strict = True
11661166
[out]
11671167

1168+
[case testStrictFalseInConfigAnyGeneric]
1169+
# flags: --config-file tmp/mypy.ini
1170+
from typing import TypeVar, Generic
1171+
1172+
T = TypeVar('T')
1173+
1174+
class A(Generic[T]):
1175+
pass
1176+
1177+
def f(c: A) -> None:
1178+
pass
1179+
[file mypy.ini]
1180+
\[mypy]
1181+
strict = False
1182+
[out]
1183+
11681184
[case testStrictAndStrictEquality]
11691185
# flags: --strict
11701186
x = 0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy