Skip to content

Commit f756e56

Browse files
authored
Merge pull request #2432 from DanielNoord/ruff-it-up
Format with `ruff` instead of `black`
2 parents 012aa69 + 52f5134 commit f756e56

File tree

12 files changed

+106
-217
lines changed

12 files changed

+106
-217
lines changed

docs/contributing/2.-coding-standard.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ There should be a `tests/test_$MODULE_NAME.py` file created to correspond to eve
4141

4242
## Automated Code Cleaners
4343

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

4747
## Automated Code Linting
4848

49-
All code submitted to hug should run through the following tools:
49+
All code submitted should run through the following tools:
5050

51-
- Black and isort verification.
51+
- Ruff and isort verification.
5252
- Flake8
53-
- flake8-bugbear
53+
- flake8-bugbear
5454
- Bandit
5555
- ruff
5656
- pep8-naming

isort/exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class ExistingSyntaxErrors(ISortError):
3131

3232
def __init__(self, file_path: str):
3333
super().__init__(
34-
f"isort was told to sort imports within code that contains syntax errors: "
35-
f"{file_path}."
34+
f"isort was told to sort imports within code that contains syntax errors: {file_path}."
3635
)
3736
self.file_path = file_path
3837

isort/output.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def _with_from_imports(
339339
)
340340
if comment:
341341
single_import_line += (
342-
f"{(comments and ';') or config.comment_prefix} " f"{comment}"
342+
f"{(comments and ';') or config.comment_prefix} {comment}"
343343
)
344344
if from_import in as_imports:
345345
if (
@@ -459,8 +459,7 @@ def _with_from_imports(
459459
# keep the name in the main list and hoist the comment to the statement.
460460
if (
461461
comment.lower().startswith("noqa")
462-
and config.multi_line_output
463-
== wrap.Modes.HANGING_INDENT # type: ignore[attr-defined]
462+
and config.multi_line_output == wrap.Modes.HANGING_INDENT # type: ignore[attr-defined] # noqa: E501
464463
):
465464
comments = list(comments) if comments else []
466465
comments.append(comment)
@@ -479,7 +478,7 @@ def _with_from_imports(
479478
comment_prefix=config.comment_prefix,
480479
)
481480
single_import_line += (
482-
f"{(use_comments and ';') or config.comment_prefix} " f"{comment}"
481+
f"{(use_comments and ';') or config.comment_prefix} {comment}"
483482
)
484483
output.append(wrap.line(single_import_line, parsed.line_separator, config))
485484

@@ -519,8 +518,7 @@ def _with_from_imports(
519518
if (
520519
len(import_statement) > config.line_length
521520
and len(from_import_section) > 0
522-
and config.multi_line_output
523-
not in (wrap.Modes.GRID, wrap.Modes.VERTICAL) # type: ignore
521+
and config.multi_line_output not in (wrap.Modes.GRID, wrap.Modes.VERTICAL) # type: ignore # noqa: E501
524522
):
525523
do_multiline_reformat = True
526524

isort/parse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
460460
for import_name in just_imports:
461461
associated_comment = nested_comments.get(import_name)
462462
if associated_comment:
463-
categorized_comments["nested"].setdefault(import_from, {})[
464-
import_name
465-
] = associated_comment
463+
categorized_comments["nested"].setdefault(import_from, {})[import_name] = (
464+
associated_comment
465+
)
466466
if associated_comment in comments: # pragma: no branch
467467
comments.pop(comments.index(associated_comment))
468468
if (

isort/wrap_modes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def vertical_hanging_indent_bracket(**interface: Any) -> str:
265265
if not interface["imports"]:
266266
return ""
267267
statement = vertical_hanging_indent(**interface)
268-
return f'{statement[:-1]}{interface["indent"]})'
268+
return f"{statement[:-1]}{interface['indent']})"
269269

270270

271271
@_wrap_mode

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[tool.black]
2-
line-length = 100
3-
41
[project]
52
name = "isort"
63
dynamic = ["version"]

scripts/build_profile_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ def format_profile(profile_name: str, profile: dict[str, Any]) -> str:
2424
return f"""
2525
#{profile_name}
2626
27-
{profile.get('description', '')}
27+
{profile.get("description", "")}
2828
{options}
2929
"""
3030

3131

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

3535

3636
def write_document():

tests/unit/test_identify.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,22 @@ def test_complex_examples():
231231
== 9
232232
)
233233
assert not imports_in_code("from os import \\")
234-
assert (
235-
imports_in_code(
236-
"""
234+
assert imports_in_code(
235+
"""
237236
from os \\
238237
import (
239238
system"""
239+
) == [
240+
Import(
241+
line_number=2,
242+
indented=False,
243+
module="os",
244+
attribute="system",
245+
alias=None,
246+
cimport=False,
247+
file_path=None,
240248
)
241-
== [
242-
Import(
243-
line_number=2,
244-
indented=False,
245-
module="os",
246-
attribute="system",
247-
alias=None,
248-
cimport=False,
249-
file_path=None,
250-
)
251-
]
252-
)
249+
]
253250

254251

255252
def test_aliases():

0 commit comments

Comments
 (0)