Skip to content

Commit

Permalink
chore: resolve ruff config deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
boidolr committed Feb 4, 2024
1 parent 33e67a6 commit e68df9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions pre_commit_images/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ def _optimize_images(images: Iterable[str], optimizer_fn: Callable[[Path, IO[byt
def bytes_to_readable(file_size: int) -> str:
if file_size / (1024 * 1024) > 1:
return f"{file_size / (1024 * 1024):.2f}Mb"
elif file_size / (1024) > 1:

if file_size / (1024) > 1:
return f"{(file_size/1024):.2f}Kb"
else:
return f"{file_size}b"

return f"{file_size}b"

def optimize_single_image(source: Path, temp: IO[bytes]) -> None:
optimizer_fn(source, temp)
Expand Down
14 changes: 11 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ packages = ["pre_commit_images"]
[tool.ruff]
line-length = 120
fix = true

[tool.ruff.lint]
select = [
# Pyflakes
"F",
Expand All @@ -68,6 +70,8 @@ select = [
"W",
# pyupgrade
"UP",
# refurb
"FURB",
# flake8-bandit
"S",
# flake8-comprehensions
Expand All @@ -80,6 +84,10 @@ select = [
"SIM",
# flake8-pytest-style
"PT",
# flake8-return
"RET",
# flake8-use-pathlib
"PTH",
# flake8-tidy-imports (relative-imports)
"TID252",
# Perflint
Expand All @@ -92,13 +100,13 @@ select = [
"RUF100"
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*.py" = ["S101"]

[tool.ruff.flake8-annotations]
[tool.ruff.lint.flake8-annotations]
ignore-fully-untyped = true

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-single-line = true
order-by-type = false

Expand Down

0 comments on commit e68df9b

Please sign in to comment.