Expressions¤
Helpers¤
get_annotation
module-attribute
¤
get_annotation = partial(get_expression, parse_strings=None)
get_base_class
module-attribute
¤
get_base_class = partial(
get_expression, parse_strings=False
)
get_class_keyword
module-attribute
¤
get_class_keyword = partial(
get_expression, parse_strings=False
)
get_condition
module-attribute
¤
get_condition = partial(get_expression, parse_strings=False)
get_expression
¤
get_expression(
node: AST | None,
parent: Module | Class,
*,
member: str | None = None,
parse_strings: bool | None = None,
) -> Expr | None
Build an expression from an AST.
Parameters:
-
(node¤AST | None) –The annotation node.
-
(parent¤Module | Class) –The parent used to resolve the name.
-
(member¤str | None, default:None) –The member name (for resolution in its scope).
-
(parse_strings¤bool | None, default:None) –Whether to try and parse strings as type annotations.
Returns:
-
Expr | None–A string or resovable name or expression.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 | |
safe_get_annotation
module-attribute
¤
safe_get_annotation = partial(
safe_get_expression,
parse_strings=None,
msg_format=_msg_format % "annotation",
)
safe_get_base_class
module-attribute
¤
safe_get_base_class = partial(
safe_get_expression,
parse_strings=False,
msg_format=_msg_format % "base class",
)
safe_get_class_keyword
module-attribute
¤
safe_get_class_keyword = partial(
safe_get_expression,
parse_strings=False,
msg_format=_msg_format % "class keyword",
)
safe_get_condition
module-attribute
¤
safe_get_condition = partial(
safe_get_expression,
parse_strings=False,
msg_format=_msg_format % "condition",
)
safe_get_expression
¤
safe_get_expression(
node: AST | None,
parent: Module | Class,
*,
member: str | None = None,
parse_strings: bool | None = None,
log_level: LogLevel | None = error,
msg_format: str = "{path}:{lineno}: Failed to get expression from {node_class}: {error}",
) -> Expr | None
Safely (no exception) build a resolvable annotation.
Parameters:
-
(node¤AST | None) –The annotation node.
-
(parent¤Module | Class) –The parent used to resolve the name.
-
(member¤str | None, default:None) –The member name (for resolution in its scope).
-
(parse_strings¤bool | None, default:None) –Whether to try and parse strings as type annotations.
-
(log_level¤LogLevel | None, default:error) –Log level to use to log a message. None to disable logging.
-
(msg_format¤str, default:'{path}:{lineno}: Failed to get expression from {node_class}: {error}') –A format string for the log message. Available placeholders: path, lineno, node, error.
Returns:
-
Expr | None–A string or resovable name or expression.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 | |
Expression nodes¤
Expr
dataclass
¤
Expr()
Base class for expressions.
- Changelog 0.33.0 - 2023-08-16 Breaking Changes
- Guide User guide Manipulating APIs Navigating APIs Model-specific fields
-
Reference
griffe Expressions
-
Reference
griffe-
Docstrings
-
Docstring models
-
DocstringAdmonition -
DocstringAttribute -
DocstringClass -
DocstringDeprecatedannotation -
DocstringElementannotation -
DocstringFunction -
DocstringModule -
DocstringNamedElement -
DocstringParameter -
DocstringRaiseannotation -
DocstringReceive -
DocstringReturn -
DocstringTypeAlias -
DocstringTypeParameter -
DocstringWarnannotation -
DocstringYield
-
-
Docstring parsers
parse_docstring_annotation
-
Docstring models
-
Expressions
-
Expr -
ExprAttribute -
ExprBinOp -
ExprBoolOp -
ExprCall -
ExprCompare -
ExprComprehension -
ExprConstant -
ExprDict -
ExprDictComp -
ExprExtSlice -
ExprFormatted -
ExprGeneratorExp -
ExprIfExp -
ExprInterpolation -
ExprJoinedStr -
ExprKeyword -
ExprLambda -
ExprList -
ExprListComp -
ExprName -
ExprNamedExpr -
ExprParameter -
ExprSet -
ExprSetComp -
ExprSlice -
ExprSubscript -
ExprTemplateStr -
ExprTuple -
ExprUnaryOp -
ExprVarKeyword -
ExprVarPositional -
ExprYield -
ExprYieldFrom -
get_expression -
safe_get_expression
-
- Models
-
Serializers
json_decoder
-
Docstrings
-
Reference
griffe Expressions-
ExprAttribute -
ExprBinOp -
ExprBoolOp -
ExprCall -
ExprCompare -
ExprComprehension -
ExprConstant -
ExprDict -
ExprDictComp -
ExprExtSlice -
ExprFormatted -
ExprGeneratorExp -
ExprIfExp -
ExprInterpolation -
ExprJoinedStr -
ExprKeyword -
ExprLambda -
ExprList -
ExprListComp -
ExprName -
ExprNamedExpr -
ExprParameter -
ExprSet -
ExprSetComp -
ExprSlice -
ExprSubscript -
ExprTemplateStr -
ExprTuple -
ExprUnaryOp -
ExprVarKeyword -
ExprVarPositional -
ExprYield -
ExprYieldFrom
-
-
Reference
griffe- Agents
- Docstrings Docstring models
-
Expressions
-
ExprAttribute -
ExprBinOp -
ExprBoolOp -
ExprCall -
ExprCompare -
ExprComprehension -
ExprDict -
ExprDictComp -
ExprExtSlice -
ExprFormatted -
ExprGeneratorExp -
ExprIfExp -
ExprInterpolation -
ExprJoinedStr -
ExprKeyword -
ExprLambda -
ExprList -
ExprListComp -
ExprNamedExpr -
ExprParameter -
ExprSet -
ExprSetComp -
ExprSlice -
ExprSubscript -
ExprTemplateStr -
ExprTuple -
ExprUnaryOp -
ExprVarKeyword -
ExprVarPositional -
ExprYield -
ExprYieldFrom
-
- Models
-
Reference
griffe Expressions-
Expriterate -
ExprAttributeiterate -
ExprBinOpiterate -
ExprBoolOpiterate -
ExprCalliterate -
ExprCompareiterate -
ExprComprehensioniterate -
ExprConstantiterate -
ExprDictiterate -
ExprDictCompiterate -
ExprExtSliceiterate -
ExprFormattediterate -
ExprGeneratorExpiterate -
ExprIfExpiterate -
ExprInterpolationiterate -
ExprJoinedStriterate -
ExprKeyworditerate -
ExprLambdaiterate -
ExprListiterate -
ExprListCompiterate -
ExprNameiterate -
ExprNamedExpriterate -
ExprParameteriterate -
ExprSetiterate -
ExprSetCompiterate -
ExprSliceiterate -
ExprSubscriptiterate -
ExprTemplateStriterate -
ExprTupleiterate -
ExprUnaryOpiterate -
ExprVarKeyworditerate -
ExprVarPositionaliterate -
ExprYielditerate -
ExprYieldFromiterate
-
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprAttribute
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprAttribute[ExprAttribute]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprAttribute
click griffe.ExprAttribute href "" "griffe.ExprAttribute"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Attributes like a.b.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
append–Append a name to this attribute.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –The canonical path of this attribute.
-
classname(str) –The expression class name.
-
first(str | Expr) –The first part of this attribute (on the left).
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
last(ExprName) –The last part of this attribute (on the right).
-
path(str) –The path of this attribute.
-
values(list[str | Expr]) –The different parts of the dotted chain.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
append
¤
Append a name to this attribute.
Parameters:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
320 321 322 323 324 325 326 327 328 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
303 304 305 306 307 308 309 310 311 312 313 | |
modernize
¤
modernize() -> ExprName | ExprAttribute
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
315 316 317 318 | |
ExprBinOp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprBinOp[ExprBinOp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprBinOp
click griffe.ExprBinOp href "" "griffe.ExprBinOp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Binary operations like a + b.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
left(str | Expr) –Left part.
-
operator(str) –Binary operator.
-
path(str) –Path of the expressed name/attribute.
-
right(str | Expr) –Right part.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
364 365 366 367 368 369 370 371 372 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprBoolOp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprBoolOp[ExprBoolOp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprBoolOp
click griffe.ExprBoolOp href "" "griffe.ExprBoolOp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Boolean operations like a or b.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
operator(str) –Boolean operator.
-
path(str) –Path of the expressed name/attribute.
-
values(Sequence[str | Expr]) –Operands.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
384 385 386 387 388 389 390 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprCall
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprCall[ExprCall]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprCall
click griffe.ExprCall href "" "griffe.ExprCall"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Calls like f().
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
arguments(Sequence[str | Expr]) –Passed arguments.
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –The canonical path of this subscript's left part.
-
classname(str) –The expression class name.
-
function(Expr) –Function called.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
407 408 409 410 411 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprCompare
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprCompare[ExprCompare]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprCompare
click griffe.ExprCompare href "" "griffe.ExprCompare"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Comparisons like a > b.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
comparators(Sequence[str | Expr]) –Things compared.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
left(str | Expr) –Left part.
-
operators(Sequence[str]) –Comparison operators.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
425 426 427 428 429 430 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprComprehension
dataclass
¤
ExprComprehension(
target: str | Expr,
iterable: str | Expr,
conditions: Sequence[str | Expr],
is_async: bool = False,
)
Bases: Expr
flowchart TD
griffe.ExprComprehension[ExprComprehension]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprComprehension
click griffe.ExprComprehension href "" "griffe.ExprComprehension"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Comprehensions like a for b in c if d.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
conditions(Sequence[str | Expr]) –Conditions to include the target in the result.
-
is_async(bool) –Async comprehension or not.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
iterable(str | Expr) –Value iterated on.
-
path(str) –Path of the expressed name/attribute.
-
target(str | Expr) –Comprehension target (value added to the result).
conditions
instance-attribute
¤
Conditions to include the target in the result.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
446 447 448 449 450 451 452 453 454 455 456 457 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprConstant
dataclass
¤
ExprConstant(value: str)
Bases: Expr
flowchart TD
griffe.ExprConstant[ExprConstant]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprConstant
click griffe.ExprConstant href "" "griffe.ExprConstant"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Constants like "a" or 1.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
value(str) –Constant value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
471 472 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprDict
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprDict[ExprDict]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprDict
click griffe.ExprDict href "" "griffe.ExprDict"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Dictionaries like {"a": 0}.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
keys(Sequence[str | Expr | None]) –Dict keys.
-
path(str) –Path of the expressed name/attribute.
-
values(Sequence[str | Expr]) –Dict values.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprDictComp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprDictComp[ExprDictComp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprDictComp
click griffe.ExprDictComp href "" "griffe.ExprDictComp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Dict comprehensions like {k: v for k, v in a}.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
generators(Sequence[Expr]) –Generators iterated on.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
key(str | Expr) –Target key.
-
path(str) –Path of the expressed name/attribute.
-
value(str | Expr | None) –Target value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
511 512 513 514 515 516 517 518 519 520 521 522 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprExtSlice
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprExtSlice[ExprExtSlice]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprExtSlice
click griffe.ExprExtSlice href "" "griffe.ExprExtSlice"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Extended slice like a[x:y, z].
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
dims(Sequence[str | Expr]) –Dims.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
532 533 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprFormatted
dataclass
¤
ExprFormatted(
value: str | Expr,
conversion: str | None = None,
format_spec: Sequence[str | Expr] | None = None,
)
Bases: Expr
flowchart TD
griffe.ExprFormatted[ExprFormatted]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprFormatted
click griffe.ExprFormatted href "" "griffe.ExprFormatted"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Formatted string like {1 + 1}.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
conversion(str | None) –Conversion flag (
s,rora), without the leading exclamation mark. -
format_spec(Sequence[str | Expr] | None) –Format specifier parts: literal strings and interpolated expressions.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
value(str | Expr) –Formatted value.
conversion
class-attribute
instance-attribute
¤
conversion: str | None = None
Conversion flag (s, r or a), without the leading exclamation mark.
format_spec
class-attribute
instance-attribute
¤
Format specifier parts: literal strings and interpolated expressions.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
586 587 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprGeneratorExp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprGeneratorExp[ExprGeneratorExp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprGeneratorExp
click griffe.ExprGeneratorExp href "" "griffe.ExprGeneratorExp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Generator expressions like (a for b in c for d in e).
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
element(str | Expr) –Yielded element.
-
generators(Sequence[Expr]) –Generators iterated on.
-
implicit(bool) –Whether the generator's parentheses are implicit (as the sole argument of a call).
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
implicit
class-attribute
instance-attribute
¤
implicit: bool = False
Whether the generator's parentheses are implicit (as the sole argument of a call).
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
601 602 603 604 605 606 607 608 609 610 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprIfExp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprIfExp[ExprIfExp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprIfExp
click griffe.ExprIfExp href "" "griffe.ExprIfExp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Conditions like a if b else c.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
body(str | Expr) –Value if test.
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
orelse(str | Expr) –Other expression.
-
path(str) –Path of the expressed name/attribute.
-
test(str | Expr) –Condition.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprInterpolation
dataclass
¤
ExprInterpolation(
value: str | Expr,
conversion: str | None = None,
format_spec: Sequence[str | Expr] | None = None,
)
Bases: Expr
flowchart TD
griffe.ExprInterpolation[ExprInterpolation]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprInterpolation
click griffe.ExprInterpolation href "" "griffe.ExprInterpolation"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Template string interpolation like {name}.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
conversion(str | None) –Conversion flag (
s,rora), without the leading exclamation mark. -
format_spec(Sequence[str | Expr] | None) –Format specifier parts: literal strings and interpolated expressions.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
value(str | Expr) –Interpolated value.
conversion
class-attribute
instance-attribute
¤
conversion: str | None = None
Conversion flag (s, r or a), without the leading exclamation mark.
format_spec
class-attribute
instance-attribute
¤
Format specifier parts: literal strings and interpolated expressions.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
653 654 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprJoinedStr
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprJoinedStr[ExprJoinedStr]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprJoinedStr
click griffe.ExprJoinedStr href "" "griffe.ExprJoinedStr"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Joined strings like f"a {b} c".
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
values(Sequence[str | Expr]) –Joined values.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
701 702 703 704 705 706 707 708 709 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprKeyword
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprKeyword[ExprKeyword]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprKeyword
click griffe.ExprKeyword href "" "griffe.ExprKeyword"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Keyword arguments like a=b.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed keyword.
-
classname(str) –The expression class name.
-
function(Expr | None) –Expression referencing the function called with this parameter.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
name(str) –Name.
-
path(str) –Path of the expressed name/attribute.
-
value(str | Expr) –Value.
function
class-attribute
instance-attribute
¤
function: Expr | None = None
Expression referencing the function called with this parameter.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
746 747 748 749 750 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprVarPositional
dataclass
¤
ExprVarPositional(value: Expr)
Bases: Expr
flowchart TD
griffe.ExprVarPositional[ExprVarPositional]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprVarPositional
click griffe.ExprVarPositional href "" "griffe.ExprVarPositional"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Variadic positional parameters like *args.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
value(Expr) –Starred value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
760 761 762 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprVarKeyword
dataclass
¤
ExprVarKeyword(value: Expr)
Bases: Expr
flowchart TD
griffe.ExprVarKeyword[ExprVarKeyword]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprVarKeyword
click griffe.ExprVarKeyword href "" "griffe.ExprVarKeyword"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Variadic keyword parameters like **kwargs.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
value(Expr) –Double-starred value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
772 773 774 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprLambda
dataclass
¤
ExprLambda(
parameters: Sequence[ExprParameter], body: str | Expr
)
Bases: Expr
flowchart TD
griffe.ExprLambda[ExprLambda]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprLambda
click griffe.ExprLambda href "" "griffe.ExprLambda"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Lambda expressions like lambda a: a.b.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
body(str | Expr) –Lambda's body.
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
parameters(Sequence[ExprParameter]) –Lambda's parameters.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprList
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprList[ExprList]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprList
click griffe.ExprList href "" "griffe.ExprList"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Lists like [0, 1, 2].
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
elements(Sequence[Expr]) –List elements.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
829 830 831 832 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprListComp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprListComp[ExprListComp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprListComp
click griffe.ExprListComp href "" "griffe.ExprListComp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
List comprehensions like [a for b in c].
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
element(str | Expr) –Target value.
-
generators(Sequence[Expr]) –Generators iterated on.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
844 845 846 847 848 849 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprName
dataclass
¤
ExprName(
name: str,
parent: str
| ExprName
| Module
| Class
| Function
| None = None,
member: str | None = None,
)
Bases: Expr
flowchart TD
griffe.ExprName[ExprName]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprName
click griffe.ExprName href "" "griffe.ExprName"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
This class represents a Python object identified by a name in a given scope.
- Changelog 0.33.0 - 2023-08-16 Breaking Changes
-
Reference
griffe Expressions-
Expriterate -
ExprAttributeiterate -
ExprBinOpiterate -
ExprBoolOpiterate -
ExprCalliterate -
ExprCompareiterate -
ExprComprehensioniterate -
ExprConstantiterate -
ExprDictiterate -
ExprDictCompiterate -
ExprExtSliceiterate -
ExprFormattediterate -
ExprGeneratorExpiterate -
ExprIfExpiterate -
ExprInterpolationiterate -
ExprJoinedStriterate -
ExprKeyworditerate -
ExprLambdaiterate -
ExprListiterate -
ExprListCompiterate -
ExprNameiterate -
ExprNamedExpriterate -
ExprParameteriterate -
ExprSetiterate -
ExprSetCompiterate -
ExprSliceiterate -
ExprSubscriptiterate -
ExprTemplateStriterate -
ExprTupleiterate -
ExprUnaryOpiterate -
ExprVarKeyworditerate -
ExprVarPositionaliterate -
ExprYielditerate -
ExprYieldFromiterate
-
Methods:
-
__eq__–Two name expressions are equal if they have the same
namevalue (parentis ignored). -
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –The canonical name (resolved one, not alias name).
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_enum_class(bool) –Whether this name resolves to an enumeration class.
-
is_enum_instance(bool) –Whether this name resolves to an enumeration instance.
-
is_enum_value(bool) –Whether this name resolves to an enumeration value.
-
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
is_type_parameter(bool) –Whether this name resolves to a type parameter.
-
member(str | None) –Member name (for resolution in its scope).
-
name(str) –Actual name.
-
parent(str | ExprName | Module | Class | Function | None) –Parent (for resolution in its scope).
-
path(str) –The full, resolved name.
-
resolved(Module | Class | None) –The resolved object this name refers to.
is_enum_instance
property
¤
is_enum_instance: bool
Whether this name resolves to an enumeration instance.
is_type_parameter
property
¤
is_type_parameter: bool
Whether this name resolves to a type parameter.
member
class-attribute
instance-attribute
¤
member: str | None = None
Member name (for resolution in its scope).
parent
class-attribute
instance-attribute
¤
Parent (for resolution in its scope).
path
property
¤
path: str
The full, resolved name.
If it was given when creating the name, return that. If a callable was given, call it and return its result. It the name cannot be resolved, return the source.
__eq__
¤
Two name expressions are equal if they have the same name value (parent is ignored).
Source code in packages/griffelib/src/griffe/_internal/expressions.py
863 864 865 866 867 | |
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
869 870 | |
modernize
¤
modernize() -> ExprName
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
872 873 874 875 | |
ExprNamedExpr
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprNamedExpr[ExprNamedExpr]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprNamedExpr
click griffe.ExprNamedExpr href "" "griffe.ExprNamedExpr"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Named/assignment expressions like a := b.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
target(Expr) –Target name.
-
value(str | Expr) –Value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
955 956 957 958 959 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprParameter
dataclass
¤
ExprParameter(
name: str,
kind: ParameterKind = positional_or_keyword,
annotation: Expr | None = None,
default: str | Expr | None = None,
)
Bases: Expr
flowchart TD
griffe.ExprParameter[ExprParameter]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprParameter
click griffe.ExprParameter href "" "griffe.ExprParameter"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Parameters in function signatures like a: int = 0.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
annotation(Expr | None) –Parameter type.
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
default(str | Expr | None) –Parameter default.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
kind(ParameterKind) –Parameter kind.
-
name(str) –Parameter name.
-
path(str) –Path of the expressed name/attribute.
kind
class-attribute
instance-attribute
¤
Parameter kind.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprSet
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprSet[ExprSet]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprSet
click griffe.ExprSet href "" "griffe.ExprSet"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Sets like {0, 1, 2}.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
elements(Sequence[str | Expr]) –Set elements.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
983 984 985 986 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprSetComp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprSetComp[ExprSetComp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprSetComp
click griffe.ExprSetComp href "" "griffe.ExprSetComp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Set comprehensions like {a for b in c}.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
element(str | Expr) –Target value.
-
generators(Sequence[Expr]) –Generators iterated on.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
998 999 1000 1001 1002 1003 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprSlice
dataclass
¤
ExprSlice(
lower: str | Expr | None = None,
upper: str | Expr | None = None,
step: str | Expr | None = None,
)
Bases: Expr
flowchart TD
griffe.ExprSlice[ExprSlice]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprSlice
click griffe.ExprSlice href "" "griffe.ExprSlice"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Slices like [a:b:c].
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
lower(str | Expr | None) –Lower bound.
-
path(str) –Path of the expressed name/attribute.
-
step(str | Expr | None) –Iteration step.
-
upper(str | Expr | None) –Upper bound.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprSubscript
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprSubscript[ExprSubscript]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprSubscript
click griffe.ExprSubscript href "" "griffe.ExprSubscript"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Subscripts like a[b].
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –The canonical path of this subscript's left part.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
left(str | Expr) –Left part.
-
path(str) –The path of this subscript's left part.
-
slice(str | Expr) –Slice part.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1038 1039 1040 1041 1042 1043 | |
modernize
¤
modernize() -> ExprBinOp | ExprSubscript
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 | |
ExprTemplateStr
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprTemplateStr[ExprTemplateStr]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprTemplateStr
click griffe.ExprTemplateStr href "" "griffe.ExprTemplateStr"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Template strings like t"a {name}".
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
values(Sequence[str | Expr]) –Joined values.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1078 1079 1080 1081 1082 1083 1084 1085 1086 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprTuple
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprTuple[ExprTuple]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprTuple
click griffe.ExprTuple href "" "griffe.ExprTuple"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Tuples like (0, 1, 2).
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
elements(Sequence[str | Expr]) –Tuple elements.
-
implicit(bool) –Whether the tuple is implicit (e.g. without parentheses in a subscript's slice).
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
implicit
class-attribute
instance-attribute
¤
implicit: bool = False
Whether the tuple is implicit (e.g. without parentheses in a subscript's slice).
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
modernize
¤
modernize() -> ExprTuple
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1113 1114 1115 1116 1117 | |
ExprUnaryOp
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprUnaryOp[ExprUnaryOp]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprUnaryOp
click griffe.ExprUnaryOp href "" "griffe.ExprUnaryOp"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Unary operations like -1.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
operator(str) –Unary operator.
-
path(str) –Path of the expressed name/attribute.
-
value(str | Expr) –Value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1129 1130 1131 1132 1133 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprYield
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprYield[ExprYield]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprYield
click griffe.ExprYield href "" "griffe.ExprYield"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Yield statements like yield a.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
value(str | Expr | None) –Yielded value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1155 1156 1157 1158 1159 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |
ExprYieldFrom
dataclass
¤
Bases: Expr
flowchart TD
griffe.ExprYieldFrom[ExprYieldFrom]
griffe._internal.expressions.Expr[Expr]
griffe._internal.expressions.Expr --> griffe.ExprYieldFrom
click griffe.ExprYieldFrom href "" "griffe.ExprYieldFrom"
click griffe._internal.expressions.Expr href "" "griffe._internal.expressions.Expr"
Yield statements like yield from a.
Methods:
-
__iter__–Iterate on the expression syntax and elements.
-
as_dict–Return the expression as a dictionary.
-
iterate–Iterate on the expression elements.
-
modernize–Modernize the expression.
Attributes:
-
canonical_name(str) –Name of the expressed name/attribute/parameter.
-
canonical_path(str) –Path of the expressed name/attribute.
-
classname(str) –The expression class name.
-
is_classvar(bool) –Whether this attribute is annotated with
ClassVar. -
is_generator(bool) –Whether this expression is a generator.
-
is_iterator(bool) –Whether this expression is an iterator.
-
is_tuple(bool) –Whether this expression is a tuple.
-
path(str) –Path of the expressed name/attribute.
-
value(str | Expr) –Yielded-from value.
__iter__
¤
Iterate on the expression syntax and elements.
Source code in packages/griffelib/src/griffe/_internal/expressions.py
193 194 195 | |
as_dict
¤
Return the expression as a dictionary.
Parameters:
Returns:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
226 227 228 229 230 231 232 233 234 235 236 | |
iterate
¤
Iterate on the expression elements.
Parameters:
-
(flat¤bool, default:True) –Expressions are trees.
When flat is false, this method iterates only on the first layer of the tree. To iterate on all the subparts of the expression, you have to do so recursively. It allows to handle each subpart specifically (for example subscripts, attribute, etc.), without them getting rendered as strings.
On the contrary, when flat is true, the whole tree is flattened as a sequence of strings and instances of Names.
Yields:
Source code in packages/griffelib/src/griffe/_internal/expressions.py
1169 1170 1171 | |
modernize
¤
modernize() -> Expr
Modernize the expression.
For example, use PEP 604 type unions | instead of typing.Union.
Returns:
-
Expr–A modernized expression.
- Guide User guide Manipulating APIs Navigating APIs Expressions Modernization
Source code in packages/griffelib/src/griffe/_internal/expressions.py
216 217 218 219 220 221 222 223 224 | |