utils ¤
This module contains utilities for docstrings parsers.
Functions:
-
parse_annotation
–Parse a string into a true name or expression that can be resolved later.
-
warning
–Create and return a warn function.
parse_annotation ¤
parse_annotation(
annotation: str,
docstring: Docstring,
log_level: LogLevel = error,
) -> str | Expr
Parse a string into a true name or expression that can be resolved later.
Parameters:
-
annotation
(str
) –The annotation to parse.
-
docstring
(Docstring
) –The docstring in which the annotation appears. The docstring's parent is accessed to bind a resolver to the resulting name/expression.
-
log_level
(LogLevel
, default:error
) –Log level to use to log a message.
Returns:
warning ¤
warning(name: str) -> WarningCallable
Create and return a warn function.
Parameters:
-
name
(str
) –The logger name.
Returns:
-
WarningCallable
–A function used to log parsing warnings.
This function logs a warning message by prefixing it with the filepath and line number.
Parameters of the returned function: