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 1502a96
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion isort/output.py
Original file line number Diff line number Diff line change
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
18 changes: 15 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,21 @@ 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/output.py" = [ "PLC0206" ]
"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
12 changes: 5 additions & 7 deletions scripts/check_acknowledgments.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ 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
)
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 1502a96

Please sign in to comment.