for member in removals:
remover(member)
- def __ior__(
+ def __ior__( # type: ignore
self: Self, other: AbstractSet[_S]
) -> MutableSet[Union[_T, _S]]:
if not collections._set_binops_check_strict(self, other):
for value in add:
self.add(value)
- def __ixor__(self, other: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]:
+ def __ixor__(self, other: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: # type: ignore # noqa: E501
if not collections._set_binops_check_strict(self, other):
raise NotImplementedError()
assert x is self, "generative methods must return self"
return self
- decorated = _generative(fn) # type: ignore
+ decorated = _generative(fn)
decorated.non_generative = fn # type: ignore
- return decorated # type: ignore
+ return decorated
def _exclusive_against(*names: str, **kw: Any) -> Callable[[_Fn], _Fn]:
self._index[k] = col
self._collection.append((k, col))
self._colset.update(c for (k, c) in self._collection)
+
+ # https://github.com/python/mypy/issues/12610
self._index.update(
- (idx, c) for idx, (k, c) in enumerate(self._collection)
+ (idx, c) for idx, (k, c) in enumerate(self._collection) # type: ignore # noqa: E501
)
for col in replace_col:
self.replace(col)
self._collection[:] = [
(k, c) for (k, c) in self._collection if c is not column
]
+
+ # https://github.com/python/mypy/issues/12610
self._index.update(
- {idx: col for idx, (k, col) in enumerate(self._collection)}
+ {idx: col for idx, (k, col) in enumerate(self._collection)} # type: ignore # noqa: E501
)
# delete higher index
del self._index[len(self._collection)]
self._collection[:] = new_cols
self._index.clear()
+
+ # https://github.com/python/mypy/issues/12610
self._index.update(
- {idx: col for idx, (k, col) in enumerate(self._collection)}
+ {idx: col for idx, (k, col) in enumerate(self._collection)} # type: ignore # noqa: E501
)
self._index.update(self._collection)
def __iter__(self) -> Iterator[_T]:
return iter(self._list)
- def __add__(self, other: Iterator[_T]) -> "OrderedSet[_T]":
+ def __add__(self, other: Iterator[_T]) -> OrderedSet[_T]:
return self.union(other)
def __repr__(self) -> str:
self._list.append(e)
super().add(e)
- def __ior__(self, other: AbstractSet[_S]) -> "OrderedSet[Union[_T, _S]]":
+ def __ior__(self, other: AbstractSet[_S]) -> OrderedSet[Union[_T, _S]]:
self.update(other) # type: ignore
return self # type: ignore
- def union(self, *other: Iterable[_S]) -> "OrderedSet[Union[_T, _S]]":
- result: "OrderedSet[Union[_T, _S]]" = self.__class__(self) # type: ignore # noqa: E501
+ def union(self, *other: Iterable[_S]) -> OrderedSet[Union[_T, _S]]:
+ result: OrderedSet[Union[_T, _S]] = self.__class__(self) # type: ignore # noqa: E501
for o in other:
result.update(o)
return result
- def __or__(self, other: AbstractSet[_S]) -> "OrderedSet[Union[_T, _S]]":
+ def __or__(self, other: AbstractSet[_S]) -> OrderedSet[Union[_T, _S]]:
return self.union(other)
- def intersection(self, *other: Iterable[Any]) -> "OrderedSet[_T]":
+ def intersection(self, *other: Iterable[Any]) -> OrderedSet[_T]:
other_set: Set[Any] = set()
other_set.update(*other)
return self.__class__(a for a in self if a in other_set)
- def __and__(self, other: AbstractSet[object]) -> "OrderedSet[_T]":
+ def __and__(self, other: AbstractSet[object]) -> OrderedSet[_T]:
return self.intersection(other)
- def symmetric_difference(self, other: Iterable[_T]) -> "OrderedSet[_T]":
+ def symmetric_difference(self, other: Iterable[_T]) -> OrderedSet[_T]:
other_set = other if isinstance(other, set) else set(other)
result = self.__class__(a for a in self if a not in other_set)
result.update(a for a in other if a not in self)
return result
- def __xor__(self, other: AbstractSet[_S]) -> "OrderedSet[Union[_T, _S]]":
- return cast("OrderedSet[Union[_T, _S]]", self).symmetric_difference(
+ def __xor__(self, other: AbstractSet[_S]) -> OrderedSet[Union[_T, _S]]:
+ return cast(OrderedSet[Union[_T, _S]], self).symmetric_difference(
other
)
- def difference(self, *other: Iterable[Any]) -> "OrderedSet[_T]":
+ def difference(self, *other: Iterable[Any]) -> OrderedSet[_T]:
other_set = super().difference(*other)
return self.__class__(a for a in self._list if a in other_set)
- def __sub__(self, other: AbstractSet[Optional[_T]]) -> "OrderedSet[_T]":
+ def __sub__(self, other: AbstractSet[Optional[_T]]) -> OrderedSet[_T]:
return self.difference(other)
def intersection_update(self, *other: Iterable[Any]) -> None:
super().intersection_update(*other)
self._list = [a for a in self._list if a in self]
- def __iand__(self, other: AbstractSet[object]) -> "OrderedSet[_T]":
+ def __iand__(self, other: AbstractSet[object]) -> OrderedSet[_T]:
self.intersection_update(other)
return self
self._list = [a for a in self._list if a in self]
self._list += [a for a in other if a in self]
- def __ixor__(self, other: AbstractSet[_S]) -> "OrderedSet[Union[_T, _S]]":
+ def __ixor__(self, other: AbstractSet[_S]) -> OrderedSet[Union[_T, _S]]:
self.symmetric_difference_update(other)
- return cast("OrderedSet[Union[_T, _S]]", self)
+ return cast(OrderedSet[Union[_T, _S]], self)
def difference_update(self, *other: Iterable[Any]) -> None:
super().difference_update(*other)
self._list = [a for a in self._list if a in self]
- def __isub__(self, other: AbstractSet[Optional[_T]]) -> "OrderedSet[_T]":
+ def __isub__(self, other: AbstractSet[Optional[_T]]) -> OrderedSet[_T]: # type: ignore # noqa: E501
self.difference_update(other)
return self
import textwrap
import threading
import types
-import typing
from typing import Any
from typing import Callable
from typing import cast
from . import _collections
from . import compat
-from . import typing as compat_typing
from ._has_cy import HAS_CYEXTENSION
+from .typing import Literal
from .. import exc
_T = TypeVar("_T")
n ^= b
-_Fn = typing.TypeVar("_Fn", bound=typing.Callable[..., Any])
-_Args = compat_typing.ParamSpec("_Args")
+_Fn = TypeVar("_Fn", bound="Callable[..., Any]")
-def decorator(
- target: typing.Callable[ # type: ignore
- compat_typing.Concatenate[_Fn, _Args], typing.Any
- ]
-) -> _Fn:
+def decorator(target: Callable[..., Any]) -> Callable[[_Fn], _Fn]:
"""A signature-matching decorator factory."""
- def decorate(fn: typing.Callable[..., Any]) -> typing.Callable[..., Any]:
+ def decorate(fn: _Fn) -> _Fn:
if not inspect.isfunction(fn) and not inspect.ismethod(fn):
raise Exception("not a decoratable function")
)
decorated.__defaults__ = getattr(fn, "__func__", fn).__defaults__
- # claims to be fixed?
- # https://github.com/python/mypy/issues/11896
decorated.__wrapped__ = fn # type: ignore
- return update_wrapper(decorated, fn)
+ return cast(_Fn, update_wrapper(decorated, fn))
- return typing.cast(_Fn, update_wrapper(decorate, target))
+ return update_wrapper(decorate, target)
def _update_argspec_defaults_into_env(spec, env):
_PF = TypeVar("_PF")
_TE = TypeVar("_TE")
-_P = compat_typing.ParamSpec("_P")
-
class PluginLoader:
def __init__(
cls: type,
*,
_set: Optional[Set[str]] = None,
- raiseerr: compat_typing.Literal[True] = ...,
+ raiseerr: Literal[True] = ...,
) -> Set[str]:
...
def __get__(self: _GFD, obj: Any, cls: Any) -> Union[_GFD, _T_co]:
raise NotImplementedError()
- if typing.TYPE_CHECKING:
+ if TYPE_CHECKING:
def __set__(self, instance: Any, value: Any) -> None:
...
"""
- if not typing.TYPE_CHECKING:
+ if not TYPE_CHECKING:
# support classes that want to have __slots__ with an explicit
# slot for __dict__. not sure if that requires base __slots__ here.
__slots__ = ()