Skip to content

Commit b18b63d

Browse files
committed
ci: Handle new Ruff warnings
1 parent 1b376cd commit b18b63d

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed

duties.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55
import os
66
import re
77
import sys
8+
import warnings
89
from contextlib import contextmanager
910
from functools import partial, wraps
1011
from importlib.metadata import version as pkgversion
1112
from pathlib import Path
13+
from random import sample
14+
from tempfile import gettempdir
1215
from typing import TYPE_CHECKING, Any, Callable
1316

1417
from duty import duty, tools
18+
from pysource_codegen import generate
19+
from pysource_minimize import minimize
20+
21+
from griffe import visit
1522

1623
if TYPE_CHECKING:
1724
from collections.abc import Callable, Iterator
@@ -471,7 +478,7 @@ def coverage(ctx: Context) -> None:
471478

472479

473480
@duty
474-
def test(ctx: Context, *cli_args: str, match: str = "") -> None:
481+
def test(ctx: Context, *cli_args: str, match: str = "") -> None: # noqa: PT028
475482
"""Run the test suite.
476483
477484
```bash
@@ -523,15 +530,6 @@ def fuzz(
523530
min_seed: Minimum value for the seeds range.
524531
max_seed: Maximum value for the seeds range.
525532
"""
526-
import warnings
527-
from random import sample
528-
from tempfile import gettempdir
529-
530-
from pysource_codegen import generate
531-
from pysource_minimize import minimize
532-
533-
from griffe import visit
534-
535533
warnings.simplefilter("ignore", SyntaxWarning)
536534

537535
def fails(code: str, filepath: Path) -> bool:

scripts/gen_structure_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _render_call_graph(module: Path) -> None:
2222
buffer = StringIO()
2323
code2flow(str(module), buffer)
2424
try:
25-
svg = subprocess.check_output(["dot", "-Tsvg"], input=buffer.getvalue(), text=True) # noqa: S603, S607
25+
svg = subprocess.check_output(["dot", "-Tsvg"], input=buffer.getvalue(), text=True) # noqa: S607
2626
except subprocess.CalledProcessError:
2727
# The subprocess dies with SIGSEGV in GHA...
2828
return

src/_griffe/expressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _join(
5555

5656

5757
def _field_as_dict(
58-
element: str | bool | Expr | list[str | Expr] | None,
58+
element: str | bool | Expr | list[str | Expr] | None, # noqa: FBT001
5959
**kwargs: Any,
6060
) -> str | bool | None | list | dict:
6161
if isinstance(element, Expr):
@@ -594,7 +594,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]:
594594

595595
# YORE: EOL 3.9: Replace `**_dataclass_opts` with `slots=True` within line.
596596
@dataclass(eq=False, **_dataclass_opts)
597-
class ExprName(Expr):
597+
class ExprName(Expr): # noqa: PLW1641
598598
"""This class represents a Python object identified by a name in a given scope."""
599599

600600
name: str

src/_griffe/extensions/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def load_extensions(*exts: LoadableExtensionType) -> Extensions:
441441

442442
# TODO: Deprecate and remove at some point?
443443
# Always add our built-in dataclasses extension.
444-
from _griffe.extensions.dataclasses import DataclassesExtension
444+
from _griffe.extensions.dataclasses import DataclassesExtension # noqa: PLC0415
445445

446446
for ext in extensions._extensions:
447447
if type(ext) is DataclassesExtension:

src/_griffe/mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def as_json(self, *, full: bool = False, **kwargs: Any) -> str:
242242
Returns:
243243
A JSON string.
244244
"""
245-
from _griffe.encoders import JSONEncoder # Avoid circular import.
245+
from _griffe.encoders import JSONEncoder # Avoid circular import. # noqa: PLC0415
246246

247247
return json.dumps(self, cls=JSONEncoder, full=full, **kwargs)
248248

@@ -261,7 +261,7 @@ def from_json(cls: type[_ObjType], json_string: str, **kwargs: Any) -> _ObjType:
261261
TypeError: When the json_string does not represent and object
262262
of the class from which this classmethod has been called.
263263
"""
264-
from _griffe.encoders import json_decoder # Avoid circular import.
264+
from _griffe.encoders import json_decoder # Avoid circular import. # noqa: PLC0415
265265

266266
kwargs.setdefault("object_hook", json_decoder)
267267
obj = json.loads(json_string, **kwargs)

src/_griffe/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def as_dict(
196196
return base
197197

198198

199-
class Parameter:
199+
class Parameter: # noqa: PLW1641
200200
"""This class represent a function parameter.
201201
202202
See also: [`Parameters`][griffe.Parameters].

0 commit comments

Comments
 (0)