treefmt/ruff: Set python lint version to 3.13. Fix all new lints coming up.

This commit is contained in:
Qubasa
2025-06-30 15:28:15 +07:00
committed by Jörg Thalheim
parent 69b9187598
commit 0d1e1d9796
10 changed files with 21 additions and 27 deletions

View File

@@ -1,4 +1,3 @@
# ruff: noqa: N801
import gi import gi
gi.require_version("Gtk", "4.0") gi.require_version("Gtk", "4.0")

View File

@@ -5,9 +5,9 @@ import shutil
import subprocess as sp import subprocess as sp
import tempfile import tempfile
from collections import defaultdict from collections import defaultdict
from collections.abc import Callable, Iterator from collections.abc import Iterator
from pathlib import Path from pathlib import Path
from typing import Any, NamedTuple from typing import NamedTuple
import pytest import pytest
from clan_cli.tests import age_keys from clan_cli.tests import age_keys
@@ -38,7 +38,12 @@ def def_value() -> defaultdict:
return defaultdict(def_value) return defaultdict(def_value)
nested_dict: Callable[[], dict[str, Any]] = lambda: defaultdict(def_value) def nested_dict() -> defaultdict:
"""
Creates a defaultdict that allows for arbitrary levels of nesting.
For example: d['a']['b']['c'] = value
"""
return defaultdict(def_value)
# Substitutes strings in a file. # Substitutes strings in a file.

View File

@@ -1,11 +0,0 @@
from collections import defaultdict
from collections.abc import Callable
from typing import Any
def def_value() -> defaultdict:
return defaultdict(def_value)
# allows defining nested dictionary in a single line
nested_dict: Callable[[], dict[str, Any]] = lambda: defaultdict(def_value)

View File

@@ -4,14 +4,13 @@ import logging
from clan_cli.completions import add_dynamic_completer, complete_machines from clan_cli.completions import add_dynamic_completer, complete_machines
from clan_lib.errors import ClanError from clan_lib.errors import ClanError
from clan_lib.machines.machines import Machine from clan_lib.machines.machines import Machine
log = logging.getLogger(__name__)
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
if TYPE_CHECKING: if TYPE_CHECKING:
from .generate import Var from .generate import Var
log = logging.getLogger(__name__)
class VarStatus: class VarStatus:
def __init__( def __init__(

View File

@@ -16,14 +16,14 @@ from typing import (
) )
from clan_lib.api.util import JSchemaTypeError from clan_lib.api.util import JSchemaTypeError
from clan_lib.errors import ClanError
from .serde import dataclass_to_dict, from_dict, sanitize_string
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
from .serde import dataclass_to_dict, from_dict, sanitize_string
__all__ = ["dataclass_to_dict", "from_dict", "sanitize_string"] __all__ = ["dataclass_to_dict", "from_dict", "sanitize_string"]
from clan_lib.errors import ClanError
T = TypeVar("T") T = TypeVar("T")

View File

@@ -42,7 +42,10 @@ def delete_machine(machine: Machine) -> None:
# louis@(2025-02-04): clean-up legacy (pre-vars) secrets: # louis@(2025-02-04): clean-up legacy (pre-vars) secrets:
sops_folder = sops_secrets_folder(machine.flake.path) sops_folder = sops_secrets_folder(machine.flake.path)
filter_fn = lambda secret_name: secret_name.startswith(f"{machine.name}-")
def filter_fn(secret_name: str) -> bool:
return secret_name.startswith(f"{machine.name}-")
for secret_name in list_secrets(machine.flake.path, filter_fn): for secret_name in list_secrets(machine.flake.path, filter_fn):
secret_path = sops_folder / secret_name secret_path = sops_folder / secret_name
changed_paths.append(secret_path) changed_paths.append(secret_path)

View File

@@ -1,4 +1,3 @@
# ruff: noqa: SLF001
import ipaddress import ipaddress
import logging import logging
import os import os

View File

@@ -1,5 +1,6 @@
import argparse import argparse
import sys import sys
import re
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
@@ -118,9 +119,6 @@ def epilog_to_md(text: str) -> str:
return md return md
import re
def contains_https_link(line: str) -> bool: def contains_https_link(line: str) -> bool:
pattern = r"https://\S+" pattern = r"https://\S+"
return re.search(pattern, line) is not None return re.search(pattern, line) is not None

View File

@@ -49,9 +49,12 @@ filterwarnings = "default::ResourceWarning"
python_files = ["test_*.py", "*_test.py"] python_files = ["test_*.py", "*_test.py"]
[tool.mypy] [tool.mypy]
python_version = "3.12" python_version = "3.13"
warn_redundant_casts = true warn_redundant_casts = true
disallow_untyped_calls = true disallow_untyped_calls = true
disallow_untyped_defs = true disallow_untyped_defs = true
no_implicit_optional = true no_implicit_optional = true
exclude = "clan_lib.nixpkgs" exclude = "clan_lib.nixpkgs"
[tool.ruff]
target-version = "py313"

View File

@@ -1,4 +1,3 @@
# ruff: noqa: RUF001
import argparse import argparse
import json import json
import logging import logging