Description
Bug Report
The verbosity level can be specified either on the command line (-v
or -vv
, etc.) or in the config file (verbosity = {number}
). However, if specified in both places, what you get is the sum of the two levels.
To Reproduce
Place verbosity = 1
in the config file.
Call mypy -v ...
Expected Behavior
Verbosity 1, stderr shows LOG messages only.
Actual Behavior
Verbosity 2, stderr shows LOG messages and TRACE messages.
Your Environment
- Mypy version used: 0.931
- Mypy command-line flags: -v
- Mypy configuration options from
mypy.ini
(and other config files): verbosity = 1
How to fix the bug
This is in main.py process_options()
.
497 general_group.add_argument(
498 '-v', '--verbose', action='count', dest='verbosity',
499 help="More verbose messages")
923 # Parse config file first, so command line can override.
924 parse_config_file(options, set_strict_flags, config_file, stdout, stderr)
937 # Parse command line for real, using a split namespace.
938 special_opts = argparse.Namespace()
939 parser.parse_args(args, SplitNamespace(options, special_opts, 'special-opts:'))
Before line 939, save options.verbosity
, then set it to 0.
After line 939, if options.verbosity
is 0 (meaning -v
was not present), then set it to the earlier saved value.
Note: if verbosity is specified nonzero in the config file, there is no way to override this with verbosity 0 on the command line. You could add a no-verbose
command line option to accomplish this.