diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2020-12-26 23:04:46 -0800 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2020-12-26 23:04:46 -0800 |
commit | 509af74d51438442aa22def564cf7ecd6efe5a2d (patch) | |
tree | 81d2a297e29bd3f8594133f9ad98a775d57c2afe /isort/wrap.py | |
parent | c48fd911e4afd8f542f561490b16aeaaaabe9fae (diff) | |
parent | a19e364f1464f1683c22394d9910f21df05b9a5e (diff) | |
download | isort-509af74d51438442aa22def564cf7ecd6efe5a2d.tar.gz |
Merge branch 'develop' of https://github.com/timothycrosley/isort into develop
Diffstat (limited to 'isort/wrap.py')
-rw-r--r-- | isort/wrap.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/isort/wrap.py b/isort/wrap.py index 11542fa0..e993ae0f 100644 --- a/isort/wrap.py +++ b/isort/wrap.py @@ -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 @@ -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 |