Skip to content

Commit

Permalink
refactor: Remove all legacy code for v1
Browse files Browse the repository at this point in the history
PR-314: #314
  • Loading branch information
pawamoy authored Aug 15, 2024
1 parent 7d9deaf commit 86d321e
Show file tree
Hide file tree
Showing 74 changed files with 246 additions and 1,671 deletions.
7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,10 @@ We are still in v0, so no major bump yet.

### Deprecations

- Classes [`InspectorExtension`][griffe.InspectorExtension]
and [`VisitorExtension`][griffe.VisitorExtension]
- Classes `InspectorExtension` and `VisitorExtension`
are deprecated in favor of [`Extension`][griffe.Extension].
As a side-effect, the [`hybrid`][griffe.HybridExtension] extension
is also deprecated. See [how to use and write extensions](guide/users/extending.md).
As a side-effect, the `hybrid` extension is also deprecated.
See [how to use and write extensions](guide/users/extending.md).

### Breaking Changes

Expand Down
4 changes: 0 additions & 4 deletions config/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ filterwarnings =
# TODO: remove once pytest-xdist 4 is released
ignore:.*rsyncdir:DeprecationWarning:xdist
ignore:.*slated for removal in Python:DeprecationWarning:.*
# YORE: Bump 1: Remove line.
ignore:.*`get_logger`:DeprecationWarning:_griffe
# YORE: Bump 1: Remove line.
ignore:.*`name`:DeprecationWarning:_griffe
6 changes: 3 additions & 3 deletions docs/guide/users/navigating.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ Models have most fields in common, but also have specific fields.
### Functions

- [`decorators`][griffe.Function.decorators]: The [decorators][griffe.Decorator] applied to the function.
- [`deleter`][griffe.Function.deleter]: The property deleter, if the function is a property.
- [`setter`][griffe.Function.setter]: The property setter, if the function is a property.
- [`overloads`][griffe.Function.overloads]: The overloaded signatures of the function.
- [`parameters`][griffe.Function.parameters]: The [parameters][griffe.Parameters] of the function.
- [`returns`][griffe.Function.returns]: The type annotation of the returned value, in the form of an [expression][griffe.Expr]. The `annotation` field can also be used, for compatibility with attributes.
Expand All @@ -385,6 +383,8 @@ Models have most fields in common, but also have specific fields.

- [`annotation`][griffe.Attribute.annotation]: The type annotation of the attribute, in the form of an [expression][griffe.Expr].
- [`value`][griffe.Attribute.value]: The value of the attribute, in the form of an [expression][griffe.Expr].
- [`deleter`][griffe.Attribute.deleter]: The property deleter.
- [`setter`][griffe.Attribute.setter]: The property setter.

### Alias

Expand Down Expand Up @@ -434,7 +434,7 @@ Ultimately, these expressions are what allow downstream tools such as [mkdocstri

During static analysis, these expressions also allow to analyze decorators, dataclass fields, and many more things in great details, and in a robust manner, to build third-party libraries support in the form of [Griffe extensions](extending.md).

To learn more about expressions, read their [API reference][griffe.expressions].
To learn more about expressions, read their [API reference](../../reference/api/expressions.md).

### Modernization

Expand Down
172 changes: 0 additions & 172 deletions docs/reference/api/deprecated.md

This file was deleted.

2 changes: 0 additions & 2 deletions docs/reference/api/docstrings/parsers.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

::: griffe.docstring_warning

::: griffe.DocstringWarningCallable

::: griffe.DocstringDetectionMethod

::: griffe.infer_docstring_style
13 changes: 1 addition & 12 deletions docs/reference/api/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,12 @@

## **Types**

::: griffe.ExtensionType

::: griffe.LoadableExtensionType

## **Builtin extensions**

::: griffe.builtin_extensions

::: griffe.DataclassesExtension
options:
inherited_members: false

## **Deprecated API**

::: griffe.When

::: griffe.VisitorExtension

::: griffe.InspectorExtension

::: griffe.HybridExtension
11 changes: 3 additions & 8 deletions docs/reference/api/loggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## **Main API**

<!-- YORE: Bump 1: Replace line with `::: griffe.logger`. -->
<!-- -->
::: griffe.logger

::: griffe.get_logger

::: griffe.Logger

Expand All @@ -15,10 +16,4 @@

## **Advanced API**

::: griffe.patch_logger

## **Deprecated API**

::: griffe.get_logger

::: griffe.patch_loggers
4 changes: 2 additions & 2 deletions docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@
]
},
"members": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"$ref": "#"
}
},
Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ nav:
- Git utilities: reference/api/git.md
- Loggers: reference/api/loggers.md
- Helpers: reference/api/helpers.md
- Deprecated: reference/api/deprecated.md
- Changelog: changelog.md
- Insiders:
- insiders/index.md
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ requires-python = ">=3.8"
keywords = ["api", "signature", "breaking-changes", "static-analysis", "dynamic-analysis"]
dynamic = ["version"]
classifiers = [
# YORE: Bump 1: Replace `4 - Beta` with `5 - Production/Stable` within line.
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
Expand Down
26 changes: 4 additions & 22 deletions src/_griffe/agents/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
from _griffe.expressions import safe_get_annotation
from _griffe.extensions.base import Extensions, load_extensions
from _griffe.importer import dynamic_import

# YORE: Bump 1: Replace `_logger` with `logger` within file.
# YORE: Bump 1: Replace `get_logger` with `logger` within line.
from _griffe.logger import get_logger
from _griffe.logger import logger
from _griffe.models import Alias, Attribute, Class, Docstring, Function, Module, Parameter, Parameters

if TYPE_CHECKING:
Expand All @@ -28,8 +25,6 @@
from _griffe.expressions import Expr


# YORE: Bump 1: Remove line.
_logger = get_logger("griffe.agents.inspector")
_empty = Signature.empty


Expand Down Expand Up @@ -132,7 +127,7 @@ def __init__(
self.filepath: Path | None = filepath
"""The module file path."""

self.extensions: Extensions = extensions.attach_inspector(self)
self.extensions: Extensions = extensions
"""The extensions to use when inspecting."""

self.parent: Module | None = parent
Expand Down Expand Up @@ -239,21 +234,14 @@ def inspect(self, node: ObjectNode) -> None:
Parameters:
node: The node to inspect.
"""
for before_inspector in self.extensions.before_inspection:
before_inspector.inspect(node)
getattr(self, f"inspect_{node.kind}", self.generic_inspect)(node)
for after_inspector in self.extensions.after_inspection:
after_inspector.inspect(node)

def generic_inspect(self, node: ObjectNode) -> None:
"""Extend the base generic inspection with extensions.
Parameters:
node: The node to inspect.
"""
for before_inspector in self.extensions.before_children_inspection:
before_inspector.inspect(node)

for child in node.children:
if target_path := child.alias_target_path:
# If the child is an actual submodule of the current module,
Expand All @@ -264,7 +252,7 @@ def generic_inspect(self, node: ObjectNode) -> None:
# so we skip it here (no member, no alias, just skip it).
if child.is_module and target_path == f"{self.current.path}.{child.name}":
if not hasattr(child.obj, "__file__"):
_logger.debug(f"Module {target_path} is not discoverable on disk, inspecting right now")
logger.debug(f"Module {target_path} is not discoverable on disk, inspecting right now")
inspector = Inspector(
child.name,
filepath=None,
Expand All @@ -275,20 +263,14 @@ def generic_inspect(self, node: ObjectNode) -> None:
lines_collection=self.lines_collection,
modules_collection=self.modules_collection,
)
try:
inspector.inspect_module(child)
finally:
self.extensions.attach_inspector(self)
inspector.inspect_module(child)
self.current.set_member(child.name, inspector.current.module)
# Otherwise, alias the object.
else:
self.current.set_member(child.name, Alias(child.name, target_path))
else:
self.inspect(child)

for after_inspector in self.extensions.after_children_inspection:
after_inspector.inspect(node)

def inspect_module(self, node: ObjectNode) -> None:
"""Inspect a module.
Expand Down
Loading

0 comments on commit 86d321e

Please sign in to comment.