Add explanation of the parameters to _infer_type_vars

This commit is contained in:
Peter Law
2020-03-07 16:31:12 +00:00
parent f1a9e681ad
commit 54e29eede1

View File

@@ -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__()