Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow packages/modules as args with files in cfg #9834

Merged
merged 2 commits into from Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions mypy/main.py
Expand Up @@ -851,9 +851,9 @@ def set_strict_flags() -> None:
if special_opts.no_executable or options.no_site_packages:
options.python_executable = None

# Paths listed in the config file will be ignored if any paths are passed on
# the command line.
if options.files and not special_opts.files:
# Paths listed in the config file will be ignored if any paths, modules or packages
# are passed on the command line.
if options.files and not (special_opts.files or special_opts.packages or special_opts.modules):
special_opts.files = options.files

# Check for invalid argument combinations.
Expand Down
34 changes: 34 additions & 0 deletions test-data/unit/cmdline.test
Expand Up @@ -1248,3 +1248,37 @@ x: str = 0
pkg/x.py:1: error: invalid syntax
Found 1 error in 1 file (errors prevented further checking)
== Return code: 2

[case testCmdlinePackageAndFile]
# cmd: mypy -p pkg file
[out]
usage: mypy [-h] [-v] [-V] [more options; see below]
[-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
mypy: error: May only specify one of: module/package, files, or command.
== Return code: 2

[case testCmdlinePackageAndIniFiles]
# cmd: mypy -p pkg
[file mypy.ini]
\[mypy]
files=file
[file pkg.py]
x = 0 # type: str
[file file.py]
y = 0 # type: str
[out]
pkg.py:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")


[case testCmdlineModuleAndIniFiles]
# cmd: mypy -m pkg
[file mypy.ini]
\[mypy]
files=file
[file pkg.py]
x = 0 # type: str
[file file.py]
y = 0 # type: str
[out]
pkg.py:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")