Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pyproject.toml as alternative to command line args #511

Closed
yoursvivek opened this issue Aug 4, 2021 · 2 comments
Closed

Use pyproject.toml as alternative to command line args #511

yoursvivek opened this issue Aug 4, 2021 · 2 comments

Comments

@yoursvivek
Copy link

Feature request

Instead of end-user running pyupgrade --py37-plus, we can utilise tools section in pyproject.toml like:

[tool.pyupgrade]
py37-plus = true

and just run the command pyupgrade

Implementation requirements: Usual requirements for finding pyproject.toml in parents folders if current directory is within the python project/packages applies. Single VCS repository may contain multiple python packages too.

Motivation

We have pyupgrade wired into pre-commit hook, but the hook itself is optional in large legacy code as it introduces huge diff. Without pre-commit hook, the onus falls back on developer to remember arguments for each projects or peek into .pre-commit-config.yaml.

isort has a similar functionality, that after following in pyproject.toml

[tool.isort]
profile = "black"

developer can simply run isort instead of isort --profile black.

@MarcoGorelli
Copy link
Contributor

Hi @yoursvivek - I think the answer will be similar to asottile/reorder-python-imports#101

@chrisbouchard
Copy link

I know this is an old issue, but would you consider a pull request using ConfigArgParse? (Or a similar library?) This library handles multiple file formats (including INI and TOML, the latter using the now-standard toml library), CLI argument parsing, and merging CLI options with config file options. And it uses argparse under the covers, so the existing parser definition could be reused.

If I understand correctly based on the discussion in asottile/reorder-python-imports#101, this would address your primary concern around adding a configuration file, which is the amount of code and effort dedicated to parsing—which I completely understand. I hope that using a library like this would be an acceptable option.

I would personally find a configuration file very valuable for linting. It's important to make sure everyone's using the same settings to avoid noisy git diffs, IDE noise, and spurious CI failures. We can use scripts and makefiles to provide CLI arguments, but they're easy to miss or ignore; to ignore a configuration file, one would need to add CLI arguments—and so the path of least effort is also the most correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants