Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/guide/contributors/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ Deprecated code should also be marked as legacy code. We use [Yore](https://pawa
Examples:

```python title="Remove function when we bump to 2.0"
# YORE: Bump 2: Remove block.
def deprecated_function():
...
```

```python title="Simplify imports when Python 3.15 is EOL"
# YORE: EOL 3.15: Replace block with line 4.
Expand Down
4 changes: 0 additions & 4 deletions docs/reference/api/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,4 @@ Griffe is able to analyze code both statically and dynamically.

::: griffe.safe_get_value

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

<!-- YORE: Bump 2: Remove line. -->
::: griffe.ExportedName
13 changes: 0 additions & 13 deletions docs/reference/api/git.md

This file was deleted.

2 changes: 0 additions & 2 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ def check_api(ctx: Context, *cli_args: str) -> None:
color=True,
extensions=[
"griffe_inherited_docstrings",
# YORE: Bump 2: Remove line.
"scripts/griffe_exts.py",
"unpack_typeddict",
],
).add_args(*cli_args),
Expand Down
4 changes: 0 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ nav:
- Parsers: reference/api/docstrings/parsers.md
- Exceptions: reference/api/exceptions.md
- Expressions: reference/api/expressions.md
# YORE: Bump 2: Remove line.
- Git utilities: reference/api/git.md
- Loggers: reference/api/loggers.md
- Helpers: reference/api/helpers.md
- Changelog: changelog.md
Expand Down Expand Up @@ -231,8 +229,6 @@ plugins:
docstring_section_style: list
extensions:
- griffe_inherited_docstrings
# YORE: Bump 2: Remove line.
- scripts/griffe_exts.py
- unpack_typeddict
heading_level: 2
inherited_members: true
Expand Down
24 changes: 0 additions & 24 deletions scripts/griffe_exts.py

This file was deleted.

39 changes: 2 additions & 37 deletions src/griffe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@

from __future__ import annotations

import warnings
from typing import Any

from griffe._internal.agents.inspector import Inspector, inspect
from griffe._internal.agents.nodes.assignments import get_instance_names, get_name, get_names
from griffe._internal.agents.nodes.ast import (
Expand All @@ -181,9 +178,7 @@
ast_siblings,
)
from griffe._internal.agents.nodes.docstrings import get_docstring

# YORE: Bump 2: Replace `ExportedName, ` with `` within line.
from griffe._internal.agents.nodes.exports import ExportedName, get__all__, safe_get__all__
from griffe._internal.agents.nodes.exports import get__all__, safe_get__all__
from griffe._internal.agents.nodes.imports import relative_to_absolute
from griffe._internal.agents.nodes.parameters import ParametersType, get_parameters
from griffe._internal.agents.nodes.runtime import ObjectNode
Expand Down Expand Up @@ -383,33 +378,9 @@
vtree,
)

# YORE: Bump 2: Remove block.
_deprecated_names = (
"assert_git_repo",
"get_latest_tag",
"get_repo_root",
"tmp_worktree",
)


# YORE: Bump 2: Remove block.
def __getattr__(name: str) -> Any:
if name in _deprecated_names:
from griffe._internal import git # noqa: PLC0415

warnings.warn(
f"The `{name}` function is deprecated and will become unavailable in the next major version.",
DeprecationWarning,
stacklevel=2,
)
return getattr(git, f"_{name}")

raise AttributeError(f"module '{__name__}' has no attribute '{name}'")


# Regenerate this list with the following Python snippet:
# import griffe
# names = sorted(n for n in dir(griffe) if not n.startswith("_") and n not in ("Any", "annotations", "lazy_importing", "warnings"))
# names = sorted(n for n in dir(griffe) if not n.startswith("_") and n not in ("annotations",))
# print('__all__ = [\n "' + '",\n "'.join(names) + '",\n]')
__all__ = [
"DEFAULT_LOG_LEVEL",
Expand Down Expand Up @@ -468,8 +439,6 @@ def __getattr__(name: str) -> Any:
"DocstringWarn",
"DocstringYield",
"ExplanationStyle",
# YORE: Bump 2: Remove line.
"ExportedName",
"Expr",
"ExprAttribute",
"ExprBinOp",
Expand Down Expand Up @@ -565,7 +534,6 @@ def __getattr__(name: str) -> Any:
"UnimportableModuleError",
"UnpackTypedDictExtension",
"Visitor",
"assert_git_repo",
"ast_children",
"ast_first_child",
"ast_kind",
Expand All @@ -591,13 +559,11 @@ def __getattr__(name: str) -> Any:
"get_docstring",
"get_expression",
"get_instance_names",
"get_latest_tag",
"get_logger",
"get_name",
"get_names",
"get_parameters",
"get_parser",
"get_repo_root",
"get_value",
"htree",
"infer_docstring_style",
Expand Down Expand Up @@ -635,7 +601,6 @@ def __getattr__(name: str) -> Any:
"temporary_pypackage",
"temporary_visited_module",
"temporary_visited_package",
"tmp_worktree",
"typing_overload",
"visit",
"vtree",
Expand Down
15 changes: 0 additions & 15 deletions src/griffe/_internal/agents/nodes/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import ast
from contextlib import suppress
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Callable

from griffe._internal.agents.nodes.values import get_value
Expand All @@ -16,20 +15,6 @@
from griffe._internal.models import Module


# YORE: Bump 2: Remove block.
@dataclass
class ExportedName:
"""Deprecated. An intermediate class to store names.

The [`get__all__`][griffe.get__all__] function now returns instances of [`ExprName`][griffe.ExprName] instead.
"""

name: str
"""The exported name."""
parent: Module
"""The parent module."""


def _extract_attribute(node: ast.Attribute, parent: Module) -> list[str | ExprName]:
return [ExprName(name=node.attr, parent=_extract(node.value, parent)[0])]

Expand Down
27 changes: 3 additions & 24 deletions src/griffe/_internal/docstrings/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from __future__ import annotations

import re
from typing import TYPE_CHECKING, Any, Literal, TypedDict
from warnings import warn
from typing import TYPE_CHECKING, Literal, TypedDict

from griffe._internal.enumerations import Parser

Expand Down Expand Up @@ -121,8 +120,6 @@ def infer_docstring_style(
style_order: list[Parser] | list[DocstringStyle] | None = None,
default: Parser | DocstringStyle | None = None,
per_style_options: PerStyleOptions | None = None,
# YORE: Bump 2: Remove line.
**options: Any,
) -> tuple[Parser | None, list[DocstringSection] | None]:
"""Infer the parser to use for the docstring.

Expand All @@ -142,21 +139,13 @@ def infer_docstring_style(
style_order: The order of the styles to try when inferring the parser.
default: The default parser to use if the inference fails.
per_style_options: Additional parsing options per style.
**options: Deprecated. Use `per_style_options` instead.

Returns:
The inferred parser, and optionally parsed sections (when method is 'max_sections').
"""
from griffe._internal.docstrings.parsers import parsers # noqa: PLC0415

# YORE: Bump 2: Replace block with `per_style_options = per_style_options or {}`.
if options:
if per_style_options:
raise ValueError("Cannot use both `options` and `per_style_options`.")
warn("`**options` is deprecated. Use `per_style_options` instead.", DeprecationWarning, stacklevel=2)
per_style_options = {"google": options, "numpy": options, "sphinx": options} # type: ignore[assignment]
elif not per_style_options:
per_style_options = {}
per_style_options = per_style_options or {}

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

Expand Down Expand Up @@ -203,8 +192,6 @@ def parse_auto(
style_order: list[Parser] | list[DocstringStyle] | None = None,
default: Parser | DocstringStyle | None = None,
per_style_options: PerStyleOptions | None = None,
# YORE: Bump 2: Remove line.
**options: Any,
) -> list[DocstringSection]:
"""Parse a docstring by automatically detecting the style it uses.

Expand All @@ -217,21 +204,13 @@ def parse_auto(
style_order: The order of the styles to try when inferring the parser.
default: The default parser to use if the inference fails.
per_style_options: Additional parsing options per style.
**options: Deprecated. Use `per_style_options` instead.

Returns:
A list of docstring sections.
"""
from griffe._internal.docstrings.parsers import parse # noqa: PLC0415

# YORE: Bump 2: Replace block with `per_style_options = per_style_options or {}`.
if options:
if per_style_options:
raise ValueError("Cannot use both `options` and `per_style_options`.")
warn("`**options` are deprecated. Use `per_style_options` instead.", DeprecationWarning, stacklevel=2)
per_style_options = {"google": options, "numpy": options, "sphinx": options} # type: ignore[assignment]
elif not per_style_options:
per_style_options = {}
per_style_options = per_style_options or {}

style, sections = infer_docstring_style(
docstring,
Expand Down
8 changes: 0 additions & 8 deletions src/griffe/_internal/docstrings/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
from contextlib import suppress
from typing import TYPE_CHECKING, TypedDict
from warnings import warn

from griffe._internal.docstrings.models import (
DocstringAttribute,
Expand Down Expand Up @@ -892,8 +891,6 @@ def parse_google(
warn_unknown_params: bool = True,
warn_missing_types: bool = True,
warnings: bool = True,
# YORE: Bump 2: Remove line.
**options: Any,
) -> list[DocstringSection]:
"""Parse a Google-style docstring.

Expand Down Expand Up @@ -921,7 +918,6 @@ def parse_google(
warn_unknown_params: Warn about documented parameters not appearing in the signature.
warn_missing_types: Warn about missing types/annotations for parameters, return values, etc.
warnings: Whether to log warnings at all.
**options: Swallowing keyword arguments for backward-compatibility.

Returns:
A list of docstring sections.
Expand All @@ -932,10 +928,6 @@ def parse_google(
in_code_block = False
lines = docstring.lines

# YORE: Bump 2: Remove block.
if options:
warn("Passing additional options is deprecated, these options are ignored.", DeprecationWarning, stacklevel=2)

options = {
"ignore_init_summary": ignore_init_summary,
"trim_doctest_flags": trim_doctest_flags,
Expand Down
8 changes: 0 additions & 8 deletions src/griffe/_internal/docstrings/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from contextlib import suppress
from textwrap import dedent
from typing import TYPE_CHECKING, TypedDict
from warnings import warn

from griffe._internal.docstrings.models import (
DocstringAttribute,
Expand Down Expand Up @@ -916,8 +915,6 @@ def parse_numpy(
warn_unknown_params: bool = True,
warn_missing_types: bool = True,
warnings: bool = True,
# YORE: Bump 2: Remove line.
**options: Any,
) -> list[DocstringSection]:
"""Parse a Numpydoc-style docstring.

Expand All @@ -931,7 +928,6 @@ def parse_numpy(
warn_unknown_params: Warn about documented parameters not appearing in the signature.
warn_missing_types: Warn about missing types/annotations for parameters, return values, etc.
warnings: Whether to log warnings at all.
**options: Swallowing keyword arguments for backward-compatibility.

Returns:
A list of docstring sections.
Expand All @@ -943,10 +939,6 @@ def parse_numpy(
in_code_block = False
lines = docstring.lines

# YORE: Bump 2: Remove block.
if options:
warn("Passing additional options is deprecated, these options are ignored.", DeprecationWarning, stacklevel=2)

options = {
"trim_doctest_flags": trim_doctest_flags,
"ignore_init_summary": ignore_init_summary,
Expand Down
8 changes: 0 additions & 8 deletions src/griffe/_internal/docstrings/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from contextlib import suppress
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, Callable, TypedDict
from warnings import warn

from griffe._internal.docstrings.models import (
DocstringAttribute,
Expand Down Expand Up @@ -98,26 +97,19 @@ def parse_sphinx(
*,
warn_unknown_params: bool = True,
warnings: bool = True,
# YORE: Bump 2: Remove line.
**options: Any,
) -> list[DocstringSection]:
"""Parse a Sphinx-style docstring.

Parameters:
docstring: The docstring to parse.
warn_unknown_params: Warn about documented parameters not appearing in the signature.
warnings: Whether to log warnings at all.
**options: Swallowing keyword arguments for backward-compatibility.

Returns:
A list of docstring sections.
"""
parsed_values = _ParsedValues()

# YORE: Bump 2: Remove block.
if options:
warn("Passing additional options is deprecated, these options are ignored.", DeprecationWarning, stacklevel=2)

options = {
"warn_unknown_params": warn_unknown_params,
"warnings": warnings,
Expand Down
Loading
Loading