Skip to content

Commit dcb075e

Browse files
johnslavikpawamoy
andauthored
refactor: Remove deprecated code
PR-433: #433 Co-authored-by: Timothée Mazzucotelli <dev@pawamoy.fr>
1 parent b977f17 commit dcb075e

File tree

17 files changed

+10
-292
lines changed

17 files changed

+10
-292
lines changed

docs/guide/contributors/workflow.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ Deprecated code should also be marked as legacy code. We use [Yore](https://pawa
5757
Examples:
5858

5959
```python title="Remove function when we bump to 2.0"
60-
# YORE: Bump 2: Remove block.
61-
def deprecated_function():
62-
...
63-
```
6460

6561
```python title="Simplify imports when Python 3.15 is EOL"
6662
# YORE: EOL 3.15: Replace block with line 4.

docs/reference/api/agents.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,4 @@ Griffe is able to analyze code both statically and dynamically.
7070

7171
::: griffe.safe_get_value
7272

73-
<!-- YORE: Bump 2: Remove line. -->
74-
## **Deprecated API**
7573

76-
<!-- YORE: Bump 2: Remove line. -->
77-
::: griffe.ExportedName

docs/reference/api/git.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

duties.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ def check_api(ctx: Context, *cli_args: str) -> None:
291291
color=True,
292292
extensions=[
293293
"griffe_inherited_docstrings",
294-
# YORE: Bump 2: Remove line.
295-
"scripts/griffe_exts.py",
296294
"unpack_typeddict",
297295
],
298296
).add_args(*cli_args),

mkdocs.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ nav:
110110
- Parsers: reference/api/docstrings/parsers.md
111111
- Exceptions: reference/api/exceptions.md
112112
- Expressions: reference/api/expressions.md
113-
# YORE: Bump 2: Remove line.
114-
- Git utilities: reference/api/git.md
115113
- Loggers: reference/api/loggers.md
116114
- Helpers: reference/api/helpers.md
117115
- Changelog: changelog.md
@@ -231,8 +229,6 @@ plugins:
231229
docstring_section_style: list
232230
extensions:
233231
- griffe_inherited_docstrings
234-
# YORE: Bump 2: Remove line.
235-
- scripts/griffe_exts.py
236232
- unpack_typeddict
237233
heading_level: 2
238234
inherited_members: true

scripts/griffe_exts.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/griffe/__init__.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@
164164

165165
from __future__ import annotations
166166

167-
import warnings
168-
from typing import Any
169-
170167
from griffe._internal.agents.inspector import Inspector, inspect
171168
from griffe._internal.agents.nodes.assignments import get_instance_names, get_name, get_names
172169
from griffe._internal.agents.nodes.ast import (
@@ -181,9 +178,7 @@
181178
ast_siblings,
182179
)
183180
from griffe._internal.agents.nodes.docstrings import get_docstring
184-
185-
# YORE: Bump 2: Replace `ExportedName, ` with `` within line.
186-
from griffe._internal.agents.nodes.exports import ExportedName, get__all__, safe_get__all__
181+
from griffe._internal.agents.nodes.exports import get__all__, safe_get__all__
187182
from griffe._internal.agents.nodes.imports import relative_to_absolute
188183
from griffe._internal.agents.nodes.parameters import ParametersType, get_parameters
189184
from griffe._internal.agents.nodes.runtime import ObjectNode
@@ -383,33 +378,9 @@
383378
vtree,
384379
)
385380

386-
# YORE: Bump 2: Remove block.
387-
_deprecated_names = (
388-
"assert_git_repo",
389-
"get_latest_tag",
390-
"get_repo_root",
391-
"tmp_worktree",
392-
)
393-
394-
395-
# YORE: Bump 2: Remove block.
396-
def __getattr__(name: str) -> Any:
397-
if name in _deprecated_names:
398-
from griffe._internal import git # noqa: PLC0415
399-
400-
warnings.warn(
401-
f"The `{name}` function is deprecated and will become unavailable in the next major version.",
402-
DeprecationWarning,
403-
stacklevel=2,
404-
)
405-
return getattr(git, f"_{name}")
406-
407-
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
408-
409-
410381
# Regenerate this list with the following Python snippet:
411382
# import griffe
412-
# names = sorted(n for n in dir(griffe) if not n.startswith("_") and n not in ("Any", "annotations", "lazy_importing", "warnings"))
383+
# names = sorted(n for n in dir(griffe) if not n.startswith("_") and n not in ("annotations",))
413384
# print('__all__ = [\n "' + '",\n "'.join(names) + '",\n]')
414385
__all__ = [
415386
"DEFAULT_LOG_LEVEL",
@@ -468,8 +439,6 @@ def __getattr__(name: str) -> Any:
468439
"DocstringWarn",
469440
"DocstringYield",
470441
"ExplanationStyle",
471-
# YORE: Bump 2: Remove line.
472-
"ExportedName",
473442
"Expr",
474443
"ExprAttribute",
475444
"ExprBinOp",
@@ -565,7 +534,6 @@ def __getattr__(name: str) -> Any:
565534
"UnimportableModuleError",
566535
"UnpackTypedDictExtension",
567536
"Visitor",
568-
"assert_git_repo",
569537
"ast_children",
570538
"ast_first_child",
571539
"ast_kind",
@@ -591,13 +559,11 @@ def __getattr__(name: str) -> Any:
591559
"get_docstring",
592560
"get_expression",
593561
"get_instance_names",
594-
"get_latest_tag",
595562
"get_logger",
596563
"get_name",
597564
"get_names",
598565
"get_parameters",
599566
"get_parser",
600-
"get_repo_root",
601567
"get_value",
602568
"htree",
603569
"infer_docstring_style",
@@ -635,7 +601,6 @@ def __getattr__(name: str) -> Any:
635601
"temporary_pypackage",
636602
"temporary_visited_module",
637603
"temporary_visited_package",
638-
"tmp_worktree",
639604
"typing_overload",
640605
"visit",
641606
"vtree",

src/griffe/_internal/agents/nodes/exports.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import ast
66
from contextlib import suppress
7-
from dataclasses import dataclass
87
from typing import TYPE_CHECKING, Any, Callable
98

109
from griffe._internal.agents.nodes.values import get_value
@@ -16,20 +15,6 @@
1615
from griffe._internal.models import Module
1716

1817

19-
# YORE: Bump 2: Remove block.
20-
@dataclass
21-
class ExportedName:
22-
"""Deprecated. An intermediate class to store names.
23-
24-
The [`get__all__`][griffe.get__all__] function now returns instances of [`ExprName`][griffe.ExprName] instead.
25-
"""
26-
27-
name: str
28-
"""The exported name."""
29-
parent: Module
30-
"""The parent module."""
31-
32-
3318
def _extract_attribute(node: ast.Attribute, parent: Module) -> list[str | ExprName]:
3419
return [ExprName(name=node.attr, parent=_extract(node.value, parent)[0])]
3520

src/griffe/_internal/docstrings/auto.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from __future__ import annotations
44

55
import re
6-
from typing import TYPE_CHECKING, Any, Literal, TypedDict
7-
from warnings import warn
6+
from typing import TYPE_CHECKING, Literal, TypedDict
87

98
from griffe._internal.enumerations import Parser
109

@@ -121,8 +120,6 @@ def infer_docstring_style(
121120
style_order: list[Parser] | list[DocstringStyle] | None = None,
122121
default: Parser | DocstringStyle | None = None,
123122
per_style_options: PerStyleOptions | None = None,
124-
# YORE: Bump 2: Remove line.
125-
**options: Any,
126123
) -> tuple[Parser | None, list[DocstringSection] | None]:
127124
"""Infer the parser to use for the docstring.
128125
@@ -142,21 +139,13 @@ def infer_docstring_style(
142139
style_order: The order of the styles to try when inferring the parser.
143140
default: The default parser to use if the inference fails.
144141
per_style_options: Additional parsing options per style.
145-
**options: Deprecated. Use `per_style_options` instead.
146142
147143
Returns:
148144
The inferred parser, and optionally parsed sections (when method is 'max_sections').
149145
"""
150146
from griffe._internal.docstrings.parsers import parsers # noqa: PLC0415
151147

152-
# YORE: Bump 2: Replace block with `per_style_options = per_style_options or {}`.
153-
if options:
154-
if per_style_options:
155-
raise ValueError("Cannot use both `options` and `per_style_options`.")
156-
warn("`**options` is deprecated. Use `per_style_options` instead.", DeprecationWarning, stacklevel=2)
157-
per_style_options = {"google": options, "numpy": options, "sphinx": options} # type: ignore[assignment]
158-
elif not per_style_options:
159-
per_style_options = {}
148+
per_style_options = per_style_options or {}
160149

161150
style_order = [Parser(style) if isinstance(style, str) else style for style in style_order or _default_style_order]
162151

@@ -203,8 +192,6 @@ def parse_auto(
203192
style_order: list[Parser] | list[DocstringStyle] | None = None,
204193
default: Parser | DocstringStyle | None = None,
205194
per_style_options: PerStyleOptions | None = None,
206-
# YORE: Bump 2: Remove line.
207-
**options: Any,
208195
) -> list[DocstringSection]:
209196
"""Parse a docstring by automatically detecting the style it uses.
210197
@@ -217,21 +204,13 @@ def parse_auto(
217204
style_order: The order of the styles to try when inferring the parser.
218205
default: The default parser to use if the inference fails.
219206
per_style_options: Additional parsing options per style.
220-
**options: Deprecated. Use `per_style_options` instead.
221207
222208
Returns:
223209
A list of docstring sections.
224210
"""
225211
from griffe._internal.docstrings.parsers import parse # noqa: PLC0415
226212

227-
# YORE: Bump 2: Replace block with `per_style_options = per_style_options or {}`.
228-
if options:
229-
if per_style_options:
230-
raise ValueError("Cannot use both `options` and `per_style_options`.")
231-
warn("`**options` are deprecated. Use `per_style_options` instead.", DeprecationWarning, stacklevel=2)
232-
per_style_options = {"google": options, "numpy": options, "sphinx": options} # type: ignore[assignment]
233-
elif not per_style_options:
234-
per_style_options = {}
213+
per_style_options = per_style_options or {}
235214

236215
style, sections = infer_docstring_style(
237216
docstring,

src/griffe/_internal/docstrings/google.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66
from contextlib import suppress
77
from typing import TYPE_CHECKING, TypedDict
8-
from warnings import warn
98

109
from griffe._internal.docstrings.models import (
1110
DocstringAttribute,
@@ -892,8 +891,6 @@ def parse_google(
892891
warn_unknown_params: bool = True,
893892
warn_missing_types: bool = True,
894893
warnings: bool = True,
895-
# YORE: Bump 2: Remove line.
896-
**options: Any,
897894
) -> list[DocstringSection]:
898895
"""Parse a Google-style docstring.
899896
@@ -921,7 +918,6 @@ def parse_google(
921918
warn_unknown_params: Warn about documented parameters not appearing in the signature.
922919
warn_missing_types: Warn about missing types/annotations for parameters, return values, etc.
923920
warnings: Whether to log warnings at all.
924-
**options: Swallowing keyword arguments for backward-compatibility.
925921
926922
Returns:
927923
A list of docstring sections.
@@ -932,10 +928,6 @@ def parse_google(
932928
in_code_block = False
933929
lines = docstring.lines
934930

935-
# YORE: Bump 2: Remove block.
936-
if options:
937-
warn("Passing additional options is deprecated, these options are ignored.", DeprecationWarning, stacklevel=2)
938-
939931
options = {
940932
"ignore_init_summary": ignore_init_summary,
941933
"trim_doctest_flags": trim_doctest_flags,

0 commit comments

Comments
 (0)