Utilities for checking function overrides used in vm.py.
Class |
|
Undocumented |
Class |
|
Constants representing various signature mismatch errors. |
Function | check |
Check that the method signatures of the new class match base classes. |
Constant | SIGNATURE |
Undocumented |
Variable | log |
Undocumented |
Function | _check |
Checks that default parameter values of the overriding method match. |
Function | _check |
Checks that the keyword-only parameters of the overriding method match. |
Function | _check |
Checks type annotations for positional parameters of the overriding method. |
Function | _check |
Checks that the positional parameters of the overriding method match. |
Function | _check |
Checks that the return types match. |
Function | _check |
Checks if the signatures match for the overridden and overriding methods. |
Function | _get |
Returns a map from method names to signatures for a ParameterizedClass. |
Function | _get |
Returns a map from method names to their signatures for a PyTDClass. |
Function | _get |
Returns the type annotation for the varargs parameter. |
Type Alias | _ |
Undocumented |
Undocumented
Value |
|
Checks that default parameter values of the overriding method match. Args: method_signature: signature of the overriding method. base_signature: signature of the overridden method. Returns: SignatureError if a mismatch is detected. Otherwise returns None.
Checks that the keyword-only parameters of the overriding method match. Args: method_signature: signature of the overriding method. base_signature: signature of the overridden method. is_subtype: a binary function to compare types. Returns: SignatureError if a mismatch is detected. Otherwise returns None.
Checks type annotations for positional parameters of the overriding method. Args: method_signature: signature of the overriding method. base_signature: signature of the overridden method. is_subtype: a binary function to compare types. Returns: SignatureError if a mismatch is detected. Otherwise returns None.
Checks that the positional parameters of the overriding method match. Args: method_signature: signature of the overriding method. base_signature: signature of the overridden method. is_subtype: a binary function to compare types. Returns: SignatureError if a mismatch is detected. Otherwise returns None.
Checks if the signatures match for the overridden and overriding methods. Adds the first error found to the context's error log. Two invariants are verified: 1. Every call that is valid for the overridden method is valid for the overriding method. 2. Two calls that are equivalent for the overridden method are equivalent for the overriding method. This translates into the following mapping requirements for overriding method parameters: +----------------------------------------------------------------------------+ | Overridden method | Overriding method | +----------------------------------------------------------------------------+ | Positional-only | Positional-only or | | | positional-or-keyword, any name | +--------------------------------------+-------------------------------------+ | Positional-or-keyword | Positional-or-keyword, same name | +--------------------------------------+-------------------------------------+ | Keyword-only | Positional-or-keyword | | | or keyword-only, same name | +--------------------------------------+-------------------------------------+ | Non-default | Non-default or default | +--------------------------------------+-------------------------------------+ | Default | Default, same default value | +--------------------------------------+-------------------------------------+ | Parameter of type T | Parameter of supertype of T or | | | no annotation | +--------------------------------------+-------------------------------------+ | Parameter without annotation | Parameter with any type annotation | | | or without annotation | +--------------------------------------+-------------------------------------+ | Return type T | Return type - subtype of T or | | | no annotation | +--------------------------------------+-------------------------------------+ | Return type not annotated | Any return type annotation | | | or no annotation | +--------------------------------------+-------------------------------------+ In addition, default parameters of the overriding method don't have to match any parameters of the overridden method. Same name requirement is often violated, so we don't treat is as an error for now and only log a warning. Arguments: method_signature: signature of the overriding method. base_signature: signature of the overridden method. stack: the stack to use for mismatch error reporting. matcher: abstract matcher for type comparison. ctx: pytype abstract context.
abstract.ParameterizedClass
, ctx: _ContextType
) -> _SignatureMapType
:
(source)
¶
Returns a map from method names to signatures for a ParameterizedClass.
abstract.PyTDClass
, ctx: _ContextType
) -> _SignatureMapType
:
(source)
¶
Returns a map from method names to their signatures for a PyTDClass.