Alias ¤
Alias(
name: str,
target: str | Object | Alias,
*,
lineno: int | None = None,
endlineno: int | None = None,
runtime: bool = True,
parent: Module | Class | Alias | None = None,
inherited: bool = False,
wildcard_imported: bool = False,
analysis: Literal["static", "dynamic"] | None = None,
)
Bases: ObjectAliasMixin
flowchart TD
griffe.Alias[Alias]
griffe._internal.mixins.ObjectAliasMixin[ObjectAliasMixin]
griffe._internal.mixins.GetMembersMixin[GetMembersMixin]
griffe._internal.mixins.SetMembersMixin[SetMembersMixin]
griffe._internal.mixins.DelMembersMixin[DelMembersMixin]
griffe._internal.mixins.SerializationMixin[SerializationMixin]
griffe._internal.mixins.ObjectAliasMixin --> griffe.Alias
griffe._internal.mixins.GetMembersMixin --> griffe._internal.mixins.ObjectAliasMixin
griffe._internal.mixins.SetMembersMixin --> griffe._internal.mixins.ObjectAliasMixin
griffe._internal.mixins.DelMembersMixin --> griffe._internal.mixins.ObjectAliasMixin
griffe._internal.mixins.SerializationMixin --> griffe._internal.mixins.ObjectAliasMixin
click griffe.Alias href "" "griffe.Alias"
click griffe._internal.mixins.ObjectAliasMixin href "" "griffe._internal.mixins.ObjectAliasMixin"
click griffe._internal.mixins.GetMembersMixin href "" "griffe._internal.mixins.GetMembersMixin"
click griffe._internal.mixins.SetMembersMixin href "" "griffe._internal.mixins.SetMembersMixin"
click griffe._internal.mixins.DelMembersMixin href "" "griffe._internal.mixins.DelMembersMixin"
click griffe._internal.mixins.SerializationMixin href "" "griffe._internal.mixins.SerializationMixin"
This class represents an alias, or indirection, to an object declared in another module.
Aliases represent objects that are in the scope of a module or class, but were imported from another module.
They behave almost exactly like regular objects, to a few exceptions:
- line numbers are those of the alias, not the target
- the path is the alias path, not the canonical one
- the name can be different from the target's
- if the target can be resolved, the kind is the target's kind
- if the target cannot be resolved, the kind becomes Kind.ALIAS
Parameters:
-
(name¤str) –The alias name.
-
(target¤str | Object | Alias) –If it's a string, the target resolution is delayed until accessing the target property. If it's an object, or even another alias, the target is immediately set.
-
(lineno¤int | None, default:None) –The alias starting line number.
-
(endlineno¤int | None, default:None) –The alias ending line number.
-
(runtime¤bool, default:True) –Whether this alias is present at runtime or not.
-
(parent¤Module | Class | Alias | None, default:None) –The alias parent.
-
(inherited¤bool, default:False) –Whether this alias wraps an inherited member.
-
(wildcard_imported¤bool, default:False) –Whether this alias was created using a wildcard import.
-
(analysis¤Literal['static', 'dynamic'] | None, default:None) –The type of analysis used to load this alias. None means the alias was created manually.
- Guide User guide Manipulating APIs
- Reference
- Reference Python API
Methods:
-
__bool__–An alias is always true-ish.
-
__delitem__–Delete a member with its name or path.
-
__getitem__–Get a member with its name or path.
-
__len__–The length of an alias is always 1.
-
__setitem__–Set a member with its name or path.
-
as_dict–Return this alias' data as a dictionary.
-
as_json–Return this target's data as a JSON string.
-
del_member–Delete a member with its name or path.
-
filter_members–Filter and return members based on predicates.
-
from_json–Create an instance of this class from a JSON string.
-
get_member–Get a member with its name or path.
-
has_labels–Tell if this object has all the given labels.
-
is_kind–Tell if this object is of the given kind.
-
mro–Return a list of classes in order corresponding to Python's MRO.
-
resolve–Resolve a name within this object's and parents' scope.
-
resolve_target–Resolve the target.
-
set_member–Set a member with its name or path.
-
signature–Construct the class/function signature.
Attributes:
-
alias_endlineno(int | None) –The ending line number of the alias.
-
alias_lineno(int | None) –The starting line number of the alias.
-
aliases(dict[str, Alias]) –The aliases pointing to this object.
-
all_members(dict[str, Object | Alias]) –All members (declared and inherited).
-
analysis(Literal['static', 'dynamic'] | None) –The type of analysis used to load this alias.
-
annotation(str | Expr | None) –The attribute type annotation.
-
attributes(dict[str, Attribute]) –The attribute members.
-
bases(list[Expr | str]) –The class bases.
-
canonical_path(str) –The full dotted path of this object.
-
classes(dict[str, Class]) –The class members.
-
decorators(list[Decorator]) –The class/function decorators.
-
deleter(Function | None) –The deleter linked to this function (property).
-
deprecated(str | bool | None) –Whether this alias is deprecated (boolean or deprecation message).
-
docstring(Docstring | None) –The target docstring.
-
endlineno(int | None) –The ending line number of the target object.
-
exports(list[str | ExprName] | None) –The names of the objects exported by this (module) object through the
__all__variable. -
extra(dict) –Namespaced dictionaries storing extra metadata for this object, used by extensions.
-
filepath(Path | list[Path]) –The file path (or directory list for namespace packages) where this object was defined.
-
final_target(Object) –The final, resolved target, if possible.
-
functions(dict[str, Function]) –The function members.
-
git_info(GitInfo | None) –Get the Git information for this object, if available.
-
has_docstring(bool) –Whether this alias' target has a non-empty docstring.
-
has_docstrings(bool) –Whether this alias' target or any of its members has a non-empty docstring.
-
imports(dict[str, str]) –The other objects imported by this alias' target.
-
imports_future_annotations(bool) –Whether this module import future annotations.
-
inherited(bool) –Whether this alias represents an inherited member.
-
inherited_members(dict[str, Alias]) –Members that are inherited from base classes.
-
is_alias(bool) –Always true for aliases.
-
is_attribute(bool) –Whether this object is an attribute.
-
is_class(bool) –Whether this object is a class.
-
is_class_private(bool) –Whether this object/alias is class-private (starts with
__and is a class member). -
is_collection(bool) –Always false for aliases.
-
is_deprecated(bool) –Whether this object is deprecated.
-
is_exported(bool) –Whether this object/alias is exported (listed in
__all__). -
is_function(bool) –Whether this object is a function.
-
is_generic(bool) –Whether this object is generic.
-
is_imported(bool) –Whether this object/alias was imported from another module.
-
is_init_method(bool) –Whether this method is an
__init__method. -
is_init_module(bool) –Whether this module is an
__init__.pymodule. -
is_module(bool) –Whether this object is a module.
-
is_namespace_package(bool) –Whether this module is a namespace package (top folder, no
__init__.py). -
is_namespace_subpackage(bool) –Whether this module is a namespace subpackage.
-
is_package(bool) –Whether this module is a package (top module).
-
is_private(bool) –Whether this object/alias is private (starts with
_) but not special. -
is_public(bool) –Whether this object is considered public.
-
is_special(bool) –Whether this object/alias is special ("dunder" attribute/method, starts and end with
__). -
is_subpackage(bool) –Whether this module is a subpackage.
-
is_type_alias(bool) –Whether this object is a type alias.
-
is_wildcard_exposed(bool) –Whether this object/alias is exposed to wildcard imports.
-
keywords(dict[str, Expr | str]) –The class keywords.
-
kind(Kind) –The target's kind, or
Kind.ALIASif the target cannot be resolved. -
labels(set[str]) –The target labels (
property,dataclass, etc.). -
lineno(int | None) –The starting line number of the target object.
-
lines(list[str]) –The lines containing the source of this object.
-
lines_collection(LinesCollection) –The lines collection attached to this object or its parents.
-
members(dict[str, Object | Alias]) –The target's members (modules, classes, functions, attributes, type aliases).
-
module(Module) –The parent module of this object.
-
modules(dict[str, Module]) –The module members.
-
modules_collection(ModulesCollection) –The modules collection attached to the alias parents.
-
name(str) –The alias name.
-
overloads(dict[str, list[Function]] | list[Function] | None) –The overloaded signatures declared in this class/module or for this function.
-
package(Module) –The absolute top module (the package) of this object.
-
parameters(Parameters) –The parameters of the current function or
__init__method for classes. -
parent(Module | Class | Alias | None) –The parent of this alias.
-
path(str) –The dotted path / import path of this object.
-
public(bool | None) –Whether this alias is public.
-
relative_filepath(Path) –The file path where this object was defined, relative to the current working directory.
-
relative_package_filepath(Path) –The file path where this object was defined, relative to the top module path.
-
resolved(bool) –Whether this alias' target is resolved.
-
resolved_bases(list[Object]) –Resolved class bases.
-
returns(str | Expr | None) –The function return type annotation.
-
runtime(bool) –Whether this alias is available at runtime.
-
setter(Function | None) –The setter linked to this function (property).
-
source(str) –The source code of this object.
-
source_link(str | None) –Get the source link for this object, if available.
-
target(Object | Alias) –The resolved target (actual object), if possible.
-
target_path(str) –The path of this alias' target.
-
type_aliases(dict[str, TypeAlias]) –The type alias members.
-
type_parameters(TypeParameters) –The target type parameters.
-
value(str | Expr | None) –The attribute or type alias value.
-
wildcard(str | None) –The module on which the wildcard import is performed (if any).
-
wildcard_imported(bool) –Whether this alias was created using a wildcard import.
Source code in src/griffe/_internal/models.py
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 | |
alias_endlineno instance-attribute ¤
The ending line number of the alias.
- Guide User guide Manipulating APIs Navigating APIs Model-specific fields Alias
alias_lineno instance-attribute ¤
The starting line number of the alias.
- Guide User guide Manipulating APIs Navigating APIs Model-specific fields Alias
all_members property ¤
All members (declared and inherited).
This method is part of the consumer API: do not use when producing Griffe trees!
- Guide User guide Manipulating APIs Navigating APIs Moving down: members
analysis instance-attribute ¤
The type of analysis used to load this alias.
None means the alias was created manually.
attributes property ¤
The attribute members.
This method is part of the consumer API: do not use when producing Griffe trees!
- Guide User guide Manipulating APIs Navigating APIs Moving down: members
classes property ¤
The class members.
This method is part of the consumer API: do not use when producing Griffe trees!
- Guide User guide Manipulating APIs Navigating APIs Moving down: members
decorators property ¤
deprecated instance-attribute ¤
Whether this alias is deprecated (boolean or deprecation message).
docstring property writable ¤
docstring: Docstring | None
exports property ¤
The names of the objects exported by this (module) object through the __all__ variable.
Exports can contain string (object names) or resolvable names, like other lists of exports coming from submodules:
from .submodule import __all__ as submodule_all
__all__ = ["hello", *submodule_all]
Exports get expanded by the loader before it expands wildcards and resolves aliases.
See also: GriffeLoader.expand_exports.
extra property ¤
extra: dict
Namespaced dictionaries storing extra metadata for this object, used by extensions.
filepath property ¤
The file path (or directory list for namespace packages) where this object was defined.
See also: relative_filepath, relative_package_filepath.
final_target property ¤
final_target: Object
The final, resolved target, if possible.
This will iterate through the targets until a non-alias object is found.
See also: target, resolve_target, resolved.
- Guide User guide Manipulating APIs Navigating APIs Aliases Alias chains
- Reference Python API Models
Alias
functions property ¤
The function members.
This method is part of the consumer API: do not use when producing Griffe trees!
- Guide User guide Manipulating APIs Navigating APIs Moving down: members
git_info property writable ¤
git_info: GitInfo | None
Get the Git information for this object, if available.
has_docstring property ¤
has_docstring: bool
Whether this alias' target has a non-empty docstring.
See also: has_docstrings, docstring.
has_docstrings property ¤
has_docstrings: bool
Whether this alias' target or any of its members has a non-empty docstring.
See also: has_docstring, docstring.
imports property ¤
The other objects imported by this alias' target.
Keys are the names within the object (from ... import ... as AS_NAME), while the values are the actual names of the objects (from ... import REAL_NAME as ...).
See also: is_imported.
imports_future_annotations property ¤
imports_future_annotations: bool
Whether this module import future annotations.
inherited instance-attribute ¤
Whether this alias represents an inherited member.
- Guide User guide Manipulating APIs Navigating APIs Moving down: members Inherited members
inherited_members property ¤
Members that are inherited from base classes.
Each inherited member of the target will be wrapped in an alias, to preserve correct object access paths.
This method is part of the consumer API: do not use when producing Griffe trees!
See also: members.
is_alias class-attribute instance-attribute ¤
is_alias: bool = True
Always true for aliases.
is_attribute property ¤
is_attribute: bool
Whether this object is an attribute.
See also: is_module, is_class, is_function, is_type_alias, is_alias, is_kind.
is_class property ¤
is_class: bool
Whether this object is a class.
See also: is_module, is_function, is_attribute, is_type_alias, is_alias, is_kind.
is_class_private property ¤
is_class_private: bool
Whether this object/alias is class-private (starts with __ and is a class member).
- Guide User guide Manipulating APIs Navigating APIs Object visibility
is_collection class-attribute instance-attribute ¤
is_collection: bool = False
Always false for aliases.
See also: ModulesCollection.
is_deprecated property ¤
is_deprecated: bool
Whether this object is deprecated.
- Guide User guide Manipulating APIs Navigating APIs Object visibility
is_exported property ¤
is_exported: bool
Whether this object/alias is exported (listed in __all__).
- Changelog 0.46.0 - 2024-06-16 Deprecations
- Guide User guide Manipulating APIs Navigating APIs Imports/exports
is_function property ¤
is_function: bool
Whether this object is a function.
See also: is_module, is_class, is_attribute, is_type_alias, is_alias, is_kind.
is_imported property ¤
is_imported: bool
Whether this object/alias was imported from another module.
- Guide User guide Manipulating APIs Navigating APIs Imports/exports
- Reference Python API Models
Aliasimports
is_module property ¤
is_module: bool
Whether this object is a module.
See also: is_init_module. is_class, is_function, is_attribute, is_type_alias, is_alias, is_kind.
is_namespace_package property ¤
is_namespace_package: bool
Whether this module is a namespace package (top folder, no __init__.py).
See also: is_namespace_subpackage.
is_namespace_subpackage property ¤
is_namespace_subpackage: bool
is_package property ¤
is_package: bool
is_private property ¤
is_private: bool
Whether this object/alias is private (starts with _) but not special.
- Guide User guide Manipulating APIs Navigating APIs Object visibility
is_public property ¤
is_public: bool
Whether this object is considered public.
In modules, developers can mark objects as public thanks to the __all__ variable. In classes however, there is no convention or standard to do so.
Therefore, to decide whether an object is public, we follow this algorithm:
- If the object's
publicattribute is set (boolean), return its value. - If the object is listed in its parent's (a module)
__all__attribute, it is public. - If the parent (module) defines
__all__and the object is not listed in, it is private. - If the object has a private name, it is private.
- If the object was imported from another module, it is private.
- Otherwise, the object is public.
- Changelog 0.46.0 - 2024-06-16 Deprecations
- Guide User guide Manipulating APIs Navigating APIs Object visibility
is_special property ¤
is_special: bool
Whether this object/alias is special ("dunder" attribute/method, starts and end with __).
- Guide User guide Manipulating APIs Navigating APIs Object visibility
is_subpackage property ¤
is_subpackage: bool
is_type_alias property ¤
is_type_alias: bool
Whether this object is a type alias.
See also: is_module, is_class, is_function, is_attribute, is_alias, is_kind.
is_wildcard_exposed property ¤
is_wildcard_exposed: bool
Whether this object/alias is exposed to wildcard imports.
To be exposed to wildcard imports, an object/alias must:
- be available at runtime
- have a module as parent
- be listed in
__all__if__all__is defined - or not be private (having a name starting with an underscore)
Special case for Griffe trees: a submodule is only exposed if its parent imports it.
Returns:
-
bool–True or False.
- Guide User guide Manipulating APIs Navigating APIs Imports/exports
kind property ¤
kind: Kind
The target's kind, or Kind.ALIAS if the target cannot be resolved.
See also: is_kind.
- Guide User guide Manipulating APIs Navigating APIs Aliases
labels property ¤
lines property ¤
lines_collection property ¤
lines_collection: LinesCollection
The lines collection attached to this object or its parents.
Raises:
-
ValueError–When no modules collection can be found in the object or its parents.
members property ¤
The target's members (modules, classes, functions, attributes, type aliases).
See also: inherited_members, get_member, set_member, filter_members.
module property ¤
module: Module
The parent module of this object.
See also: package.
Raises:
-
ValueError–When the object is not a module and does not have a parent.
modules property ¤
The module members.
This method is part of the consumer API: do not use when producing Griffe trees!
- Guide User guide Manipulating APIs Navigating APIs Moving down: members
modules_collection property ¤
modules_collection: ModulesCollection
The modules collection attached to the alias parents.
overloads property writable ¤
The overloaded signatures declared in this class/module or for this function.
parameters property ¤
parameters: Parameters
The parameters of the current function or __init__ method for classes.
This property can fetch inherited members, and therefore is part of the consumer API: do not use when producing Griffe trees!
path property ¤
path: str
relative_filepath property ¤
relative_filepath: Path
The file path where this object was defined, relative to the current working directory.
If this object's file path is not relative to the current working directory, return its absolute path.
See also: filepath, relative_package_filepath.
Raises:
-
ValueError–When the relative path could not be computed.
relative_package_filepath property ¤
relative_package_filepath: Path
The file path where this object was defined, relative to the top module path.
See also: filepath, relative_filepath.
Raises:
-
ValueError–When the relative path could not be computed.
resolved property ¤
resolved: bool
Whether this alias' target is resolved.
- Guide User guide Manipulating APIs Navigating APIs Aliases
- Reference Python API Models
Alias
resolved_bases property ¤
Resolved class bases.
This method is part of the consumer API: do not use when producing Griffe trees!
source property ¤
source: str
source_link property writable ¤
source_link: str | None
Get the source link for this object, if available.
target property writable ¤
The resolved target (actual object), if possible.
Upon accessing this property, if the target is not already resolved, a lookup is done using the modules collection to find the target.
See also: final_target, resolve_target, resolved.
target_path instance-attribute ¤
target_path: str
The path of this alias' target.
- Guide User guide Manipulating APIs Navigating APIs
type_aliases property ¤
The type alias members.
This method is part of the consumer API: do not use when producing Griffe trees!
- Guide User guide Manipulating APIs Navigating APIs Moving down: members
wildcard property ¤
wildcard: str | None
The module on which the wildcard import is performed (if any).
See also: GriffeLoader.expand_wildcards.
wildcard_imported instance-attribute ¤
wildcard_imported: bool = wildcard_imported
Whether this alias was created using a wildcard import.
__bool__ ¤
__bool__() -> bool
An alias is always true-ish.
Source code in src/griffe/_internal/models.py
1426 1427 1428 | |
__delitem__ ¤
Delete a member with its name or path.
This method is part of the consumer API: do not use when producing Griffe trees!
Members will be looked up in both declared members and inherited ones, triggering computation of the latter.
Parameters:
Examples:
>>> del griffe_object["foo"]
>>> del griffe_object["path.to.bar"]
>>> del griffe_object[("path", "to", "qux")]
Source code in src/griffe/_internal/mixins.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
__getitem__ ¤
Get a member with its name or path.
This method is part of the consumer API: do not use when producing Griffe trees!
Members will be looked up in both declared members and inherited ones, triggering computation of the latter.
Parameters:
Examples:
>>> foo = griffe_object["foo"]
>>> bar = griffe_object["path.to.bar"]
>>> qux = griffe_object[("path", "to", "qux")]
Source code in src/griffe/_internal/mixins.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
__len__ ¤
__len__() -> int
The length of an alias is always 1.
Source code in src/griffe/_internal/models.py
1430 1431 1432 | |
__setitem__ ¤
Set a member with its name or path.
This method is part of the consumer API: do not use when producing Griffe trees!
Parameters:
-
(key¤str | Sequence[str]) –The name or path of the member.
-
(value¤Object | Alias) –The member.
Examples:
>>> griffe_object["foo"] = foo
>>> griffe_object["path.to.bar"] = bar
>>> griffe_object[("path", "to", "qux")] = qux
Source code in src/griffe/_internal/mixins.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
as_dict ¤
Return this alias' data as a dictionary.
See also: as_json.
Parameters:
-
(full¤bool, default:False) –Whether to return full info, or just base info.
-
(**kwargs¤Any, default:{}) –Additional serialization options.
Returns:
Source code in src/griffe/_internal/models.py
2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 | |
as_json ¤
Return this target's data as a JSON string.
See also: as_dict.
Parameters:
-
(full¤bool, default:False) –Whether to return full info, or just base info.
-
(**kwargs¤Any, default:{}) –Additional serialization options passed to encoder.
Returns:
-
str–A JSON string.
Source code in src/griffe/_internal/models.py
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 | |
del_member ¤
Delete a member with its name or path.
This method is part of the producer API: you can use it safely while building Griffe trees (for example in Griffe extensions).
Members will be looked up in declared members only, not inherited ones.
Parameters:
Examples:
>>> griffe_object.del_member("foo")
>>> griffe_object.del_member("path.to.bar")
>>> griffe_object.del_member(("path", "to", "qux"))
Source code in src/griffe/_internal/mixins.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
filter_members ¤
Filter and return members based on predicates.
See also: members, get_member, set_member.
Parameters:
-
(*predicates¤Callable[[Object | Alias], bool], default:()) –A list of predicates, i.e. callables accepting a member as argument and returning a boolean.
Returns:
Source code in src/griffe/_internal/models.py
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 | |
from_json classmethod ¤
from_json(json_string: str, **kwargs: Any) -> _ObjType
Create an instance of this class from a JSON string.
Parameters:
-
(json_string¤str) –JSON to decode into Object.
-
(**kwargs¤Any, default:{}) –Additional options passed to decoder.
Returns:
-
_ObjType–An Object instance.
Raises:
-
TypeError–When the json_string does not represent and object of the class from which this classmethod has been called.
- Guide User guide Manipulating APIs Serializing APIs Python API
- Reference
Source code in src/griffe/_internal/mixins.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
get_member ¤
Get a member with its name or path.
This method is part of the producer API: you can use it safely while building Griffe trees (for example in Griffe extensions).
Members will be looked up in declared members only, not inherited ones.
Parameters:
Examples:
>>> foo = griffe_object["foo"]
>>> bar = griffe_object["path.to.bar"]
>>> bar = griffe_object[("path", "to", "bar")]
Source code in src/griffe/_internal/mixins.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
has_labels ¤
Tell if this object has all the given labels.
See also: labels.
Parameters:
Returns:
-
bool–True or False.
Source code in src/griffe/_internal/models.py
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 | |
is_kind ¤
Tell if this object is of the given kind.
See also: is_module, is_class, is_function, is_attribute, is_type_alias, is_alias.
Parameters:
Raises:
-
ValueError–When an empty set is given as argument.
Returns:
-
bool–True or False.
Source code in src/griffe/_internal/models.py
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 | |
mro ¤
Return a list of classes in order corresponding to Python's MRO.
Source code in src/griffe/_internal/models.py
2044 2045 2046 | |
resolve ¤
Resolve a name within this object's and parents' scope.
Parameters:
Raises:
-
NameResolutionError–When the name could not be resolved.
Returns:
-
str–The resolved name.
Source code in src/griffe/_internal/models.py
1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 | |
resolve_target ¤
resolve_target() -> None
Resolve the target.
See also: target, final_target, resolved.
Raises:
-
AliasResolutionError–When the target cannot be resolved. It happens when the target does not exist, or could not be loaded (unhandled dynamic object?), or when the target is from a module that was not loaded and added to the collection.
-
CyclicAliasError–When the resolved target is the alias itself.
- Guide User guide Manipulating APIs Navigating APIs Model-specific fields Alias
- Reference Python API Models
Alias
Source code in src/griffe/_internal/models.py
2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 | |
set_member ¤
Set a member with its name or path.
This method is part of the producer API: you can use it safely while building Griffe trees (for example in Griffe extensions).
Parameters:
-
(key¤str | Sequence[str]) –The name or path of the member.
-
(value¤Object | Alias) –The member.
Examples:
>>> griffe_object.set_member("foo", foo)
>>> griffe_object.set_member("path.to.bar", bar)
>>> griffe_object.set_member(("path", "to", "qux"), qux)
Source code in src/griffe/_internal/mixins.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
signature ¤
signature(
*, return_type: bool = False, name: str | None = None
) -> str
Construct the class/function signature.
Parameters:
-
(return_type¤bool, default:False) –Whether to include the return type in the signature.
-
(name¤str | None, default:None) –The name of the class/function to use in the signature.
Returns:
-
str–A string representation of the class/function signature.
Source code in src/griffe/_internal/models.py
2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 | |