Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: deactivate Ruff isort split-on-trailing-comma #288

Merged
merged 3 commits into from
Jan 21, 2024
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
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ task-tags = ["cspell"]
[tool.ruff.isort]
known-first-party = ["compwa_policy"]

[tool.ruff.lint.isort]
split-on-trailing-comma = false

[tool.ruff.per-file-ignores]
"docs/*" = [
"E402",
Expand Down
5 changes: 1 addition & 4 deletions src/compwa_policy/check_dev_files/citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
from html2text import HTML2Text
from ruamel.yaml import YAML
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from ruamel.yaml.scalarstring import (
FoldedScalarString,
PreservedScalarString,
)
from ruamel.yaml.scalarstring import FoldedScalarString, PreservedScalarString

from compwa_policy.errors import PrecommitError
from compwa_policy.utilities import CONFIG_PATH, vscode
Expand Down
20 changes: 16 additions & 4 deletions src/compwa_policy/check_dev_files/ruff.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
executor(_remove_pydocstyle)
executor(_remove_pylint)
executor(_update_ruff_settings, has_notebooks)
executor(_update_ruff_pydocstyle_settings)
executor(_update_precommit_hook, has_notebooks)
executor(_update_pyproject)
executor(_update_vscode_settings)
Expand Down Expand Up @@ -262,7 +261,9 @@
def _update_ruff_settings(has_notebooks: bool) -> None:
executor = Executor()
executor(__update_ruff_settings, has_notebooks)
executor(_update_ruff_per_file_ignores, has_notebooks)
executor(__update_ruff_per_file_ignores, has_notebooks)
executor(__update_ruff_isort_settings)
executor(__update_ruff_pydocstyle_settings)

Check warning on line 266 in src/compwa_policy/check_dev_files/ruff.py

View check run for this annotation

Codecov / codecov/patch

src/compwa_policy/check_dev_files/ruff.py#L264-L266

Added lines #L264 - L266 were not covered by tests
executor(_remove_nbqa)
executor.finalize()

Expand Down Expand Up @@ -435,7 +436,7 @@
return lowest_version


def _update_ruff_per_file_ignores(has_notebooks: bool) -> None:
def __update_ruff_per_file_ignores(has_notebooks: bool) -> None:
pyproject = load_pyproject()
settings = get_sub_table(pyproject, "tool.ruff.per-file-ignores", create=True)
minimal_settings = {}
Expand Down Expand Up @@ -506,7 +507,18 @@
raise PrecommitError(msg)


def _update_ruff_pydocstyle_settings() -> None:
def __update_ruff_isort_settings() -> None:
pyproject = load_pyproject()
settings = get_sub_table(pyproject, "tool.ruff.lint.isort", create=True)
minimal_settings = {"split-on-trailing-comma": False}

Check warning on line 513 in src/compwa_policy/check_dev_files/ruff.py

View check run for this annotation

Codecov / codecov/patch

src/compwa_policy/check_dev_files/ruff.py#L511-L513

Added lines #L511 - L513 were not covered by tests
if not complies_with_subset(settings, minimal_settings):
settings.update(minimal_settings)
write_pyproject(pyproject)
msg = f"Updated Ruff isort settings in {CONFIG_PATH.pyproject}"
raise PrecommitError(msg)

Check warning on line 518 in src/compwa_policy/check_dev_files/ruff.py

View check run for this annotation

Codecov / codecov/patch

src/compwa_policy/check_dev_files/ruff.py#L515-L518

Added lines #L515 - L518 were not covered by tests


def __update_ruff_pydocstyle_settings() -> None:
pyproject = load_pyproject()
settings = get_sub_table(pyproject, "tool.ruff.pydocstyle", create=True)
minimal_settings = {
Expand Down
Loading