Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions docs/contributing/2.-coding-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ There should be a `tests/test_$MODULE_NAME.py` file created to correspond to eve

## Automated Code Cleaners

All code submitted to Hug should be formatted using Black and isort.
Black should be run with the line length set to 100, and isort with Black compatible settings in place.
All code submitted should be formatted using Ruff and isort.
Ruff should be run with the line length set to 100, and isort with Black compatible settings in place.

## Automated Code Linting

All code submitted to hug should run through the following tools:
All code submitted should run through the following tools:

- Black and isort verification.
- Ruff and isort verification.
- Flake8
- flake8-bugbear
- flake8-bugbear
- Bandit
- ruff
- pep8-naming
Expand Down
3 changes: 1 addition & 2 deletions isort/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class ExistingSyntaxErrors(ISortError):

def __init__(self, file_path: str):
super().__init__(
f"isort was told to sort imports within code that contains syntax errors: "
f"{file_path}."
f"isort was told to sort imports within code that contains syntax errors: {file_path}."
)
self.file_path = file_path

Expand Down
10 changes: 4 additions & 6 deletions isort/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def _with_from_imports(
)
if comment:
single_import_line += (
f"{(comments and ';') or config.comment_prefix} " f"{comment}"
f"{(comments and ';') or config.comment_prefix} {comment}"
)
if from_import in as_imports:
if (
Expand Down Expand Up @@ -459,8 +459,7 @@ def _with_from_imports(
# keep the name in the main list and hoist the comment to the statement.
if (
comment.lower().startswith("noqa")
and config.multi_line_output
== wrap.Modes.HANGING_INDENT # type: ignore[attr-defined]
and config.multi_line_output == wrap.Modes.HANGING_INDENT # type: ignore[attr-defined] # noqa: E501
):
comments = list(comments) if comments else []
comments.append(comment)
Expand All @@ -479,7 +478,7 @@ def _with_from_imports(
comment_prefix=config.comment_prefix,
)
single_import_line += (
f"{(use_comments and ';') or config.comment_prefix} " f"{comment}"
f"{(use_comments and ';') or config.comment_prefix} {comment}"
)
output.append(wrap.line(single_import_line, parsed.line_separator, config))

Expand Down Expand Up @@ -519,8 +518,7 @@ def _with_from_imports(
if (
len(import_statement) > config.line_length
and len(from_import_section) > 0
and config.multi_line_output
not in (wrap.Modes.GRID, wrap.Modes.VERTICAL) # type: ignore
and config.multi_line_output not in (wrap.Modes.GRID, wrap.Modes.VERTICAL) # type: ignore # noqa: E501
):
do_multiline_reformat = True

Expand Down
6 changes: 3 additions & 3 deletions isort/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
for import_name in just_imports:
associated_comment = nested_comments.get(import_name)
if associated_comment:
categorized_comments["nested"].setdefault(import_from, {})[
import_name
] = associated_comment
categorized_comments["nested"].setdefault(import_from, {})[import_name] = (
associated_comment
)
if associated_comment in comments: # pragma: no branch
comments.pop(comments.index(associated_comment))
if (
Expand Down
2 changes: 1 addition & 1 deletion isort/wrap_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def vertical_hanging_indent_bracket(**interface: Any) -> str:
if not interface["imports"]:
return ""
statement = vertical_hanging_indent(**interface)
return f'{statement[:-1]}{interface["indent"]})'
return f"{statement[:-1]}{interface['indent']})"


@_wrap_mode
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[tool.black]
line-length = 100

[project]
name = "isort"
dynamic = ["version"]
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_profile_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def format_profile(profile_name: str, profile: dict[str, Any]) -> str:
return f"""
#{profile_name}

{profile.get('description', '')}
{profile.get("description", "")}
{options}
"""


def document_text() -> str:
return f"{HEADER}{''.join(format_profile(profile_name, profile) for profile_name, profile in profiles.items())}"
return f"{HEADER}{''.join(format_profile(profile_name, profile) for profile_name, profile in profiles.items())}"


def write_document():
Expand Down
27 changes: 12 additions & 15 deletions tests/unit/test_identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,25 +231,22 @@ def test_complex_examples():
== 9
)
assert not imports_in_code("from os import \\")
assert (
imports_in_code(
"""
assert imports_in_code(
"""
from os \\
import (
system"""
) == [
Import(
line_number=2,
indented=False,
module="os",
attribute="system",
alias=None,
cimport=False,
file_path=None,
)
== [
Import(
line_number=2,
indented=False,
module="os",
attribute="system",
alias=None,
cimport=False,
file_path=None,
)
]
)
]


def test_aliases():
Expand Down
Loading