You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For this kind of formatting, the patch seems to be easy
diff --git a/src/cercis/lines.py b/src/cercis/lines.py
index e774d63..7efde52 100644
--- a/src/cercis/lines.py+++ b/src/cercis/lines.py@@ -1087,7 +1088,7 @@ def can_omit_invisible_parens(
max_priority = bt.max_delimiter_priority()
delimiter_count = bt.delimiter_count_with_priority(max_priority)
- if delimiter_count > 1:+ if delimiter_count > 100:
# With more than one delimiter of a kind the optional parentheses read better.
return False
Normally after 2 method chain, it will be wrapped into parantheses, this changes make it basically to never wrap it in parantheses.
Thanks for the link. I remember looking at that feed a while ago. It goes against Black's super strict ethos to have it as an option, which is fine, but I raised it here hopefully so that it can be aded as an option.
Personally, I think your method chaining approach is great for shorter chains (in a page long chain you might miss the exist at first glance - but that's pretty minor). I assume the logic is more or less the same - an option for method_chain_dot_on_newline=True/False would be AMAZING
Is your feature request related to a problem? Please describe.
Method chaining is pretty powerful. It is encouraged when using Pandas DataFrames. However, Black regularly reformats this in inconsistent ways:
black does this:
It prioritises the first method being on the same line as the original dataframe/class. I think this reduces readability.
Describe the solution you'd like
An option like
method-chain-first-method-on-newline
which keeps the.some_function(
on the second line of the method chain.Describe alternatives you've considered
Not using Black. The problem here is the rest of the code is horrible to maintain.
Not using Black for blocks of this code. The problem here is the chained methods are rather horrible to manually format.
Using a different formatter. The problem here is most aren't as good as Black, are only minimally configurable or are slow/old/unmaintained etc...
Edge cases
This is fine as this is not yet method chaining:
This is fine as this is all one line and readable:
The text was updated successfully, but these errors were encountered: