Skip to content

Commit

Permalink
Update ruff config, change count to enumerate, and enable flake8-trio
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Feb 5, 2024
1 parent 12468fe commit 06c6010
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.2.1
hooks:
- id: ruff
types: [file]
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true

[tool.pycln]
Expand All @@ -93,6 +93,8 @@ line-length = 120 # I don't care about line length a whole lot, just that it's
fix = true

include = ["*.py", "*.pyi", "**/pyproject.toml"]

[tool.ruff.lint]
select = [
"A", # flake8-builtins
"ASYNC", # flake8-async
Expand All @@ -116,6 +118,7 @@ select = [
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"TCH", # flake8-type-checking
"TRIO", # flake8-trio
"UP", # pyupgrade
"W", # Warning
"YTT", # flake8-2020
Expand All @@ -129,7 +132,7 @@ extend-ignore = [
"D213", # multi-line-summary-second-line
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"src/sanescansrv/htmlgen.py" = [
"D417", # Bugged "Missing argument descriptions" even though they are there
]
Expand Down
8 changes: 2 additions & 6 deletions src/sanescansrv/htmlgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ def radio_select_dict(
) -> str:
"""Create radio select from dictionary."""
lines = []
count = 0
for display, value in options.items():
for count, (display, value) in enumerate(options.items()):
cid = f"{submit_name}_{count}"
args = {
"type": "radio",
Expand All @@ -207,7 +206,6 @@ def radio_select_dict(
lines.append(tag("input", **args))
lines.append(wrap_tag("label", display, False, **{"for": cid}))
lines.append("<br>")
count += 1
return "\n".join(lines)


Expand Down Expand Up @@ -347,9 +345,8 @@ def jinja_if_block(conditions: dict[str, str], block: bool = True) -> str:
"" key means else block.
"""
contents = []
count = 0
has_else = False
for condition, content in conditions.items():
for count, (condition, content) in enumerate(conditions.items()):
statement = "if" if count == 0 else "elif"
cond = ""
if condition:
Expand All @@ -367,7 +364,6 @@ def jinja_if_block(conditions: dict[str, str], block: bool = True) -> str:
statement = "else"
contents.append(jinja_statement(f"{statement}{cond}"))
contents.append(content)
count += 1
contents.append(jinja_statement("endif"))
join = "\n" if block else ""
return join.join(contents)
Expand Down

0 comments on commit 06c6010

Please sign in to comment.