class SuggestionEngine: (source)
Method | __init__ |
Undocumented |
Method | add_adjustments |
Undocumented |
Method | ensure_loaded |
Make sure that the module represented by state is fully loaded. |
Method | extract_from_decorator |
Undocumented |
Method | filter_options |
Apply any configured filters to the possible guesses. |
Method | find_best |
From a list of possible function types, find the best one. |
Method | find_node |
From a target name, return module/target names and the func def. |
Method | find_node_by_file_and_line |
Find symbol node by path to file and line number. |
Method | find_node_by_module_and_name |
Find symbol node by module id and qualified name. |
Method | format_args |
Undocumented |
Method | format_signature |
Format a callable type in a way suitable as an annotation... kind of |
Method | format_type |
Undocumented |
Method | get_args |
Produce a list of type suggestions for each argument type. |
Method | get_callsites |
Find all call sites of a function. |
Method | get_default_arg_types |
Undocumented |
Method | get_guesses |
Compute a list of guesses for a function's type. |
Method | get_guesses_from_parent |
Try to get a guess of a method type from a parent class. |
Method | get_starting_type |
Undocumented |
Method | get_suggestion |
Compute a suggestion for a function. |
Method | get_trivial_type |
Generate a trivial callable type from a func def, with all Anys |
Method | json_suggestion |
Produce a json blob for a suggestion suitable for application by pyannotate. |
Method | named_type |
Undocumented |
Method | pyannotate_signature |
Format a callable type as a pyannotate dict |
Method | reload |
Recheck the module given by state. |
Method | restore_after |
Context manager that reloads a module after executing the body. |
Method | score_callable |
Undocumented |
Method | score_type |
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_callsites |
Find a list of call sites of function. |
Method | try_type |
Recheck a function while assuming it has type typ. |
Method | with_export_types |
Context manager that enables the export_types flag in the body. |
Instance Variable | fgmanager |
Undocumented |
Instance Variable | finder |
Undocumented |
Instance Variable | flex_any |
Undocumented |
Instance Variable | give_json |
Undocumented |
Instance Variable | graph |
Undocumented |
Instance Variable | manager |
Undocumented |
Instance Variable | max_guesses |
Undocumented |
Instance Variable | no_errors |
Undocumented |
Instance Variable | plugin |
Undocumented |
Instance Variable | try_text |
Undocumented |
Instance Variable | use_fixme |
Undocumented |
Undocumented
Parameters | |
fgmanager:FineGrainedBuildManager | Undocumented |
json:bool | Undocumented |
no_errors:bool | Undocumented |
no_any:bool | Undocumented |
try_text:bool | Undocumented |
flex_any:Optional[ | Undocumented |
use_fixme:Optional[ | Undocumented |
max_guesses:Optional[ | Undocumented |
Apply any configured filters to the possible guesses.
Currently the only option is filtering based on Any prevalance.
Parameters | |
guesses:List[ | Undocumented |
is_method:bool | Undocumented |
ignore_return:bool | Undocumented |
Returns | |
List[ | Undocumented |
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.
Parameters | |
func:FuncDef | Undocumented |
guesses:List[ | Undocumented |
Returns | |
Tuple[ | Undocumented |
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
Parameters | |
key:str | Undocumented |
Returns | |
Tuple[ | Undocumented |
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.
Parameters | |
file:str | Undocumented |
line:int | Undocumented |
Returns | |
Tuple[ | Undocumented |
Find symbol node by module id and qualified name.
Raise SuggestionFailure if can't find one.
Parameters | |
modname:str | Undocumented |
tail:str | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
sig:PyAnnotateSignature | Undocumented |
Returns | |
str | Undocumented |
Undocumented
Parameters | |
cur_module:Optional[ | Undocumented |
typ:Type | Undocumented |
Returns | |
str | Undocumented |
Parameters | |
is_method:bool | Undocumented |
base:CallableType | Undocumented |
defaults:List[ | Undocumented |
callsites:List[ | Undocumented |
uses:List[ | Undocumented |
Returns | |
List[ | Undocumented |
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.
Parameters | |
is_method:bool | Undocumented |
base:CallableType | Undocumented |
defaults:List[ | Undocumented |
callsites:List[ | Undocumented |
uses:List[ | Undocumented |
Returns | |
List[ | Undocumented |
Parameters | |
node:FuncDef | Undocumented |
Returns | |
List[ | Undocumented |
Compute a suggestion for a function.
Return the type and whether the first argument should be ignored.
Parameters | |
mod:str | Undocumented |
node:FuncDef | Undocumented |
Returns | |
PyAnnotateSignature | Undocumented |
Parameters | |
fdef:FuncDef | Undocumented |
Returns | |
CallableType | Undocumented |
Parameters | |
mod:str | Undocumented |
func_name:str | Undocumented |
node:FuncDef | Undocumented |
suggestion:PyAnnotateSignature | Undocumented |
Returns | |
str | Undocumented |
Parameters | |
cur_module:Optional[ | Undocumented |
is_method:bool | Undocumented |
typ:CallableType | Undocumented |
Returns | |
PyAnnotateSignature | Undocumented |
Recheck the module given by state.
If check_errors is true, raise an exception if there are errors.
Parameters | |
state:State | Undocumented |
check_errors:bool | Undocumented |
Returns | |
List[ | Undocumented |
Context manager that reloads a module after executing the body.
This should undo any damage done to the module state while mucking around.
Parameters | |
module:str | Undocumented |
Returns | |
Iterator[ | Undocumented |
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.
Parameters | |
t:Type | Undocumented |
arg_pos:bool | Undocumented |
Returns | |
int | Undocumented |
Recheck a function while assuming it has type typ.
Return all error messages.
Parameters | |
func:FuncDef | Undocumented |
typ:ProperType | Undocumented |
Returns | |
List[ | Undocumented |