Code Monkey home page Code Monkey logo

Comments (6)

john-hen avatar john-hen commented on June 16, 2024

I like the idea, I just don't know how we would make it work. If two packages define the command as an entry point, here flake8, then wouldn't it depend on install order which package gets called?

from flake8-pyproject.

woile avatar woile commented on June 16, 2024

That's a very good question that I don't know the answer haha I think ppl from flake9 are directly modifying the flake8 source 🤔

from flake8-pyproject.

john-hen avatar john-hen commented on June 16, 2024

Yeah, flake9 seems to have vendored flake8, that's how they do it.

from flake8-pyproject.

john-hen avatar john-hen commented on June 16, 2024

Maybe there is a way to do this if we get Flake8 to run the code here as a plug-in. Then we could patch it live whenever the regular flake8 entry point is invoked. I think. I haven't quite figured out yet how to do it and if it'll actually work.

from flake8-pyproject.

vcalvert avatar vcalvert commented on June 16, 2024

Maybe there is a way to do this if we get Flake8 to run the code here as a plug-in. Then we could patch it live whenever the regular flake8 entry point is invoked. I think. I haven't quite figured out yet how to do it and if it'll actually work.

This caused me to do a bit of code-diving, the result is in #8.

from flake8-pyproject.

john-hen avatar john-hen commented on June 16, 2024

@vcalvert As far as I can tell, your code does not work as is.

I played around with this a bit more, but I think (and I could be wrong) that as of Flake8 5.0, plug-ins are loaded after the configuration files, whereas it was the other way around before. (Again, I could be wrong.) So by the time the plug-ins are loaded, it might be too late to monkey-patch the loading of the configuration files. See Application.initialize().

But there's another step that happens after the plug-ins are loaded, when Flake8 calls parse_configuration_and_cli(), which ultimately calls options.aggregator.aggregate_options(). Since that happens after the configuration files are loaded, I think we could hook in there with a plug-in.

However, the behavior may be somewhat different then. This "merges" options with whatever was previously loaded. So that could mean configuration files not named pyproject.toml in parent folders of the current working directory. Which doesn't sound so bad, but is different from what the flake8p entry point currently does: It just looks at pyproject.toml if it finds it in the working directory, but then disregards all other files. Might not be a deal-breaker, just a difference. And also, as you mentioned in the PR, this might be the behavior Flake8 would implement eventually, via "configuration plug-ins". So maybe this is the right approach. I just haven't made up my mind yet.

from flake8-pyproject.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.