pyproject.toml configuration wrapper for pyupgrade
Via pip
pip install pyproject-pyupgradeVia poetry
poetry add --group dev pyproject-pyupgradeVia pipx
pipx install -f pyproject-pyupgradeMake sure you have a desired version of pyupgrade
installed in your python environment.
Add the following section in your pyproject.toml:
[tool.pyupgrade]
# for example, if you're using python 3.10
py310-plus = trueAnd then just execute it via CLI
pyproject-pyupgrade [filename [filenames...]]or shorter version
ppyupgrade [filename [filenames...]]So, basically you specify flags that you want to add to pyupgrade
CLI arguments specifying them without leading two dashes (--).
This is the way how you can supply any option that your version of pyupgrade receives
There is also one additional parameter provided exclusively by pyproject-pyupgrade wrapper:
[tool.pyupgrade]
pyproject-pyupgrade-debug = trueOr directly via CLI
ppyupgrade --pyproject-pyupgrade-debug ...This option is going to output debug information about pyproject-pyupgrade.
Info about parsed configuration from pyproject.toml (if there is one) and all the flags
See pre-commit for instructions.
Sample .pre-commit-config.yaml:
repos:
- repo: https://github.com/venomlab/pyproject-pyupgrade
rev: v0.1.1
hooks:
- id: ppyupgrade- Add tests and
toxconfig to run them for all supported python versions - Add option to specify custom
pyupgradecommand. It allows in case if you want to chain pyupgrade wrappers (for instance, with pyupgrade-directories) - Add better parser for TOML. Right now the parser is ultra primitive and might lead to errors if used improperly
- If
pythonversion >=3.11use tomllib forpyproject.tomlparsing - Support adding custom options or key-value arguments to
pyupgradeCLI - Support storing configuration in
pyupgrade.ini - Support storing configuration in
tox.ini - Support storing configuration in
setup.cfg