Skip to content

Commit 0304843

Browse files
authored
Fixes plugin to work with mypy@0.920 (#340)
* Fixes plugin to work with mypy@0.920 * Fixes plugin to work with mypy@0.920 * Fixes
1 parent 4d6c975 commit 0304843

File tree

6 files changed

+32
-95
lines changed

6 files changed

+32
-95
lines changed

classes/_typeclass.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@
9595
9696
.. code:: python
9797
98-
>>> from typing_extensions import Protocol
98+
>>> from typing_extensions import Protocol, runtime_checkable
9999
100-
>>> class CustomProtocol(Protocol):
100+
>>> @runtime_checkable
101+
... class CustomProtocol(Protocol):
101102
... field: str
102103
103104
>>> @example.instance(protocol=CustomProtocol)

classes/contrib/mypy/typeops/call_signatures.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from mypy.typeops import get_type_vars, make_simplified_union
77
from mypy.types import CallableType, Instance, ProperType
88
from mypy.types import Type as MypyType
9-
from mypy.types import TypeVarDef, TypeVarId, TypeVarType, union_items
9+
from mypy.types import TypeVarType, union_items
1010
from typing_extensions import Final, final
1111

1212
from classes.contrib.mypy.typeops import type_loader
@@ -98,19 +98,6 @@ def _infer_regular(self, first_arg: MypyType) -> CallableType:
9898
return self._signature
9999

100100

101-
def _find_callable_variable(
102-
var_id: TypeVarId,
103-
signature: CallableType,
104-
) -> TypeVarDef:
105-
var_def = next(
106-
var_def
107-
for var_def in signature.variables
108-
if var_def.id == var_id
109-
)
110-
assert isinstance(var_def, TypeVarDef)
111-
return var_def
112-
113-
114101
def _load_supports_type(
115102
first_arg: MypyType,
116103
associated_type: Instance,

classes/contrib/mypy/typeops/inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def type_obj(type_: MypyType) -> MypyType:
9191
# however we still use `ret_type`,
9292
# because it is practically the same thing,
9393
# but with proper type arguments.
94-
return type_.items()[0].ret_type
94+
return type_.items[0].ret_type
9595
return type_
9696

9797

classes/contrib/mypy/typeops/mro.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from mypy.subtypes import is_equivalent
55
from mypy.types import Instance
66
from mypy.types import Type as MypyType
7-
from mypy.types import TypeVarType, UnionType, union_items
7+
from mypy.types import UnionType, union_items
88
from typing_extensions import final
99

1010
from classes.contrib.mypy.typeops import type_loader
@@ -199,10 +199,9 @@ def _load_supports_type(
199199
# Because `mypy` requires `type_var.id` to match,
200200
# otherwise, they would be treated as different variables.
201201
# That's why we copy the typevar definition from instance itself.
202-
supports_spec = associated_type.copy_modified(args=[
203-
TypeVarType(var_def)
204-
for var_def in instance_type.type.defn.type_vars
205-
])
202+
supports_spec = associated_type.copy_modified(
203+
args=instance_type.type.defn.type_vars,
204+
)
206205

207206
return type_loader.load_supports_type(
208207
supports_spec,

0 commit comments

Comments
 (0)