class documentation
class Parser: (source)
Object to keep track of parsed modules and inferred nodes.
Method | __init__ |
Undocumented |
Method | add |
Add a module to the parser and make compatible with astuce inference system. |
Method | invalidate |
Clears the inference cache. |
Method | parse |
Parse the python source string into a ast.Module instance, and make compatible with astuce inference system. |
Method | unparse |
Unparse an ast.AST object and generate a code string. |
Class Variable | max |
Undocumented |
Instance Variable | modules |
The parsed modules. |
Method | _init |
A method that must be called for all nodes in the tree as well as inferred (created) nodes. |
Method | _new |
Create a fresh inference context. |
Instance Variable | _assignattr |
A list to store assignments to attributes. |
Instance Variable | _inference |
Inferred node contexts to their mapped results. |
Instance Variable | _wildcard |
Store wildcard ImportFrom to resolve them after building. |
Add a module to the parser and make compatible with astuce inference system.
This method will apply a set of harmless transformations:
__all__.extend(a) -> __all__ += a __all__.append(a) -> __all__ += [a]
Parameters | |
mod:ast.Module | Undocumented |
modname:str | Undocumented |
isbool | Undocumented |
**kw:Any | Undocumented |
Returns | |
_typing.Module | Undocumented |
Parse the python source string into a ast.Module
instance, and make compatible with astuce inference system.
- source
- The python code string.
- modname
- The full name of the module, required.
This additional argument is the only breaking changed compared to
ast.parse
. - is_package
- Whether this module is package.
- kw
Other arguments are passed to the
ast.parse
function directly. Including:- filename: The filename where we can find the module source
- (only used for error messages)
Parameters | |
source:str | Undocumented |
modname:str | Undocumented |
isbool | Undocumented |
**kw:Any | Undocumented |
Returns | |
_typing.Module | Undocumented |
Unknown Field: newfield | |
parameters | Parameters |
Unknown Field: parameters | |
Inferred node contexts to their mapped results.
The keys are nodes and the value is tuple of the inferred results.
See Also | |
InferenceContext._cache |