Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,11 @@ 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, modules or packages
# are passed on the command line.
if not (special_opts.files or special_opts.packages or special_opts.modules):
# File, package, and module targets from the config file are used only if no target
# is specified on the command line.
if not (
special_opts.files or special_opts.packages or special_opts.modules or special_opts.command
):
if options.files:
special_opts.files = options.files
if options.packages:
Expand Down
8 changes: 8 additions & 0 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,14 @@ files = config.py
mypy: error: Cannot read file 'override.py': No such file or directory
== Return code: 2

[case testCommandOverridesTargetsFromConfig]
# cmd: mypy -c pass
[file mypy.ini]
\[mypy]
files = should_be_ignored.py
packages = should_be_ignored_package
modules = should_be_ignored_module

[case testErrorSummaryOnSuccess]
# cmd: mypy --error-summary good.py
[file good.py]
Expand Down
Loading