Skip to content

Commit 4e60ef7

Browse files
committed
chore: fix linter errors introduced with ruff upgrade
1 parent 977f26a commit 4e60ef7

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ extend-ignore-names = ["mcs", "test_*"]
6464
[tool.ruff.lint.extend-per-file-ignores]
6565
# Allow f-string without an `f` prefix for our custom error formatter.
6666
"**/questionpy_sdk/webserver/question_ui/errors.py" = ["RUF027"]
67+
# unused-async (aiohttp handlers must be async even if they don't use it)
68+
"**/questionpy_sdk/webserver/routes/*" = ["RUF029"]
6769

6870
[tool.ruff.lint.pylint]
6971
allow-dunder-method-names = ["__get_pydantic_core_schema__"]

questionpy/form/_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class _FormModelMeta(ModelMetaclass):
125125

126126
__slots__ = ()
127127

128-
def __new__(mcs, name: str, bases: tuple[type, ...], namespace: dict, **kwargs: Any) -> type: # noqa: N804
128+
def __new__(mcs, name: str, bases: tuple[type, ...], namespace: dict, **kwargs: Any) -> type:
129129
annotations = namespace.get("__annotations__", {}).copy()
130130
new_namespace = {}
131131
form = OptionsFormDefinition()

questionpy_sdk/commands/package.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def create_qpy_package(
109109

110110
try:
111111
# Use temp file, otherwise we risk overwriting `out_path` in case of a build error.
112-
temp_file = tempfile.NamedTemporaryFile(delete=False)
112+
temp_file = tempfile.NamedTemporaryFile(delete=False) # noqa: SIM115
113113
temp_file_path = Path(temp_file.name)
114114

115115
try:

questionpy_sdk/package/builder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ def _write_manifest(self) -> None:
116116

117117
def _run_hook(self, cmd: str, hook_name: BuildHookName, num: int) -> None:
118118
log.info("Running %s hook[%d]: '%s'", hook_name, num, cmd)
119-
with subprocess.Popen(
119+
with subprocess.Popen( # noqa: S602
120120
cmd,
121121
cwd=self._source.path,
122-
shell=True, # noqa: S602
122+
shell=True,
123123
stdout=subprocess.PIPE,
124124
stderr=subprocess.STDOUT,
125125
text=True,

questionpy_sdk/webserver/question_ui/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def _shuffle_contents(self) -> None:
437437
child_elements = [child for child in element if isinstance(child, etree._Element)]
438438
self._random.shuffle(child_elements)
439439

440-
element.attrib.pop("{%s}shuffle-contents" % self.QPY_NAMESPACE)
440+
element.attrib.pop(f"{{{self.QPY_NAMESPACE}}}shuffle-contents")
441441

442442
# Reinsert shuffled elements, preserving non-element nodes
443443
for i, child in enumerate(child_elements):

questionpy_sdk/webserver/question_ui/errors.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ def __init__(
122122
template_kwargs["expected"] = expected
123123
expected_str = " Expected values are {expected}."
124124

125-
s = "" if isinstance(value, str) or len(value) <= 1 else ""
126125
super().__init__(
127126
element=element,
128-
template=f"Invalid value{s} {{value}} for attribute {{attribute}} on element {{element}}.{expected_str}",
127+
template=f"Invalid value {{value}} for attribute {{attribute}} on element {{element}}.{expected_str}",
129128
template_kwargs=template_kwargs,
130129
)
131130

tests/questionpy_sdk/commands/conftest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ def invoke(*args: Any, **kwargs: Any) -> Result:
5353
os.chdir(cwd_orig)
5454

5555

56-
@pytest.fixture # noqa: FURB118
57-
def runner(isolated_runner: tuple[CliRunner, Path]) -> CliRunner:
56+
@pytest.fixture
57+
def runner(isolated_runner: tuple[CliRunner, Path]) -> CliRunner: # noqa: FURB118
5858
return isolated_runner[0]
5959

6060

61-
@pytest.fixture # noqa: FURB118
62-
def cwd(isolated_runner: tuple[CliRunner, Path]) -> Path:
61+
@pytest.fixture
62+
def cwd(isolated_runner: tuple[CliRunner, Path]) -> Path: # noqa: FURB118
6363
return isolated_runner[1]
6464

6565

0 commit comments

Comments
 (0)