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

Options for moving forward re: pyproject.toml #1447

Closed
Diggsey opened this issue Nov 10, 2021 · 1 comment
Closed

Options for moving forward re: pyproject.toml #1447

Diggsey opened this issue Nov 10, 2021 · 1 comment

Comments

@Diggsey
Copy link

Diggsey commented Nov 10, 2021

I read through #234 for context on this. Unfortunately the links were broken due to the move from gitlab, but from what I gathered, the following were things considered blockers for adding support for pyproject:

  1. pip to change its behaviour so mere presence of the file does not change functionality
    this probably involves a PEP, or at least a discussion on the various pypa mailing lists
  2. python to consider adding a standard library toml implementation
    neither toml (the configration language) nor the python implementations (most popular being toml, tomlkit, pytoml afaik) on pypi are even 1.0 so I don't see this happening any time soon

the first one is a hard blocker for me accepting this as it imposes technical limitations on users which are outside of the control of this project.

This only makes sense assuming these additional unwritten constraints:

  1. The code path which flake8 uses to read configuration is not made more complicated (ie. if pyproject.toml is added, the older options must go).

  2. Projects which are broken by PEP517 can continue to use flake8.

Since the original issue was opened, usage of pyproject.toml has only become more widespread, and the benefits of tools like poetry are so great, that I don't see it going away any time soon.

It also seems like blocker (1) is unlikely to ever be lifted. The choice then is:
a) Never support pyproject.toml in flake8.
b) Find a way to bypass blocker (1) by finding another way to remove the downsides.

As a result, I would like to propose some solutions for consideration, which I believe can avoid the downsides. For options which are backwards incompatible, the assumption is that they would happen in a new major release:

  • Do what black does.
    There is only a single toml configuration parser, and pyproject.toml is read by default, but the file to use can be overridden on the command-line, eg. black --config notpyproject.toml. Projects which cannot use pyproject.toml can use this option.

  • Open a path for simplifying the configuration code path.
    At the end of the day, reading configuration from potentially multiple sources should not be that complicated. If adding an additional source of configuration would complicate the existing code too much, then perhaps a way forward would be for people interested in adding pyproject.toml support, to first help to simplify the existing code such that a new config file is less of a burden to maintain.

Regarding the need for a TOML library: black, coverage, etc. seem to use tomli, which appears to be very lightweight, well tested, and is 1.x. If necessary, it could be an optional dependency, only imported if a pyproject.toml is found.

@asottile
Copy link
Member

dupe #234

@PyCQA PyCQA locked as spam and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants