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

Migrate flake8 config to pyproject.toml #29

Closed
2 of 3 tasks
johnthagen opened this issue Sep 26, 2020 · 25 comments · Fixed by #164
Closed
2 of 3 tasks

Migrate flake8 config to pyproject.toml #29

johnthagen opened this issue Sep 26, 2020 · 25 comments · Fixed by #164
Assignees
Labels
enhancement New feature or request upstream

Comments

@johnthagen
Copy link
Owner

johnthagen commented Sep 26, 2020

If/when the flake8 developers decide to support pyproject.toml, should move flake8 configuration to that to consolidate configurations.

Current Status

This comment lists blockers the Flake8 developers have listed:

This comment lists a non-technical reason a Flake8 developer has against TOML (against the creator of TOML himself):

Recent tweets:

@johnthagen johnthagen added enhancement New feature or request upstream labels Sep 26, 2020
@johnthagen johnthagen changed the title Migrate flake8 configuration to pyproject.toml Migrate flake8 config to pyproject.toml Sep 26, 2020
@drhagen
Copy link
Contributor

drhagen commented Apr 29, 2021

Issue for flake8 pyproject.toml support was migrated and locked.

@Halkcyon
Copy link

Halkcyon commented Jun 3, 2021

@drhagen reading through that with the broken links is quite a mess. Has any progress been made in the year+ since that issue was closed on supporting pyproject.toml like a lot of other popular packages have?

@agronholm
Copy link

As a workaround, you can use pyproject-flake8.

@johnthagen
Copy link
Owner Author

johnthagen commented Dec 31, 2021

bpo-40059 is tracking the discussion about adding TOML parsing to the stdlib, which has historically been one of the blockers that the flake8 maintainer has listed as a requirement for supporting pyproject.toml.

Also see:

@johnthagen
Copy link
Owner Author

johnthagen commented Feb 22, 2022

tomli has been accepted into the stdlib for 3.11+ as tomllib

@johnthagen

This comment was marked as outdated.

@agronholm
Copy link

It's a crutch until flake8 itself gets TOML support. Now that TOML support is in stdlib, there shouldn't be any excuse left for them not to add pyproject.toml support.

@johnthagen
Copy link
Owner Author

johnthagen commented Apr 4, 2022

It appears that the recent acceptance of tomllib into the std library has not been enough to motivate flake8 devs to begin adding support at this time:

@agronholm

This comment was marked as off-topic.

@johnthagen johnthagen mentioned this issue May 14, 2022
2 tasks
@johnthagen
Copy link
Owner Author

johnthagen commented May 15, 2022

#91 uses pyproject-flake8 to move flake8 configuration into pyproject.toml. I am going to leave this issue open until flake8 adds native support for pyproject.toml, as there are certain edge cases that (e.g. editors shelling out to flake8) this does not fully solve.

@flying-sheep
Copy link

flying-sheep commented Jul 12, 2022

The problems with pyproject-flake8 are that it’s not upstream, and therefore needs more configuration than flake8, and is less integrated than it. E.g.:

  • Its versions don’t reflect flake8 versions, so pre-commit autoupdate doesn’t bump its version, which means the cache will continue to hold the flake8 version that was downloaded when the newest pyproject-flake8 was released.
  • IDE/Editor plugins like VS Code’s need to be configured to use pflake8 instead of flake8.

I’m very much a fan of having all development configuration in pyproject.toml and wonder how we can get every project to support it.

@agronholm
Copy link

Which is why it would be nice to get that support in upstream flake8 now that all of the blockers should be gone.

@agronholm

This comment was marked as off-topic.

@flying-sheep
Copy link

flying-sheep commented Aug 18, 2022

I think there’s two facets to this:

  1. The opaque approach the PyCQA people are taking here with closing & locking mostly* without even hinting at the reason. They don’t treat people with respect, they don’t acknowledge any of the arguments, they just cut off communication as if everyone was a bad faith actor or obviously wrong. I think that’s inexcusable. People write these issues because they want to make things better, not to spite Anthony or something.

    *The only hint I saw was in @NeilGirdhar’s issue Configuration file feature request revisited now that concerns addressed PyCQA/flake8#1632 (comment) where Anthony says “neither of the pip issues you linked are related”.

  2. One of the things Anthony considers a hard blocker still remains: Pip is still branching behavior based on the presence of pyproject.toml, specifically build isolation.

    @NeilGirdhar’s issue above does indeed link unrelated pip issues, as can be glanced from Isolated builds when both pyproject.toml and setup.py co-exist pypa/pip#8437 (comment): Pip uses build isolation independently from PEP 517: --no-use-pep517 doesn’t turn it off.

To fix the bad blood, the PyCQA people need to start respecting people filing issues and explicitly link the pip issues that point out that their blocker is still not resolved.

To fix the underlying technical issue, pip would need to switch build isolation on or off based on a criterion other than Path('pyproject.toml').is_file(). Unconditionally on would work for the flake8 maintainers (as stated in an email), alternatively I assume switching based on the [build-system] table would also work.

@agronholm
Copy link

Hm, I was under the impression that nowadays pip only does an isolated build if the build-system section is found in pyproject.toml. Am I mistaken?

@flying-sheep
Copy link

flying-sheep commented Aug 18, 2022

You are! I checked the current main branch code:

  1. The build_isolation config value is True by default and means “does the user allow pip to use build isolation?” (can be turned off via --no-build-isolation)
  2. A requirement’s use_pep517 defaults to has_pyproject or not importlib.util.find_spec("setuptools") (can be specified via --use-pep517/--no-use-pep517)
  3. pip will use build isolation if self.req.use_pep517 and build_isolation

Therefore without specifying any of the mentioned CLI options and with setuptools installed, build isolation depends on the existence of pyproject.toml, not its contents.

@agronholm
Copy link

Then it was at least discussed somewhere. Would seem like a good change to make in pip, yes?

@flying-sheep
Copy link

flying-sheep commented Aug 18, 2022

Seems like that’ll happen:

Once we kill setup.py install and setup.py develop, we should be good to flip the switch on build isolation and pyproject.toml-based builds as well.

See here: pypa/pip#9175 (comment)

@NeilGirdhar

This comment was marked as off-topic.

@johnthagen
Copy link
Owner Author

johnthagen commented Aug 18, 2022

Hey all, happy to use this as a forum to track status and discuss technical productive ways to improve the situation, but please refrain from personal attacks of any kind.

Thank you for your understanding.

@johnthagen
Copy link
Owner Author

johnthagen commented Nov 27, 2022

I am migrating to this Flake8 pyproject.toml tool instead:

The main advantages being:

  • It still allows the user to run flake8 rather than pflake8
    • This removes one more thing to teach about the differences of how to run flake8 with pyproject.toml
    • This helps with some editor integration
  • It doesn't monkey patch, so it might be a more stable way to get this functionality than pyproject-flake8

Disadvantages:

  • It is more complex than pyproject-flake8

Edit, done in:

@flying-sheep
Copy link

I just came across https://github.com/charliermarsh/ruff, which seems like a great and fast alternative to flake8, isort, …

@johnthagen
Copy link
Owner Author

I just came across https://github.com/charliermarsh/ruff,

Yes, I've been keeping my eye on Ruff as well. It looks very promising.

@johnthagen
Copy link
Owner Author

I have decided to migrate from Flake8 to Ruff for a variety of reasons. Ruff natively supports pyproject.toml so this particular papercut is solved with it.

To look at how I choose to do the migration, see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants