Skip to content

Commit

Permalink
Add ruff rules ARG, C4, Q, SLF, T10 and TID
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Feb 24, 2024
1 parent a4383af commit 942ca16
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
11 changes: 11 additions & 0 deletions pste/migrations/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
# the 'revision' command, regardless of autogenerate
# revision_environment = false

[post_write_hooks]
hooks=ruff-check,ruff-format

ruff-check.type = exec
ruff-check.executable = ruff
ruff-check.options = check REVISION_SCRIPT_FILENAME

ruff-format.type = exec
ruff-format.executable = ruff
ruff-format.options = format REVISION_SCRIPT_FILENAME


# Logging configuration
[loggers]
Expand Down
2 changes: 1 addition & 1 deletion pste/models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def to_dict(self) -> dict:
}


def after_delete(mapper, connection, target: File):
def after_delete(mapper, connection, target: File): # noqa: ARG001
with contextlib.suppress(OSError):
Path(target.path).unlink()

Expand Down
4 changes: 2 additions & 2 deletions pste/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def quota(self, humanize: bool = False) -> int | str:
return quota


def after_delete(mapper, connection, target: User):
def after_delete(mapper, connection, target: User): # noqa: ARG001
shutil.rmtree(target.storage_directory, ignore_errors=True)


def after_insert(mapper, connection, target: User):
def after_insert(mapper, connection, target: User): # noqa: ARG001
Path(target.storage_directory).mkdir(parents=True, exist_ok=True)


Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ extend-exclude = [
[tool.ruff.lint]
select = [
"A",
"ARG",
"B",
"BLE",
"C4",
"C90",
"DTZ",
"E",
Expand All @@ -57,12 +59,16 @@ select = [
"N",
"PL",
"PTH",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"SLF",
"T10",
"T20",
"TID",
"UP",
"W",
"YTT",
Expand All @@ -75,7 +81,7 @@ ignore = [
]

[tool.ruff.lint.extend-per-file-ignores]
"pste/migrations/*" = ["ERA001"]
"pste/migrations/*" = ["ERA001", "ARG001"]

[tool.ruff.format]
line-ending = "lf"
Expand Down

0 comments on commit 942ca16

Please sign in to comment.