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

chore: resolve ruff config deprecations #69

Merged
merged 1 commit into from
Feb 4, 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
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