MCPcopy
hub / github.com/python/mypy / SubtypeContext

Class SubtypeContext

mypy/subtypes.py:90–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88
89
90class SubtypeContext:
91 def __init__(
92 self,
93 *,
94 # Non-proper subtype flags
95 ignore_type_params: bool = False,
96 ignore_pos_arg_names: bool = False,
97 ignore_declared_variance: bool = False,
98 # Supported for both proper and non-proper
99 always_covariant: bool = False,
100 ignore_promotions: bool = False,
101 # Proper subtype flags
102 erase_instances: bool = False,
103 keep_erased_types: bool = False,
104 options: Options | None = None,
105 ) -> None:
106 self.ignore_type_params = ignore_type_params
107 self.ignore_pos_arg_names = ignore_pos_arg_names
108 self.ignore_declared_variance = ignore_declared_variance
109 self.always_covariant = always_covariant
110 self.ignore_promotions = ignore_promotions
111 self.erase_instances = erase_instances
112 self.keep_erased_types = keep_erased_types
113 self.options = options
114
115 def check_context(self, proper_subtype: bool) -> None:
116 # Historically proper and non-proper subtypes were defined using different helpers
117 # and different visitors. Check if flag values are such that we definitely support.
118 if proper_subtype:
119 assert not self.ignore_pos_arg_names and not self.ignore_declared_variance
120 else:
121 assert not self.erase_instances and not self.keep_erased_types
122
123
124def is_subtype(

Callers 4

join_instancesMethod · 0.90
is_subtypeFunction · 0.85
is_proper_subtypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…