From 06c6010f3030198623d2a949c4a5cb5aaf8ad7dc Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:52:14 -0600 Subject: [PATCH] Update ruff config, change count to enumerate, and enable `flake8-trio` --- .pre-commit-config.yaml | 2 +- pyproject.toml | 7 +++++-- src/sanescansrv/htmlgen.py | 8 ++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9bf9238..fafb01d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/pyproject.toml b/pyproject.toml index b94e002..1a117df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -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 @@ -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 @@ -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 ] diff --git a/src/sanescansrv/htmlgen.py b/src/sanescansrv/htmlgen.py index 4f7896a..820d7e4 100644 --- a/src/sanescansrv/htmlgen.py +++ b/src/sanescansrv/htmlgen.py @@ -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", @@ -207,7 +206,6 @@ def radio_select_dict( lines.append(tag("input", **args)) lines.append(wrap_tag("label", display, False, **{"for": cid})) lines.append("
") - count += 1 return "\n".join(lines) @@ -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: @@ -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)