Skip to content

Commit

Permalink
chore: fix linter errors introduced with ruff upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
tumidi committed Oct 14, 2024
1 parent 977f26a commit 4e60ef7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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__"]
Expand Down
2 changes: 1 addition & 1 deletion questionpy/form/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion questionpy_sdk/commands/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions questionpy_sdk/package/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion questionpy_sdk/webserver/question_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions questionpy_sdk/webserver/question_ui/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
8 changes: 4 additions & 4 deletions tests/questionpy_sdk/commands/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down

0 comments on commit 4e60ef7

Please sign in to comment.