Skip to content

Commit

Permalink
Add a few more ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Feb 18, 2025
1 parent 47cc9c6 commit 1ebf17c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
6 changes: 3 additions & 3 deletions isort/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ def _with_from_imports(
}
if config.combine_as_imports and not ("*" in from_imports and config.combine_star):
if not config.no_inline_sort:
for as_import in as_imports:
for as_import, from_import_as_module in as_imports.items():
if not config.only_sections:
as_imports[as_import] = sorting.sort(config, as_imports[as_import])
as_imports[as_import] = sorting.sort(config, from_import_as_module)
for from_import in copy.copy(from_imports):
if from_import in as_imports:
idx = from_imports.index(from_import)
Expand Down Expand Up @@ -569,7 +569,7 @@ def _with_straight_imports(
) -> List[str]:
output: List[str] = []

as_imports = any((module in parsed.as_map["straight"] for module in straight_modules))
as_imports = any(module in parsed.as_map["straight"] for module in straight_modules)

# combine_straight_imports only works for bare imports, 'as' imports not included
if config.combine_straight_imports and not as_imports:
Expand Down
17 changes: 14 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,13 @@ lint.select = [
"E",
"F",
"FLY",
"PERF",
"PIE",
"PLC",
"PLE",
"RUF",
"S",
"UP",
"W",
]
lint.ignore = [
Expand All @@ -190,14 +195,20 @@ lint.ignore = [
"B904",
"E203",
"E501",
"PERF203",
"RUF100",
"UP006",
"UP035",
]
lint.exclude = [ "_vendored" ]
lint.exclude = [ "isort/_vendored/*" ]
lint.mccabe.max-complexity = 91 # Default is 10

[tool.ruff.lint.per-file-ignores]
"isort/deprecated/finders.py" = [ "UP034" ]
"isort/hooks.py" = [ "S603" ]
"isort/settings.py" = [ "S603", "S607" ]
"tests/*" = [ "S" ]
"isort/settings.py" = [ "PLC0414", "S603", "S607" ]
"isort/setuptools_commands.py" = [ "RUF012" ]
"tests/*" = [ "RUF001", "S" ]
"tests/unit/example_crlf_file.py" = [ "F401" ]
"tests/unit/test_wrap_modes.py" = [ "PIE804" ]

Expand Down
4 changes: 2 additions & 2 deletions scripts/check_acknowledgments.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ async def main():
)
results = response.json()
contributors.extend(
(

contributor
for contributor in results
if contributor["type"] == GITHUB_USER_TYPE
and contributor["login"] not in IGNORED_AUTHOR_LOGINS
and f"@{contributor['login'].lower()}" not in ACKNOWLEDGEMENTS
)

)

unacknowledged_users = await asyncio.gather(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_isort.py
Original file line number Diff line number Diff line change
Expand Up @@ -3019,7 +3019,7 @@ def test_import_by_paren_issue_460() -> None:
import io
import os
"""
assert isort.code((test_input)) == test_input
assert isort.code(test_input) == test_input


def test_function_with_docstring() -> None:
Expand Down Expand Up @@ -3783,7 +3783,7 @@ def test_command_line(tmpdir, capfd, multiprocess: bool) -> None:

tmpdir.join("file1.py").write("import re\nimport os\n\nimport contextlib\n\n\nimport isort")
tmpdir.join("file2.py").write(
("import collections\nimport time\n\nimport abc" "\n\n\nimport isort")
"import collections\nimport time\n\nimport abc" "\n\n\nimport isort"
)
arguments = [str(tmpdir), "--settings-path", os.getcwd()]
if multiprocess:
Expand Down

0 comments on commit 1ebf17c

Please sign in to comment.