Skip to content

Commit 72c8fc8

Browse files
committed
chore: Use YORE comments (experiment)
1 parent 8c9f6e6 commit 72c8fc8

File tree

11 files changed

+65
-24
lines changed

11 files changed

+65
-24
lines changed

scripts/gen_credits.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from jinja2.sandbox import SandboxedEnvironment
1616
from packaging.requirements import Requirement
1717

18-
# TODO: Remove once support for Python 3.10 is dropped.
18+
# YORE: EOL 3.10: Replace block with line 2.
1919
if sys.version_info >= (3, 11):
2020
import tomllib
2121
else:

src/griffe/agents/nodes/_runtime.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
def _same_components(a: str, b: str, /) -> bool:
24-
# TODO: Use `removeprefix` when we drop Python 3.8.
24+
# YORE: EOL 3.8: Replace `lstrip` with `removeprefix` within line.
2525
return [cpn.lstrip("_") for cpn in a.split(".")] == [cpn.lstrip("_") for cpn in b.split(".")]
2626

2727

src/griffe/agents/nodes/_values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from griffe.logger import get_logger
1010

11-
# TODO: Remove once support for Python 3.8 is dropped.
11+
# YORE: EOL 3.8: Replace block with line 4.
1212
if sys.version_info < (3, 9):
1313
from astunparse import unparse
1414
else:

src/griffe/dataclasses.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def as_dict(
152152
Returns:
153153
A dictionary.
154154
"""
155-
# TODO: Remove at some point.
155+
# YORE: Bump 1.0.0: Remove block.
156156
if docstring_parser is not None:
157157
warnings.warn("Parameter `docstring_parser` is deprecated and has no effect.", stacklevel=1)
158158

@@ -527,6 +527,7 @@ def is_namespace_subpackage(self) -> bool:
527527
"""Whether this object is a namespace subpackage."""
528528
return False
529529

530+
# YORE: Bump 1.0.0: Replace ` | set[str]` with `` within line.
530531
def has_labels(self, *labels: str | set[str]) -> bool:
531532
"""Tell if this object has all the given labels.
532533
@@ -536,7 +537,7 @@ def has_labels(self, *labels: str | set[str]) -> bool:
536537
Returns:
537538
True or False.
538539
"""
539-
# TODO: Remove at some point.
540+
# YORE: Bump 1.0.0: Remove block.
540541
all_labels = set()
541542
for label in labels:
542543
if isinstance(label, str):
@@ -548,6 +549,8 @@ def has_labels(self, *labels: str | set[str]) -> bool:
548549
stacklevel=2,
549550
)
550551
all_labels.update(label)
552+
553+
# YORE: Bump 1.0.0: Replace `all_labels` with `set(labels)` within line.
551554
return all_labels.issubset(self.labels)
552555

553556
def filter_members(self, *predicates: Callable[[Object | Alias], bool]) -> dict[str, Object | Alias]:

src/griffe/encoders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(
8888
super().__init__(*args, **kwargs)
8989
self.full: bool = full
9090

91-
# TODO: Remove at some point.
91+
# YORE: Bump 1.0.0: Remove block.
9292
self.docstring_parser: Parser | None = docstring_parser
9393
self.docstring_options: dict[str, Any] = docstring_options or {}
9494
if docstring_parser is not None:

src/griffe/expressions.py

+33-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _expr_as_dict(expression: Expr, **kwargs: Any) -> dict[str, Any]:
7373
return fields
7474

7575

76-
# TODO: Merge in decorators once Python 3.9 is dropped.
76+
# YORE: EOL 3.9: Remove block.
7777
dataclass_opts: dict[str, bool] = {}
7878
if sys.version_info >= (3, 10):
7979
dataclass_opts["slots"] = True
@@ -171,6 +171,7 @@ def is_generator(self) -> bool:
171171
return isinstance(self, ExprSubscript) and self.canonical_name == "Generator"
172172

173173

174+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
174175
@dataclass(eq=True, **dataclass_opts)
175176
class ExprAttribute(Expr):
176177
"""Attributes like `a.b`."""
@@ -214,6 +215,7 @@ def canonical_path(self) -> str:
214215
return self.last.canonical_path
215216

216217

218+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
217219
@dataclass(eq=True, **dataclass_opts)
218220
class ExprBinOp(Expr):
219221
"""Binary operations like `a + b`."""
@@ -231,6 +233,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
231233
yield from _yield(self.right, flat=flat)
232234

233235

236+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
234237
@dataclass(eq=True, **dataclass_opts)
235238
class ExprBoolOp(Expr):
236239
"""Boolean operations like `a or b`."""
@@ -244,6 +247,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
244247
yield from _join(self.values, f" {self.operator} ", flat=flat)
245248

246249

250+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
247251
@dataclass(eq=True, **dataclass_opts)
248252
class ExprCall(Expr):
249253
"""Calls like `f()`."""
@@ -265,6 +269,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
265269
yield ")"
266270

267271

272+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
268273
@dataclass(eq=True, **dataclass_opts)
269274
class ExprCompare(Expr):
270275
"""Comparisons like `a > b`."""
@@ -282,6 +287,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
282287
yield from _join(zip_longest(self.operators, [], self.comparators, fillvalue=" "), " ", flat=flat)
283288

284289

290+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
285291
@dataclass(eq=True, **dataclass_opts)
286292
class ExprComprehension(Expr):
287293
"""Comprehensions like `a for b in c if d`."""
@@ -307,6 +313,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
307313
yield from _join(self.conditions, " if ", flat=flat)
308314

309315

316+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
310317
@dataclass(eq=True, **dataclass_opts)
311318
class ExprConstant(Expr):
312319
"""Constants like `"a"` or `1`."""
@@ -318,6 +325,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: ARG002
318325
yield self.value
319326

320327

328+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
321329
@dataclass(eq=True, **dataclass_opts)
322330
class ExprDict(Expr):
323331
"""Dictionaries like `{"a": 0}`."""
@@ -337,6 +345,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
337345
yield "}"
338346

339347

348+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
340349
@dataclass(eq=True, **dataclass_opts)
341350
class ExprDictComp(Expr):
342351
"""Dict comprehensions like `{k: v for k, v in a}`."""
@@ -357,6 +366,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
357366
yield "}"
358367

359368

369+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
360370
@dataclass(eq=True, **dataclass_opts)
361371
class ExprExtSlice(Expr):
362372
"""Extended slice like `a[x:y, z]`."""
@@ -368,6 +378,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
368378
yield from _join(self.dims, ", ", flat=flat)
369379

370380

381+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
371382
@dataclass(eq=True, **dataclass_opts)
372383
class ExprFormatted(Expr):
373384
"""Formatted string like `{1 + 1}`."""
@@ -381,6 +392,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
381392
yield "}"
382393

383394

395+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
384396
@dataclass(eq=True, **dataclass_opts)
385397
class ExprGeneratorExp(Expr):
386398
"""Generator expressions like `a for b in c for d in e`."""
@@ -396,6 +408,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
396408
yield from _join(self.generators, " ", flat=flat)
397409

398410

411+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
399412
@dataclass(eq=True, **dataclass_opts)
400413
class ExprIfExp(Expr):
401414
"""Conditions like `a if b else c`."""
@@ -415,6 +428,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
415428
yield from _yield(self.orelse, flat=flat)
416429

417430

431+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
418432
@dataclass(eq=True, **dataclass_opts)
419433
class ExprJoinedStr(Expr):
420434
"""Joined strings like `f"a {b} c"`."""
@@ -428,6 +442,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
428442
yield "'"
429443

430444

445+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
431446
@dataclass(eq=True, **dataclass_opts)
432447
class ExprKeyword(Expr):
433448
"""Keyword arguments like `a=b`."""
@@ -468,6 +483,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
468483
yield from _yield(self.value, flat=flat)
469484

470485

486+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
471487
@dataclass(eq=True, **dataclass_opts)
472488
class ExprVarPositional(Expr):
473489
"""Variadic positional parameters like `*args`."""
@@ -480,6 +496,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
480496
yield from _yield(self.value, flat=flat)
481497

482498

499+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
483500
@dataclass(eq=True, **dataclass_opts)
484501
class ExprVarKeyword(Expr):
485502
"""Variadic keyword parameters like `**kwargs`."""
@@ -492,6 +509,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
492509
yield from _yield(self.value, flat=flat)
493510

494511

512+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
495513
@dataclass(eq=True, **dataclass_opts)
496514
class ExprLambda(Expr):
497515
"""Lambda expressions like `lambda a: a.b`."""
@@ -534,6 +552,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
534552
yield from _yield(self.body, flat=flat)
535553

536554

555+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
537556
@dataclass(eq=True, **dataclass_opts)
538557
class ExprList(Expr):
539558
"""Lists like `[0, 1, 2]`."""
@@ -547,6 +566,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
547566
yield "]"
548567

549568

569+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
550570
@dataclass(eq=True, **dataclass_opts)
551571
class ExprListComp(Expr):
552572
"""List comprehensions like `[a for b in c]`."""
@@ -564,6 +584,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
564584
yield "]"
565585

566586

587+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
567588
@dataclass(eq=False, **dataclass_opts)
568589
class ExprName(Expr):
569590
"""This class represents a Python object identified by a name in a given scope."""
@@ -643,6 +664,7 @@ def is_enum_value(self) -> bool:
643664
return False
644665

645666

667+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
646668
@dataclass(eq=True, **dataclass_opts)
647669
class ExprNamedExpr(Expr):
648670
"""Named/assignment expressions like `a := b`."""
@@ -660,6 +682,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
660682
yield ")"
661683

662684

685+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
663686
@dataclass(eq=True, **dataclass_opts)
664687
class ExprParameter(Expr):
665688
"""Parameters in function signatures like `a: int = 0`."""
@@ -674,6 +697,7 @@ class ExprParameter(Expr):
674697
"""Parameter default."""
675698

676699

700+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
677701
@dataclass(eq=True, **dataclass_opts)
678702
class ExprSet(Expr):
679703
"""Sets like `{0, 1, 2}`."""
@@ -687,6 +711,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
687711
yield "}"
688712

689713

714+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
690715
@dataclass(eq=True, **dataclass_opts)
691716
class ExprSetComp(Expr):
692717
"""Set comprehensions like `{a for b in c}`."""
@@ -704,6 +729,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
704729
yield "}"
705730

706731

732+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
707733
@dataclass(eq=True, **dataclass_opts)
708734
class ExprSlice(Expr):
709735
"""Slices like `[a:b:c]`."""
@@ -726,6 +752,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
726752
yield from _yield(self.step, flat=flat)
727753

728754

755+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
729756
@dataclass(eq=True, **dataclass_opts)
730757
class ExprSubscript(Expr):
731758
"""Subscripts like `a[b]`."""
@@ -756,6 +783,7 @@ def canonical_path(self) -> str:
756783
return self.left.canonical_path
757784

758785

786+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
759787
@dataclass(eq=True, **dataclass_opts)
760788
class ExprTuple(Expr):
761789
"""Tuples like `(0, 1, 2)`."""
@@ -773,6 +801,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
773801
yield ")"
774802

775803

804+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
776805
@dataclass(eq=True, **dataclass_opts)
777806
class ExprUnaryOp(Expr):
778807
"""Unary operations like `-1`."""
@@ -787,6 +816,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
787816
yield from _yield(self.value, flat=flat)
788817

789818

819+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
790820
@dataclass(eq=True, **dataclass_opts)
791821
class ExprYield(Expr):
792822
"""Yield statements like `yield a`."""
@@ -801,6 +831,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
801831
yield from _yield(self.value, flat=flat)
802832

803833

834+
# YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
804835
@dataclass(eq=True, **dataclass_opts)
805836
class ExprYieldFrom(Expr):
806837
"""Yield statements like `yield from a`."""
@@ -1135,7 +1166,7 @@ def _build_yield_from(node: ast.YieldFrom, parent: Module | Class, **kwargs: Any
11351166
ast.YieldFrom: _build_yield_from,
11361167
}
11371168

1138-
# TODO: remove once Python 3.8 support is dropped
1169+
# YORE: EOL 3.8: Remove block.
11391170
if sys.version_info < (3, 9):
11401171

11411172
def _build_extslice(node: ast.ExtSlice, parent: Module | Class, **kwargs: Any) -> Expr:

src/griffe/extensions/base.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -461,20 +461,20 @@ def _load_extension(
461461

462462

463463
def load_extensions(
464-
# TODO: Only accept LoadableExtension at some point.
464+
# YORE: Bump 1.0.0: Replace ` | Sequence[LoadableExtension],` with `` within line.
465465
*exts: LoadableExtension | Sequence[LoadableExtension],
466466
) -> Extensions:
467467
"""Load configured extensions.
468468
469469
Parameters:
470-
exts: A sequence of extension, with potential configuration options.
470+
exts: Extensions with potential configuration options.
471471
472472
Returns:
473473
An extensions container.
474474
"""
475475
extensions = Extensions()
476476

477-
# TODO: Remove at some point.
477+
# YORE: Bump 1.0.0: Remove block.
478478
all_exts: list[LoadableExtension] = []
479479
for ext in exts:
480480
if isinstance(ext, (list, tuple)):
@@ -488,6 +488,7 @@ def load_extensions(
488488
else:
489489
all_exts.append(ext) # type: ignore[arg-type]
490490

491+
# YORE: Bump 1.0.0: Replace `all_exts` with `exts` within line.
491492
for extension in all_exts:
492493
ext = _load_extension(extension)
493494
if isinstance(ext, list):

src/griffe/git.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
WORKTREE_PREFIX = "griffe-worktree-"
1717

1818

19-
# TODO: Remove at some point.
19+
# YORE: Bump 1.0.0: Remove block.
2020
def __getattr__(name: str) -> Any:
2121
if name == "load_git":
2222
warnings.warn(

0 commit comments

Comments
 (0)