diff --git a/pyproject.toml b/pyproject.toml index edbcc646..7f0c85b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,6 +64,8 @@ extend-ignore-names = ["mcs", "test_*"] [tool.ruff.lint.extend-per-file-ignores] # Allow f-string without an `f` prefix for our custom error formatter. "**/questionpy_sdk/webserver/question_ui/errors.py" = ["RUF027"] +# unused-async (aiohttp handlers must be async even if they don't use it) +"**/questionpy_sdk/webserver/routes/*" = ["RUF029"] [tool.ruff.lint.pylint] allow-dunder-method-names = ["__get_pydantic_core_schema__"] diff --git a/questionpy/form/_model.py b/questionpy/form/_model.py index 7aef91ee..442a14e3 100644 --- a/questionpy/form/_model.py +++ b/questionpy/form/_model.py @@ -125,7 +125,7 @@ class _FormModelMeta(ModelMetaclass): __slots__ = () - def __new__(mcs, name: str, bases: tuple[type, ...], namespace: dict, **kwargs: Any) -> type: # noqa: N804 + def __new__(mcs, name: str, bases: tuple[type, ...], namespace: dict, **kwargs: Any) -> type: annotations = namespace.get("__annotations__", {}).copy() new_namespace = {} form = OptionsFormDefinition() diff --git a/questionpy_sdk/commands/package.py b/questionpy_sdk/commands/package.py index d6871125..147e3d56 100644 --- a/questionpy_sdk/commands/package.py +++ b/questionpy_sdk/commands/package.py @@ -109,7 +109,7 @@ def create_qpy_package( try: # Use temp file, otherwise we risk overwriting `out_path` in case of a build error. - temp_file = tempfile.NamedTemporaryFile(delete=False) + temp_file = tempfile.NamedTemporaryFile(delete=False) # noqa: SIM115 temp_file_path = Path(temp_file.name) try: diff --git a/questionpy_sdk/package/builder.py b/questionpy_sdk/package/builder.py index b866840e..d23e8a2b 100644 --- a/questionpy_sdk/package/builder.py +++ b/questionpy_sdk/package/builder.py @@ -116,10 +116,10 @@ def _write_manifest(self) -> None: def _run_hook(self, cmd: str, hook_name: BuildHookName, num: int) -> None: log.info("Running %s hook[%d]: '%s'", hook_name, num, cmd) - with subprocess.Popen( + with subprocess.Popen( # noqa: S602 cmd, cwd=self._source.path, - shell=True, # noqa: S602 + shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, diff --git a/questionpy_sdk/webserver/question_ui/__init__.py b/questionpy_sdk/webserver/question_ui/__init__.py index 3c958fc3..663cb024 100644 --- a/questionpy_sdk/webserver/question_ui/__init__.py +++ b/questionpy_sdk/webserver/question_ui/__init__.py @@ -437,7 +437,7 @@ def _shuffle_contents(self) -> None: child_elements = [child for child in element if isinstance(child, etree._Element)] self._random.shuffle(child_elements) - element.attrib.pop("{%s}shuffle-contents" % self.QPY_NAMESPACE) + element.attrib.pop(f"{{{self.QPY_NAMESPACE}}}shuffle-contents") # Reinsert shuffled elements, preserving non-element nodes for i, child in enumerate(child_elements): diff --git a/questionpy_sdk/webserver/question_ui/errors.py b/questionpy_sdk/webserver/question_ui/errors.py index 9f142eb1..6e0f2968 100644 --- a/questionpy_sdk/webserver/question_ui/errors.py +++ b/questionpy_sdk/webserver/question_ui/errors.py @@ -122,10 +122,9 @@ def __init__( template_kwargs["expected"] = expected expected_str = " Expected values are {expected}." - s = "" if isinstance(value, str) or len(value) <= 1 else "" super().__init__( element=element, - template=f"Invalid value{s} {{value}} for attribute {{attribute}} on element {{element}}.{expected_str}", + template=f"Invalid value {{value}} for attribute {{attribute}} on element {{element}}.{expected_str}", template_kwargs=template_kwargs, ) diff --git a/tests/questionpy_sdk/commands/conftest.py b/tests/questionpy_sdk/commands/conftest.py index cd46d20e..fd3e3bc4 100644 --- a/tests/questionpy_sdk/commands/conftest.py +++ b/tests/questionpy_sdk/commands/conftest.py @@ -53,13 +53,13 @@ def invoke(*args: Any, **kwargs: Any) -> Result: os.chdir(cwd_orig) -@pytest.fixture # noqa: FURB118 -def runner(isolated_runner: tuple[CliRunner, Path]) -> CliRunner: +@pytest.fixture +def runner(isolated_runner: tuple[CliRunner, Path]) -> CliRunner: # noqa: FURB118 return isolated_runner[0] -@pytest.fixture # noqa: FURB118 -def cwd(isolated_runner: tuple[CliRunner, Path]) -> Path: +@pytest.fixture +def cwd(isolated_runner: tuple[CliRunner, Path]) -> Path: # noqa: FURB118 return isolated_runner[1]