From 54e29eede19947c27f63cfa7929e23d47327b135 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 7 Mar 2020 16:31:12 +0000 Subject: [PATCH] Add explanation of the parameters to `_infer_type_vars` --- jedi/inference/gradual/annotation.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index 0e8582ee..31b36ae1 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -331,6 +331,27 @@ def _infer_type_vars(annotation_value, value_set, is_class_value=False): This functions would generate `int` for `_T` in this case, because it unpacks the `Iterable`. + + Parameters + ---------- + + `annotation_value`: represents the annotation of the current parameter to + infer the value for. In the above example, this would initially be the + `Iterable[_T]` of the `iterable` parameter and then, when recursing, + just the `_T` generic parameter. + + `value_set`: represents the actual argument passed to the parameter we're + inferrined for, or (for recursive calls) their types. In the above + example this would first be the representation of the list `[1]` and + then, when recursing, just of `1`. + + `is_class_value`: tells us whether or not to treat the `value_set` as + representing the instances or types being passed, which is neccesary to + correctly cope with `Type[T]` annotations. When it is True, this means + that we are being called with a nested portion of an annotation and that + the `value_set` represents the types of the arguments, rather than their + actual instances. + Note: not all recursive calls will neccesarily set this to True. """ type_var_dict = {} annotation_name = annotation_value.py__name__()