Closed bittner closed 3 years ago
If you are suggesting that flake8-black
should programmatically edit the user's flake8 configuration, I am not keen.
Given there is a conflict between the flake8 and black default line length, I think the user should resolve this.
(edited to fix typo)
Thanks for getting back about this!
To ensure we avoid misunderstandings, can you define "programmatically edit"?
What many (if not most) of the Pylint and Flake8 plugins do, is "correct" Pylint's or Flake8's sensitivity for certain error situations. For example:
locals()
to populate the context should be avoided for security reasons, so when the plugin detects that situation it makes Flake8 report that as a violation.In essence, these plugins establish an expected behavior for using those linters in, e.g., Django projects.
If you project this view to the use of Black, we want Flake8 to not to report things that are "okay" for Black out-of-the-box. Doesn't that make sense? Of course, if you explicitly set a Flake8 configuration setting in a configuration file that flake8
reads then that should take precedence (which would be intuitive).
Seen this way, there is no "conflict" of Flake8's expectations if you use Black. In fact, the natural way to see this is likely: If you use Black (which is meant to be automatic and "uncompromising" as a code formatter) you accept Black's rules, which also intends you accept them to overrule Flake8's rule if they interfere. If you don't want that you'll configure Black's behavior (not Flake8's).
I thought you meant the tool should edit the user's .flake8
file - which I am not keen on.
It sounds like (without checking the implementation) that these other flake8 plugins change the flake8 settings (after flake8 has loaded its configuration)? That seems a bit too magic for my tastes.
flake8-django is a Flake8 extension just as yours. They operate on the ast. Nobody is changing settings on the fly, let alone editing. There's nothing magic about all that.
I'm glad you're not keen on editing Flake8 configuration files. And so do I. I'd be happy to get away with just the defaults. Unfortunately, Black reformats the code with a preferred line length of 88 characters. Flake8 would typically report lines long like this. With a Flake8 plugin you can override Flake8's behavior, e.g. making it accept Black's choices. That would be a logic behavior and all I'm asking for.
I think I missed a notification, apologies for the very late reply. Quoting bittner:
With a Flake8 plugin you can override Flake8's behavior, e.g. making it accept Black's choices. That would be a logic behavior and all I'm asking for.
I think that's the same as what I meant by:
change the flake8 settings (after flake8 has loaded its configuration)
And no, I don't want to do this. The user could have multiple plugins installed and if any of them do automatic changes to the core settings, it will quickly get very confusing and difficult to debug unexpected interactions.
I much prefer Explicit is better than implicit here (Zen of Python), and making the user pick a line length and configure flake8 and/or black accordingly.
Closing as "won't fix", but thank you for explaining your idea.
@bittner You can forget about this flake8 extension, one can easily use flake8 and black without it. If we wait a little bit we would likely see flake8 defaults being switched to match black ones. Until this happens manually tuning flake8 config is better because other tools (IDEs) may fail to produce same results if they miss that extension.
Currently, the README instructs you to add some configuration for
flake8
in boiler-plate style. This is neither user-friendly nor very elegant.For an improved user experience this plugin may modify
flake8
's defaults to satisfyblack
's defaults (e.g.max-line-length = 88
) out-of-the-box.Potential role models
See flake8-django for a flake8 plugin that does things like that.