Skip to content

Commit 15f2f59

Browse files
committed
Support reading config from pyproject.toml
1 parent 26b5754 commit 15f2f59

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

mypy/config_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ def parse_toml_config_file(options: Options, set_strict_flags: Callable[[], None
156156
else:
157157
options.config_file = filename
158158

159-
if 'mypy' not in table:
160-
print("%s: No [mypy] table in config file" % filename, file=stderr)
159+
if 'tool' not in table or 'mypy' not in table['tool']:
160+
print("%s: No 'tool.mypy' table in config file" % filename, file=stderr)
161161
return False
162162

163163
# Handle the mypy table.
164-
for key, value in table['mypy'].items():
164+
for key, value in table['tool']['mypy'].items():
165165

166166
# Is an option.
167167
if key != 'overrides':

test-data/unit/cmdline.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def f():
173173
[case testWarnUnusedIgnores]
174174
# cmd: mypy main.py --config-file=pyproject.toml
175175
[file pyproject.toml]
176-
\[mypy]
176+
\[tool.mypy]
177177
warn_unused_ignores = true
178178
[file main.py]
179179
# type: ignore
@@ -186,17 +186,17 @@ main.py:1: error: unused 'type: ignore' comment
186186
[file main.py]
187187
# type: ignore
188188
[out]
189-
pyproject.toml: No [mypy] table in config file
189+
pyproject.toml: No 'tool.mypy' table in config file
190190
== Return code: 0
191191

192192
[case testPerFileConfigSection]
193193
# cmd: mypy x.py y.py z.py
194194
[file pyproject.toml]
195-
\[mypy]
195+
\[tool.mypy]
196196
disallow_untyped_defs = true
197-
\[mypy.overrides.y]
197+
\[tool.mypy.overrides.y]
198198
disallow_untyped_defs = false
199-
\[mypy.overrides.z]
199+
\[tool.mypy.overrides.z]
200200
disallow_untyped_calls = true
201201
[file x.py]
202202
def f(a):

0 commit comments

Comments
 (0)