class SuggestionEngine: (source)
Engine for finding call sites and suggesting signatures.
Method | __init__ |
Undocumented |
Method | ensure |
Make sure that the module represented by state is fully loaded. |
Method | extract |
Undocumented |
Method | filter |
Apply any configured filters to the possible guesses. |
Method | find |
From a list of possible function types, find the best one. |
Method | find |
From a target name, return module/target names and the func def. |
Method | find |
Find symbol node by path to file and line number. |
Method | find |
Find symbol node by module id and qualified name. |
Method | format |
Undocumented |
Method | format |
Format a callable type in a way suitable as an annotation... kind of |
Method | format |
Undocumented |
Method | get |
Produce a list of type suggestions for each argument type. |
Method | get |
Find all call sites of a function. |
Method | get |
Undocumented |
Method | get |
Compute a list of guesses for a function's type. |
Method | get |
Try to get a guess of a method type from a parent class. |
Method | get |
Undocumented |
Method | get |
Compute a suggestion for a function. |
Method | get |
Generate a trivial callable type from a func def, with all Anys |
Method | json |
Produce a json blob for a suggestion suitable for application by pyannotate. |
Method | named |
Undocumented |
Method | pyannotate |
Format a callable type as a pyannotate dict |
Method | reload |
Recheck the module given by state. |
Method | restore |
Context manager that reloads a module after executing the body. |
Method | score |
Undocumented |
Method | score |
Generate a score for a type that we use to pick which type to use. |
Method | suggest |
Suggest an inferred type for function. |
Method | suggest |
Find a list of call sites of function. |
Method | try |
Recheck a function while assuming it has type typ. |
Method | with |
Context manager that enables the export_types flag in the body. |
Instance Variable | fgmanager |
Undocumented |
Instance Variable | finder |
Undocumented |
Instance Variable | flex |
Undocumented |
Instance Variable | give |
Undocumented |
Instance Variable | graph |
Undocumented |
Instance Variable | manager |
Undocumented |
Instance Variable | max |
Undocumented |
Instance Variable | no |
Undocumented |
Instance Variable | plugin |
Undocumented |
Instance Variable | use |
Undocumented |
FineGrainedBuildManager
, *, json: bool
, no_errors: bool
= False, no_any: bool
= False, flex_any: float|None
= None, use_fixme: str|None
= None, max_guesses: int|None
= None):
(source)
¶
Undocumented
list[ CallableType]
, is_method: bool
, ignore_return: bool
) -> list[ CallableType]
:
(source)
¶
Apply any configured filters to the possible guesses. Currently the only option is filtering based on Any prevalance.
FuncDef
, guesses: list[ CallableType]
) -> tuple[ CallableType, int]
:
(source)
¶
From a list of possible function types, find the best one. For best, we want the fewest errors, then the best "score" from score_callable.
From a target name, return module/target names and the func def. The 'key' argument can be in one of two formats: * As the function full name, e.g., package.module.Cls.method * As the function location as file and line separated by column, e.g., path/to/file.py:42
Find symbol node by path to file and line number. Find the first function declared *before or on* the line number. Return module id and the node found. Raise SuggestionFailure if can't find one.
list[ list[ ArgKind]]
, arg_names: list[ list[ str|None]]
, arg_types: list[ list[ Type]]
) -> str
:
(source)
¶
Undocumented
bool
, base: CallableType
, defaults: list[ Type|None]
, callsites: list[ Callsite]
, uses: list[ list[ Type]]
) -> list[ list[ Type]]
:
(source)
¶
Produce a list of type suggestions for each argument type.
bool
, base: CallableType
, defaults: list[ Type|None]
, callsites: list[ Callsite]
, uses: list[ list[ Type]]
) -> list[ CallableType]
:
(source)
¶
Compute a list of guesses for a function's type. This focuses just on the argument types, and doesn't change the provided return type.
Compute a suggestion for a function. Return the type and whether the first argument should be ignored.
str
, func_name: str
, node: FuncDef
, suggestion: PyAnnotateSignature
) -> str
:
(source)
¶
Produce a json blob for a suggestion suitable for application by pyannotate.
str|None
, is_method: bool
, typ: CallableType
) -> PyAnnotateSignature
:
(source)
¶
Format a callable type as a pyannotate dict
Context manager that reloads a module after executing the body. This should undo any damage done to the module state while mucking around.
Generate a score for a type that we use to pick which type to use. Lower is better, prefer non-union/non-any types. Don't penalize optionals.