Wrong verbosity level when specified in both config file and command line.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in main.py, in process_options() around the config-file parsing and second command-line parse described in the issue. Reproduce the combination of verbosity = 1 and -v, then inspect how options.verbosity is preserved and overridden. Done means command-line verbosity takes precedence rather than being added to the configured value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100