Skip to content

Commit

Permalink
Fix comma behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycrosley committed Dec 25, 2020
1 parent 8b828fb commit 59f635a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions isort/wrap.py
Expand Up @@ -77,7 +77,13 @@ def line(content: str, line_separator: str, config: Config = DEFAULT_CONFIG) ->
line_parts = re.split(exp, line_without_comment)
if comment and not (config.use_parentheses and "noqa" in comment):
_comma_maybe = (
"," if (config.include_trailing_comma and config.use_parentheses) else ""
","
if (
config.include_trailing_comma
and config.use_parentheses
and not line_without_comment.rstrip().endswith(",")
)
else ""
)
line_parts[
-1
Expand All @@ -92,13 +98,16 @@ def line(content: str, line_separator: str, config: Config = DEFAULT_CONFIG) ->
content = next_line.pop()

cont_line = _wrap_line(
config.indent + splitter.join(next_line).lstrip(), line_separator, config
config.indent + splitter.join(next_line).lstrip(),
line_separator,
config,
)
if config.use_parentheses:
if splitter == "as ":
output = f"{content}{splitter}{cont_line.lstrip()}"
else:
_comma = "," if config.include_trailing_comma and not comment else ""

if wrap_mode in (
Modes.VERTICAL_HANGING_INDENT, # type: ignore
Modes.VERTICAL_GRID_GROUPED, # type: ignore
Expand Down

0 comments on commit 59f635a

Please sign in to comment.