Skip to content

Commit

Permalink
fix: Fix identity checks in inspector when handling attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Sep 9, 2024
1 parent a319f65 commit 676cfb4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/_griffe/agents/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from _griffe.agents.nodes.runtime import ObjectNode
from _griffe.collections import LinesCollection, ModulesCollection
from _griffe.enumerations import ObjectKind, ParameterKind
from _griffe.enumerations import Kind, ParameterKind
from _griffe.expressions import safe_get_annotation
from _griffe.extensions.base import Extensions, load_extensions
from _griffe.importer import dynamic_import
Expand Down Expand Up @@ -483,18 +483,18 @@ def handle_attribute(self, node: ObjectNode, annotation: str | Expr | None = Non
self.extensions.call("on_node", node=node, agent=self)
self.extensions.call("on_attribute_node", node=node, agent=self)

# TODO: to improve
# TODO: To improve.
parent = self.current
labels: set[str] = set()

if parent.kind is ObjectKind.MODULE:
if parent.kind is Kind.MODULE:
labels.add("module")
elif parent.kind is ObjectKind.CLASS:
elif parent.kind is Kind.CLASS:
labels.add("class")
elif parent.kind is ObjectKind.FUNCTION:
elif parent.kind is Kind.FUNCTION:
if parent.name != "__init__":
return
parent = parent.parent
parent = parent.parent # type: ignore[assignment]
labels.add("instance")

try:
Expand Down

0 comments on commit 676cfb4

Please sign in to comment.