-
-
Notifications
You must be signed in to change notification settings - Fork 308
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
pyproject.toml (PEP 518) support #234
Comments
In GitLab by @jgirardet on Jul 28, 2018, 06:04 Hi,
As simple implementation, all those possibility should return a dict to add to a configPArser. Thank for your advice. |
In GitLab by @valignatev on Jul 28, 2018, 07:22 I'm nobody, of course (in the terms of flake8 project), but I personally think that |
In GitLab by @tmose1106 on Jul 29, 2018, 11:58 I am also not affiliate with flake8 in any way, but here is my two cents: At the moment, is hard to tell which toml library to choose. As of today I have found the toml library to work just fine for parsing. It is also worth noting that if poetry picks up usage in the future, tomlkit could very well become the dominant toml library. Specifically to @jgirardet's question, I feel that the second option would make the most sense at the moment. Simply make the toml library an optional dependency and if there is a |
In GitLab by @jgirardet on Jul 30, 2018, 03:47 mentioned in merge request !245 |
In GitLab by @d_ on Jan 30, 2019, 02:38 mentioned in commit d_/dlc-gui@248a6b88d5d620dac793b7856fc217b0e1210e5d |
In GitLab by @d_ on Jan 30, 2019, 02:50 mentioned in commit d_/dlc-gui@ba4aadd9fccb0568c8712321c664fa83a7bca36a |
In GitLab by @radek-sprta on Feb 28, 2019, 24:56 A temporary solution could be what tox did -- just inline the ini configuration under tool.flake8.legacy_flake8_ini key. |
In GitLab by @asottile on Feb 28, 2019, 07:37 @radek-sprta iirc tox did that because they use a special ini parser with extra features (substitutions etc.). Doing that for flake8 wouldn't really help (you'd still need toml to parse that) |
In GitLab by @rossmacarthur on Mar 27, 2019, 03:26 I would really like this to be done 🙏, I don't mind working on it. @jgirardet @tmose1106 my opinion is to use the I don't think |
In GitLab by @asottile on Mar 27, 2019, 08:31
Just want to point out that both of the "pyproject.toml PEPs" (517 and 518) are about defining a build system for pip and aren't speccing that projects should stuff configuration in there (PEP 518 briefly mentions the tool table but is referring to configuration of PEP517/PEP518 build tools). See also this thread from pypa/pip further about that topic. |
In GitLab by @d_ on Mar 30, 2019, 13:13 mentioned in commit d_/dlc-gui@74b0d42bdfb742217720dc2d806d2fbbcda93341 |
In GitLab by @ethanhs on May 15, 2019, 15:30 FWIW, I read the PEP as allowing configuration of any tool, and asked on the packaging discourse. Based on https://discuss.python.org/t/pep-518-clarify-scope-of-tool-section/1682/2 I think it is safe to say that all tools are allowed in |
In GitLab by @sigmavirus24 on May 18, 2019, 11:11 @ethanhs As I understand Anthony's comment, he was responding to the assertion that Flake8 should grow this because the PEP allows for tools to use the file. The PEP doesn't require tools to use If Flake8 were a tool like homebrew or pip that could reasonably report usage to us, we could say "Well we can deprecate X, Y, and Z because no one is using it to allow for the surface area to expand to supporting I don't think anyone is saying "pyproject.toml" is out of the question. It's just a matter of the fact that the existing configuration processing in Flake8 is ridiculously complex because of historical reasons and backwards compatibility. I would feel far more comfortable (if I were still the primary Flake8 maintainer) if I could deprecate a bunch of the config related things before adding support for another file. Further, while there hasn't been an explicit "yes" or "no", I'd like to remind everything that "No is temporary, but yes is 'forever'" as far as any responsibly maintained project is concerned. In other words, given our existing attempts to provide backwards compatibility, it's entirely likely that we'd never be able to get rid of this once it was added. That's a long term maintenance nightmare, sadly. |
In GitLab by @Stavros on May 27, 2019, 10:33
Why can't it? I'd opt in.
Is there not, essentially, an order with which ini files are processed? If so, adding one more file to that list doesn't sound terrible, although I do see your argument about having to then maintain that for ever... |
In GitLab by @jgirardet on May 27, 2019, 12:09 Initially I thought it was great to add it then I started !245. And I read the opinion of Guido in rejecting pyproject.toml support in mypy : python/mypy#5205 Maybe he is right. Maybe old tools should keep .ini support and don't bother pyproject. Maybe only new tools should try to support pyproject.toml and ignore .ini files (this is what black did). So I will not go further for now in !245. I think we should close !245. But if maintainers really want to add it, I'll then finish the job. |
In GitLab by @olibre on Jun 14, 2019, 01:40 Hi @jgirardet Guido said in August 2018:
But his opinion is changing over the time. For instance, Guido rejected the idea of In my case, having the configuration stuff of my Python tools in one file will clean my source code root directory. Multiple configuration files polluting the source code directory is not pleasant, isn't it? |
In GitLab by @jokerjokerer on Jun 15, 2019, 03:04 It's always a trade-off though and depends on the size of that file:
|
In GitLab by @olibre on Jun 16, 2019, 09:07 You are right @jokerjokerer ... |
In GitLab by @aiguofer on Jul 12, 2019, 13:39 I was just in the process of trying to unify my various config files... down to |
In GitLab by @d_ on Aug 18, 2019, 14:16 mentioned in commit d_/dlc-gui@fa5edf6dd433e041a1b00459c8cd45ce1c4fb003 |
In GitLab by @d_ on Aug 18, 2019, 14:20 mentioned in commit d_/dlc-gui@6e62f9236b0e28f781a439b01c581f0b56b38d3f |
In GitLab by @pawamoy on Oct 21, 2019, 13:51 Same here. Last three are One of the main issue when adding support for Despite all this, I still see support for Plus, once you support Well, I just wanted to share these thoughts. I hope flake8, pytest and coveragepy will support TOML configuration at some point :slight_smile: (could be soon for coveragepy 😉). As for those who already added support for
|
In GitLab by @sigmavirus24 on Nov 26, 2019, 18:45 @asottile We should just deprecate everything else, switch to toml for 4.0 and be done with it. I'll send the PR just to end the ridiculously passive-aggressive comments here |
In GitLab by @asottile on Nov 26, 2019, 18:48 lol I'd rather just close + lock to be honest 🤦 I don't think toml is the way especially with pip continuing to have weird behaviour when the file even exists |
In GitLab by @janw on Nov 26, 2019, 23:19 May I ask what weird behavior are you referring to, @asottile? Pip’s logic regarding pyproject.toml is described here and appears to be quite sound and thought-through. Also I might add, as has been argued here, with pyproject.toml being the PEP-designated “way forward” (albeit not strictly for non-build tools), other tools initially implementing support poorly or introducing bugs during the transition should not dissuade the adoption of it. Not even if it’s Pip. Personally, I wouldn’t take any of the comments made here as passive aggressive, @sigmavirus24. I think people are just offering up firsthand accounts on their move to migrate to pyproject.toml, and making note of the general adoption of pyproject.toml in other projects. This gives you insights on what the collective of project tools is heading towards, and is something worth to consider I think. Even if one is not willing to “lead the pack”, embracing the momentum that’s clearly there is a good thing. As for deprecating a bunch of things: please do. Nothing requires you to keep maintaining old cruft for years and years over multiple major releases, just to keep everyone happy all the time. I for one greatly prefer dropping things suddenly in the next major release if that makes way for new things, better maintainability, a better tool. |
In GitLab by @asottile on Nov 27, 2019, 06:02
just the presence of the file changes how your project is built -- I can already see the "I can't use flake8 because I can't use isolated builds" issue and then we'll be back to supporting setup.cfg/.flake8 forever (not to mention editable installs still aren't a proper thing for toml gives us no benefits over the current format except some people get to delete an extra file from their repository root. On the downsides, we gain a dependency. There's also additional surface area to support around configuration loading (which we're currently trying to simplify!). Not to mention the complexity for plugin authors / documentation / etc. (toml is not simple strings and so I assume someone will come knocking on the door for custom toml data types soon enough as well). And lastly, the comments about what other projects are doing and "flake8 is the hold out" are not at all productive to conversation -- if you have something productive about why flake8 should do it beyond "because toml is cool and everyone else is doin it" then please add to the discussion. Otherwise you're at best just adding another email to the inbox of the 80+ participants |
In GitLab by @ericvw on Nov 27, 2019, 10:43 I echo a similar sentiment that @sigmavirus24 and @asottile share. Looking at this pragmatically, adding, or migrating fully towards, While PEP 518 does specify that the Looking at other tools and utilities which have configuration files, they typically have their own well-defined file name and format which they respect. It's worthwhile to take a step back and ask ourselves why many utilities we use today take this approach instead of a single or shared configuration file Personally, I much prefer to use a tool-specific configuration file (i.,e If there is a strong object and pragmatic argument of what |
In GitLab by @danyeaw on Nov 27, 2019, 11:45 Thanks for the great library ❤️ As a user of This wasn't a request to solve a problem in Maybe someone would be willing to signup to support this Feature now and in the future? |
In GitLab by @sigmavirus24 on Nov 27, 2019, 12:37
I see this suggestion so often and never does anyone step up. And frankly, especially in this case, with the horrible legacy that is config discovery and parsing in Flake8, I blame no one for wanting to step up to maintain this. I also appreciate the implicit "Things work so well today, how hard could this really be to add" because that means that at least the config user experience isn't as bad as the config handling is in the code itself. (I still think it's crap behaviour but whatever.) |
In GitLab by @thnee on Nov 28, 2019, 13:28 If it's already established that flake8 has a horrible legacy in its config parsing, then it seems to me that logically speaking the right thing to do is drop the old standards like To anyone who says that it provides no new technical value, I would just like to say, sure, you are technically correct. But there is value in standardizing things. There is definitely an unnecessary complexity and learning curve currently in the Python ecosystem, when it comes to project config files, and that is worth improving. And to be clear I have no affiliation with any of this, this is just my opinion as a Python user who has created plenty of projects. The point is it doesn't really matter so much if the file format is INI or TOML or something else, as long as the overall situation is improved and continues to improve. |
In GitLab by @asottile on Nov 28, 2019, 13:49 If you want this, I'd suggest lobbying for the following:
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. For example, consider the frustration due to the exact opposite issue on black |
In GitLab by @janw on Nov 28, 2019, 14:26
I completely agree; that’s exactly what I was alluding to in my earlier comment. A clean cut with the next major release; dropping a few things that are basically just hindering progress, and adding complexity for maintainers, contributors and users alike. The complexity argument keeps coming up here, so IMHO it’s clearly time to simplify. Bringing people another step closer to removing half a dozen config files from their Having had a look at the config parsing code I can even see why the argument comes up, but it certainly isn’t an impossible thing to untangle. In looking around a bit and trying out a few things I managed to replace all the possible INI file detection, parsing, etc. with a rudimentary pyproject.toml loader in the matter of a few hours, and immediately new options for simplification opened up. And I’d be happy to contribute MRs for this. |
In GitLab by @sigmavirus24 on Nov 28, 2019, 14:37 We've done our best to not deprecate things across major releases except |
In GitLab by @chadgh on Jan 16, 2020, 09:03 Here is the awesome-pyproject list. It would be helpful if and when flake8 supports pyproject.toml to notify the list maintainer or submitting a PR to update the list indicating that flake8 supports the file now. Just FYI. :) |
In GitLab by @erikkemperman on Feb 27, 2020, 04:19 I appreciate that just having fewer files (and especially formats) in the project root and "everyone else is doing it" aren't great arguments in favour of, well, anything. However, I still find myself wishing flake8 would support pyproject.toml for pretty much those very reasons. Judging from this thread I am not alone, although I certainly acknowledge that others clearly express preference for having separate config files for each tool. I guess this is true especially when the configurations get more complicated -- whereas simple projects, sticking to the tool defaults mostly, might prefer a single file. But I don't think it has to be either/or -- it seems to me it should be feasible to support whatever the user prefers. I'm not a huge fan of TOML actually, but am not going to litigate the issue (the PEP mentions their rationale, such as it is). It's indeed unfortunate that there isn't yet a parser for it in the standard library, I agree, but both toml and tomlkit seem pretty reliable from what I've seen. The spec itself is not formally at 1.0 either but has been stable for years and the maintainers say that 1.0 will be compatible with the current (already pretty old) release. My understanding is that Pip has resolved its troubles around the existence of pyproject.toml (but that's just from the release notes, I haven't actually tried anything complicated.) So anyway, wanting to be constructive with my feedback, I took some time playing around with !245 (squashed the commits for legibility, rebased on current master, fixed some minor issues to make all the tests pass). And I'd like to hereby commit to spending some more time with it if anyone is interested or would like to suggest improvements. https://gitlab.com/erikkemperman/flake8/-/commits/245-redux @jgirardet Of course this remains almost completely your work, and so I took care to retain your authorship of the commit... But I trust you'll free to object to this -- I could either reset the author to myself and instead acknowledge your effort in the commit message, or simply throw away the whole thing if you prefer. |
In GitLab by @asottile on Feb 27, 2020, 20:16
it is still a problem, the presence of
|
In GitLab by @erikkemperman on Feb 28, 2020, 06:04 Thanks for the quick response! Ah, that may be a different pip issue than the one I thought you were pointing out above. I assumed you were thinking of pypa/pip#6163 -- which was why mypy, for example, got rid of their pyproject.toml (and reinstated it as this pip issue was fixed). Sorry, my mistake! It seems to me that the presence of pyproject.toml signals (to build tools and installer) that you want to follow PEP517. In that case, it seems reasonable to me that if you need a dependency during build (such as six in your example) it ought to be listed as such in the toml file. From that point of view, the stack trace you quote does not surprise me. After all, explicit control over build-time dependencies was kind of the point of the PEP. Pip has an option to disable it (even in the presence of pyproject.toml), and the above works as expected if I add it:
Likewise, things work fine if I don't use that flag but add six as a build dependency:
I don't believe anyone is proposing that flake8 (or anyone else) should support reading its configuration from pyproject.toml in projects which otherwise do not follow PEP517... Or are they? So I guess I'm now not entirely sure what problem you are expecting this to cause for users (and maintainers) of flake8. Please don't get me wrong, I don't mean to be contrary for the sake of it. Just trying to figure out if I understand the objections properly. Thanks again for taking the time to respond -- and for maintaining this great package! |
In GitLab by @asottile on Feb 28, 2020, 07:06 sorry in case it wasn't clear, six is just an easy demonstration of the issue -- there are situations where an isolated build is not possible and presence of pyproject.toml forces you into isolated build with no opt-out |
In GitLab by @intgr on Feb 28, 2020, 07:55 That pip behavior is surprising and a caveat for |
In GitLab by @asottile on Feb 28, 2020, 08:00 it is: the list of blockers more specifically because we cannot in good faith deprecate and remove the other configuration options |
In GitLab by @FallenWarrior2k on Feb 28, 2020, 08:08 Is there a need to deprecate other options, and if so, why? As far as I know, most other tools that support pyproject.toml haven't deprecated support for setup.cfg, tox.ini, or their own config files. |
In GitLab by @asottile on Feb 28, 2020, 08:13 the reasoning is covered above, but it's not surprising that one hasn't read this enormous thread the tl;dr is that the configuration parsing is some of the most tangled code in flake8 and adding more complexity and more ways to do something is not desirable |
In GitLab by @rpdelaney on Feb 28, 2020, 11:16 You give good reasons why it would benefit flake8 to do this (culling tangled incomprehensible config parsing code), but dropping support could also be a long-term benefit to the entire ecosystem if publicized well and in advance. The plethora of ancient, broken configuration options won't die in part because tools like flake8 continue to support them. |
In GitLab by @erikkemperman on Feb 28, 2020, 12:57
That's just unfair. I for one would like to see this supported, obviously, but it's completely understandable -- not to mention correct -- that maintainers of such a widely used package be very reluctant to change such a fundamental component. And please note that I just wanted to throw something concrete out there, and demonstrate some goodwill perhaps, in updating the original merge request -- in no way am I proposing that anything change imminently. Maybe some untangling would be in order first, before configuration formats can be factored in or out more comfortably. That's probably no small task. |
In GitLab by @rpdelaney on Feb 28, 2020, 13:15
I'm not sure what you take my point to be, but to be clear, I understand the tension also. It is by no means easy to drop support for old things in a widely used app, nor is it obvious that that is the right thing to do here. But to build a case that it is the right thing to do, I think it's worth acknowledging the costs of maintaining legacy support indefinitely and without a planned (and publicized!) EOL timeline. The situation with the config parsing will either only get worse, or it will continue to sacrifice support for newer, better things in the name of maintaining the old things. I don't think that's sustainable. |
In GitLab by @erikkemperman on Feb 28, 2020, 13:39
Sorry if I've read too much into the sentence I quoted; it seemed to me maybe slightly accusatory. Glad to be wrong. |
In GitLab by @rpdelaney on Feb 28, 2020, 20:04 I think I see what you mean. I'm not intending to lay blame for the array of packaging standards at the feet of flake8: not even for the spaghetti of parsing code required to support all of them. It did not get this way because of any decision made here. But I do worry that a pattern of unwillingness to design exit strategies across the ecosystem has contributed maintaining these difficult tensions. So I don't want to lay blame, but I do want to call attention to the way that worries about backward-compatibility with breaking configuration changes can unintentionally contribute to the maintenance of the dysfunction. If flake8 were to, after a reasonably protracted and publicized time period, drop support for .flake8 / setup.cfg / etc in favor of pyproject.toml, no doubt there would be some grumbling. But it would also add momentum to the shift elsewhere and encourage others to "go with the flow". That might be a good thing. The key, I think, is the well-thought out and well publicized migration plan. First, we need to have one. Second, it needs to give people ample time to find out that the migration is planned, and adjust. I worry that @asottile and others might think that this is something that has to happen in 1 day with no advance notice except an open PR on this gitlab repo, but that doesn't have to be the case at all. There is a lot that can be done to make the transition less painful. Not painless, but the pain can be mitigated. As for pip, it seems like pip's support of PEP517 may be incomplete. I'm not sure how best to improve that, or what kind of levers would have to be moved. But flake8 need not be blocked by it. |
In GitLab by @asottile on Feb 28, 2020, 20:27 or we have zero pain by not migrating. look, I've stated what needs to happen above for this to even be considered -- until those two things change this is not happening. I understand this isn't a popular choice. if you'd like to continue this discussion please reach out to me privately, you may find the email address in my git commits |
there's been an uptick in those that cannot follow directions (NOTE: if you ask about pyproject.toml your issue will be closed as a duplicate of #234) so I will reiterate here: both of the things above are blockers before we'd even start considering an implementation only one of two of them has been resolved -- there is a the other has not (pip still has different behaviour based on the presence of if you'd like to continue this discussion please reach out to me privately, you may find the email address in my git commits |
In GitLab by @valignatev on Jun 11, 2018, 10:58
Hi! Is there a plan to support
pyproject.toml
from PEP 518?Specifically, it would be nice if flake8 could understand
[tool.flake8]
section in thepyproject.toml
file.The text was updated successfully, but these errors were encountered: