blob: 83f4745d07867ed3b0b68c860be9d2cf0ab4f8c3 [file] [log] [blame] [edit]
-- Tests for command line parsing
-- ------------------------------
--
-- The initial line specifies the command line, in the format
--
-- # cmd: mypy <options>
--
-- Note that # flags: --some-flag IS NOT SUPPORTED.
-- Use # cmd: mypy --some-flag ...
--
-- '== Return code: <value>' is added to the output when the process return code
-- is "nonobvious" -- that is, when it is something other than 0 if there are no
-- messages and 1 if there are.
-- Directories/packages on the command line
-- ----------------------------------------
[case testNonArrayOverridesPyprojectTOML]
# cmd: mypy x.py
[file pyproject.toml]
\[tool.mypy]
\[tool.mypy.overrides]
module = "x"
disallow_untyped_defs = false
[file x.py]
def f(a):
pass
def g(a: int) -> int:
return f(a)
[out]
pyproject.toml: tool.mypy.overrides sections must be an array. Please make sure you are using double brackets like so: [[tool.mypy.overrides]]
== Return code: 0
[case testNoModuleInOverridePyprojectTOML]
# cmd: mypy x.py
[file pyproject.toml]
\[tool.mypy]
\[[tool.mypy.overrides]]
disallow_untyped_defs = false
[file x.py]
def f(a):
pass
def g(a: int) -> int:
return f(a)
[out]
pyproject.toml: toml config file contains a [[tool.mypy.overrides]] section, but no module to override was specified.
== Return code: 0
[case testInvalidModuleInOverridePyprojectTOML]
# cmd: mypy x.py
[file pyproject.toml]
\[tool.mypy]
\[[tool.mypy.overrides]]
module = 0
disallow_untyped_defs = false
[file x.py]
def f(a):
pass
def g(a: int) -> int:
return f(a)
[out]
pyproject.toml: toml config file contains a [[tool.mypy.overrides]] section with a module value that is not a string or a list of strings
== Return code: 0
[case testConflictingModuleInOverridesPyprojectTOML]
# cmd: mypy x.py
[file pyproject.toml]
\[tool.mypy]
\[[tool.mypy.overrides]]
module = 'x'
disallow_untyped_defs = false
\[[tool.mypy.overrides]]
module = ['x']
disallow_untyped_defs = true
[file x.py]
def f(a):
pass
def g(a: int) -> int:
return f(a)
[out]
pyproject.toml: toml config file contains [[tool.mypy.overrides]] sections with conflicting values. Module 'x' has two different values for 'disallow_untyped_defs'
== Return code: 0