Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions classes/_typeclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@

.. code:: python

>>> from typing_extensions import Protocol
>>> from typing_extensions import Protocol, runtime_checkable

>>> class CustomProtocol(Protocol):
>>> @runtime_checkable
... class CustomProtocol(Protocol):
... field: str

>>> @example.instance(protocol=CustomProtocol)
Expand Down
15 changes: 1 addition & 14 deletions classes/contrib/mypy/typeops/call_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mypy.typeops import get_type_vars, make_simplified_union
from mypy.types import CallableType, Instance, ProperType
from mypy.types import Type as MypyType
from mypy.types import TypeVarDef, TypeVarId, TypeVarType, union_items
from mypy.types import TypeVarType, union_items
from typing_extensions import Final, final

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


def _find_callable_variable(
var_id: TypeVarId,
signature: CallableType,
) -> TypeVarDef:
var_def = next(
var_def
for var_def in signature.variables
if var_def.id == var_id
)
assert isinstance(var_def, TypeVarDef)
return var_def


def _load_supports_type(
first_arg: MypyType,
associated_type: Instance,
Expand Down
2 changes: 1 addition & 1 deletion classes/contrib/mypy/typeops/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def type_obj(type_: MypyType) -> MypyType:
# however we still use `ret_type`,
# because it is practically the same thing,
# but with proper type arguments.
return type_.items()[0].ret_type
return type_.items[0].ret_type
return type_


Expand Down
9 changes: 4 additions & 5 deletions classes/contrib/mypy/typeops/mro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from mypy.subtypes import is_equivalent
from mypy.types import Instance
from mypy.types import Type as MypyType
from mypy.types import TypeVarType, UnionType, union_items
from mypy.types import UnionType, union_items
from typing_extensions import final

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

return type_loader.load_supports_type(
supports_spec,
Expand Down
Loading