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

E131: indent_chances overwritten #972

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
# ignore token lined up with matching one from a
# previous line
pass
elif isinstance(visual_indent, list) and text in visual_indent:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm so now this variable can be None, True, False, bytes, str, or a list of str? this seems like we're trying to do too much with dynamicism here -- is there any way to make this easier to understand than overloading the type further?

pass
else:
# indent is broken
if hang <= 0:
Expand Down Expand Up @@ -778,6 +780,13 @@ def continued_indentation(logical_line, tokens, indent_level, hang_closing,
if start[1] not in indent_chances:
# allow lining up tokens
indent_chances[start[1]] = text
else:
v = indent_chances[start[1]]
if not isinstance(v, (bool, type(None))):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see:

if list:
   ...
elif str / bytes:
    ...

are all of these branches covered by your tests?

if isinstance(v, list):
indent_chances[start[1]].append(text)
else:
indent_chances[start[1]] = [v, text]

last_token_multiline = (start[0] != end[0])
if last_token_multiline:
Expand Down
12 changes: 12 additions & 0 deletions testsuite/E12not.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,15 @@ def f1():
open('/path/to/some/file/being/written', 'w') as file_2, \
open('just-making-sure-more-continuations-also-work'):
file_2.write(file_1.read())


aaaa = (
sqla.session
.pop()
)


aaaa5 = (
sqla.session
.pop()
)