extensions ¤
This module is the public interface to import elements from the base.
Modules:
-
base
–This module contains the base classes for dealing with extensions.
-
dataclasses
–Built-in extension adding support for dataclasses.
-
hybrid
–Deprecated. This extension provides an hybrid behavior while loading data.
Classes:
-
Extension
–Base class for Griffe extensions.
-
Extensions
–This class helps iterating on extensions that should run at different times.
-
InspectorExtension
–Deprecated in favor of
Extension
. The object inspector extension base class, to inherit from. -
VisitorExtension
–Deprecated in favor of
Extension
. The node visitor extension base class, to inherit from. -
When
–Enumeration of the different times at which an extension is used.
Functions:
-
load_extensions
–Load configured extensions.
Extension ¤
Base class for Griffe extensions.
Methods:
-
generic_inspect
–Extend the base generic inspection with extensions.
-
generic_visit
–Visit children nodes.
-
inspect
–Inspect a node.
-
on_attribute_instance
–Run when an Attribute has been created.
-
on_attribute_node
–Run when visiting a new attribute node during static/dynamic analysis.
-
on_class_instance
–Run when a Class has been created.
-
on_class_members
–Run when members of a Class have been loaded.
-
on_class_node
–Run when visiting a new class node during static/dynamic analysis.
-
on_function_instance
–Run when a Function has been created.
-
on_function_node
–Run when visiting a new function node during static/dynamic analysis.
-
on_instance
–Run when an Object has been created.
-
on_members
–Run when members of an Object have been loaded.
-
on_module_instance
–Run when a Module has been created.
-
on_module_members
–Run when members of a Module have been loaded.
-
on_module_node
–Run when visiting a new module node during static/dynamic analysis.
-
on_node
–Run when visiting a new node during static/dynamic analysis.
-
on_package_loaded
–Run when a package has been completely loaded.
-
visit
–Visit a node.
generic_inspect ¤
generic_inspect(node: ObjectNode) -> None
Extend the base generic inspection with extensions.
Parameters:
-
node
(ObjectNode
) –The node to inspect.
inspect ¤
inspect(node: ObjectNode) -> None
on_attribute_instance ¤
on_attribute_instance(
*, node: AST | ObjectNode, attr: Attribute
) -> None
Run when an Attribute has been created.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
attr
(Attribute
) –The attribute instance.
on_attribute_node ¤
on_attribute_node(*, node: AST | ObjectNode) -> None
Run when visiting a new attribute node during static/dynamic analysis.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
on_class_instance ¤
on_class_instance(
*, node: AST | ObjectNode, cls: Class
) -> None
Run when a Class has been created.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
cls
(Class
) –The class instance.
on_class_members ¤
on_class_members(
*, node: AST | ObjectNode, cls: Class
) -> None
Run when members of a Class have been loaded.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
cls
(Class
) –The class instance.
on_class_node ¤
on_class_node(*, node: AST | ObjectNode) -> None
Run when visiting a new class node during static/dynamic analysis.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
on_function_instance ¤
on_function_instance(
*, node: AST | ObjectNode, func: Function
) -> None
Run when a Function has been created.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
func
(Function
) –The function instance.
on_function_node ¤
on_function_node(*, node: AST | ObjectNode) -> None
Run when visiting a new function node during static/dynamic analysis.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
on_instance ¤
on_instance(*, node: AST | ObjectNode, obj: Object) -> None
Run when an Object has been created.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
obj
(Object
) –The object instance.
on_members ¤
on_members(*, node: AST | ObjectNode, obj: Object) -> None
Run when members of an Object have been loaded.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
obj
(Object
) –The object instance.
on_module_instance ¤
on_module_instance(
*, node: AST | ObjectNode, mod: Module
) -> None
Run when a Module has been created.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
mod
(Module
) –The module instance.
on_module_members ¤
on_module_members(
*, node: AST | ObjectNode, mod: Module
) -> None
Run when members of a Module have been loaded.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
-
mod
(Module
) –The module instance.
on_module_node ¤
on_module_node(*, node: AST | ObjectNode) -> None
Run when visiting a new module node during static/dynamic analysis.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
on_node ¤
on_node(*, node: AST | ObjectNode) -> None
Run when visiting a new node during static/dynamic analysis.
Parameters:
-
node
(AST | ObjectNode
) –The currently visited node.
Extensions ¤
Extensions(*extensions: ExtensionType)
This class helps iterating on extensions that should run at different times.
Parameters:
-
*extensions
(ExtensionType
, default:()
) –The extensions to add.
Methods:
-
add
–Add extensions to this container.
-
attach_inspector
–Attach a parent inspector to the inspector extensions.
-
attach_visitor
–Attach a parent visitor to the visitor extensions.
-
call
–Call the extension hook for the given event.
Attributes:
-
after_children_inspection
(list[InspectorExtension]
) –The inspectors that run after the children inspection.
-
after_children_visit
(list[VisitorExtension]
) –The visitors that run after the children visit.
-
after_inspection
(list[InspectorExtension]
) –The inspectors that run after the inspection.
-
after_visit
(list[VisitorExtension]
) –The visitors that run after the visit.
-
before_children_inspection
(list[InspectorExtension]
) –The inspectors that run before the children inspection.
-
before_children_visit
(list[VisitorExtension]
) –The visitors that run before the children visit.
-
before_inspection
(list[InspectorExtension]
) –The inspectors that run before the inspection.
-
before_visit
(list[VisitorExtension]
) –The visitors that run before the visit.
after_children_inspection property
¤
after_children_inspection: list[InspectorExtension]
The inspectors that run after the children inspection.
after_children_visit property
¤
after_children_visit: list[VisitorExtension]
The visitors that run after the children visit.
after_inspection property
¤
after_inspection: list[InspectorExtension]
The inspectors that run after the inspection.
before_children_inspection property
¤
before_children_inspection: list[InspectorExtension]
The inspectors that run before the children inspection.
before_children_visit property
¤
before_children_visit: list[VisitorExtension]
The visitors that run before the children visit.
before_inspection property
¤
before_inspection: list[InspectorExtension]
The inspectors that run before the inspection.
before_visit property
¤
before_visit: list[VisitorExtension]
The visitors that run before the visit.
add ¤
add(*extensions: ExtensionType) -> None
Add extensions to this container.
Parameters:
-
*extensions
(ExtensionType
, default:()
) –The extensions to add.
attach_inspector ¤
attach_inspector(parent_inspector: Inspector) -> Extensions
Attach a parent inspector to the inspector extensions.
Parameters:
-
parent_inspector
(Inspector
) –The parent inspector, leading the inspection.
Returns:
-
Extensions
–Self, conveniently.
attach_visitor ¤
attach_visitor(parent_visitor: Visitor) -> Extensions
Attach a parent visitor to the visitor extensions.
Parameters:
-
parent_visitor
(Visitor
) –The parent visitor, leading the visit.
Returns:
-
Extensions
–Self, conveniently.
InspectorExtension ¤
InspectorExtension()
Deprecated in favor of Extension
. The object inspector extension base class, to inherit from.
Methods:
attach ¤
attach(inspector: Inspector) -> None
Attach the parent inspector to this extension.
Parameters:
-
inspector
(Inspector
) –The parent inspector.
inspect ¤
inspect(node: ObjectNode) -> None
VisitorExtension ¤
VisitorExtension()
Deprecated in favor of Extension
. The node visitor extension base class, to inherit from.
Methods:
When ¤
flowchart TD
griffe.extensions.When[When]
click griffe.extensions.When href "" "griffe.extensions.When"
Enumeration of the different times at which an extension is used.
Attributes:
-
after_all
(int
) –For each node, after the visit/inspection.
-
after_children
(int
) –For each node, after the children have been visited/inspected, and before finishing the visit/inspection.
-
before_all
(int
) –For each node, before the visit/inspection.
-
before_children
(int
) –For each node, after the visit has started, and before the children visit/inspection.
after_all class-attribute
instance-attribute
¤
after_all: int = 4
For each node, after the visit/inspection.
after_children class-attribute
instance-attribute
¤
after_children: int = 3
For each node, after the children have been visited/inspected, and before finishing the visit/inspection.