Add support for configuration files in pyupgrade using ConfigArgParse.
By default, we'll look for a tool.pyupgrade section in pyupgrade.toml or pyproject.toml (in that order), and read the configuration from there. Command line arguments will override configuration file settings, which will override command line argument defaults. We also add a --config-file option to override the config file path.
Fixes #511.
Example Output
% pyupgrade -h
usage: pyupgrade [-h] [--config-file CONFIG_FILE] [--exit-zero-even-if-changed] [--keep-percent-format] [--keep-mock] [--keep-runtime-typing] [--py3-plus]
[--py36-plus] [--py37-plus] [--py38-plus] [--py39-plus] [--py310-plus] [--py311-plus] [--py312-plus]
[filenames ...]
positional arguments:
filenames
options:
-h, --help show this help message and exit
--config-file CONFIG_FILE
config file path
--exit-zero-even-if-changed
--keep-percent-format
--keep-mock
--keep-runtime-typing
--py3-plus, --py3-only
--py36-plus
--py37-plus
--py38-plus
--py39-plus
--py310-plus
--py311-plus
--py312-plus
Args that start with '--' can also be set in a config file (pyupgrade.toml or pyproject.toml or specified via --config-file). Config file syntax is Tom's
Obvious, Minimal Language. See https://github.com/toml-lang/toml/blob/v0.5.0/README.md for details. In general, command-line values override config file
values which override defaults.
Add support for configuration files in pyupgrade using
ConfigArgParse
.By default, we'll look for a
tool.pyupgrade
section inpyupgrade.toml
orpyproject.toml
(in that order), and read the configuration from there. Command line arguments will override configuration file settings, which will override command line argument defaults. We also add a--config-file
option to override the config file path.Fixes #511.
Example Output
TODO
ConfigArgParse
dependencyargparse
toconfigargparse