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

Flake plugin? #6

Closed
frejonb opened this issue Jan 3, 2022 · 6 comments
Closed

Flake plugin? #6

frejonb opened this issue Jan 3, 2022 · 6 comments
Labels
wontfix This will not be worked on

Comments

@frejonb
Copy link

frejonb commented Jan 3, 2022

Nice idea! What are the chances of wrapping it as a flake8 plugin?

@ariebovenberg
Copy link
Owner

ariebovenberg commented Jan 3, 2022

Hi @frejonb! making this a flake8-plugin would be a big win for usability, but it's made tricky because AFAIK flake8-plugins need to work without importing the actual source code.

So to make this into a plugin, I'd have be duplicate all Python's import logic. Which is reasonably complex in normal circumstances, but many libraries define conditional imports, star imports, re-exports and metaclasses.

tricky examples:

try:
    from place import Foo
except ImportError:
    from other_place mport Foo

class Bla(Foo):
    ...

class Qux(Base1 of SOME_FEATURE_FLAG else Base2):
    ...

class Foo(metaclass=Bar):  # a metaclass making slots maybe?
    ...

from somewhere import *  # what now????

For the initial version, I decided to go the import route. I'll keep this issue open because it's definitely worth investigating.

I will also address this in the README. I think many other people have the same question.

@ariebovenberg ariebovenberg added the enhancement New feature or request label Jan 3, 2022
@sondrelg
Copy link

sondrelg commented Jan 3, 2022

Just a suggestion, but what about just making it possible to run as a pre-commit hook instead? That would only require a __main__.py I believe, and would tick a lot of the same boxes. I (and I think a pretty large % of devs) run flake8 via pre-commit anyway.

@ariebovenberg
Copy link
Owner

Awesome! I'm tracking that in #13

@ariebovenberg
Copy link
Owner

@sondrelg __main__.py has since been implemented in version 0.2.0 which I just published.

@ariebovenberg ariebovenberg added needs refinement This issue needs refinement before work can start on hold The issue is currently paused or blocked help wanted Extra attention is needed and removed on hold The issue is currently paused or blocked labels Jan 5, 2022
@ariebovenberg
Copy link
Owner

Added 'help wanted' label: if anybody knows a way to trace complex class inheritance statically, let me know.

Otherwise this issue will remain on hold.

@ariebovenberg ariebovenberg removed enhancement New feature or request help wanted Extra attention is needed needs refinement This issue needs refinement before work can start labels Jan 17, 2022
@ariebovenberg
Copy link
Owner

Due to the complexities involved (tracing complex imports, class decorators, metaclasses) I've decided this feature is not feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants