typing: replace ImmutableSetProtocol with typing.AbstractSet

Which does the same thing, but is a builtin and is more accurate
pull/10473/head
Dylan Baker 3 years ago committed by Jussi Pakkanen
parent 3dec0db06d
commit c51639b4ff
  1. 39
      mesonbuild/_typing.py
  2. 8
      mesonbuild/build.py

@ -79,42 +79,3 @@ class ImmutableListProtocol(Protocol[T]):
def index(self, item: T) -> int: ...
def copy(self) -> typing.List[T]: ...
class ImmutableSetProtocol(Protocol[T]):
"""A protocol for a set that cannot be mutated.
This provides for cases where mutation of the set is undesired. Although
this will be allowed at runtime, mypy (or another type checker), will see
any attempt to use mutative methods as an error.
"""
def __iter__(self) -> typing.Iterator[T]: ...
def __contains__(self, item: T) -> bool: ...
def __len__(self) -> int: ...
def __add__(self, other: typing.Set[T]) -> typing.Set[T]: ...
def __eq__(self, other: typing.Any) -> bool: ...
def __ne__(self, other: typing.Any) -> bool: ...
def __le__(self, other: typing.Any) -> bool: ...
def __lt__(self, other: typing.Any) -> bool: ...
def __gt__(self, other: typing.Any) -> bool: ...
def __ge__(self, other: typing.Any) -> bool: ...
def copy(self) -> typing.Set[T]: ...
def difference(self, other: typing.Set[T]) -> typing.Set[T]: ...
def intersection(self, other: typing.Set[T]) -> typing.Set[T]: ...
def issubset(self, other: typing.Set[T]) -> bool: ...
def issuperset(self, other: typing.Set[T]) -> bool: ...
def symmetric_difference(self, other: typing.Set[T]) -> typing.Set[T]: ...
def union(self, other: typing.Set[T]) -> typing.Set[T]: ...

@ -47,7 +47,7 @@ from .interpreterbase import FeatureNew, FeatureDeprecated
if T.TYPE_CHECKING:
from typing_extensions import Literal
from ._typing import ImmutableListProtocol, ImmutableSetProtocol
from ._typing import ImmutableListProtocol
from .backend.backends import Backend, ExecutableSerialisation
from .interpreter.interpreter import Test, SourceOutputs, Interpreter
from .interpreterbase import SubProject
@ -1086,7 +1086,7 @@ class BuildTarget(Target):
return result
@lru_cache(maxsize=None)
def get_link_dep_subdirs(self) -> 'ImmutableSetProtocol[str]':
def get_link_dep_subdirs(self) -> T.AbstractSet[str]:
result: OrderedSet[str] = OrderedSet()
for i in self.link_targets:
if not isinstance(i, StaticLibrary):
@ -2573,7 +2573,7 @@ class CustomTarget(Target, CommandBase):
def get_link_deps_mapping(self, prefix: str) -> T.Mapping[str, str]:
return {}
def get_link_dep_subdirs(self):
def get_link_dep_subdirs(self) -> T.AbstractSet[str]:
return OrderedSet()
def get_all_link_deps(self):
@ -2765,7 +2765,7 @@ class CustomTargetIndex(HoldableObject):
def get_link_deps_mapping(self, prefix: str) -> T.Mapping[str, str]:
return self.target.get_link_deps_mapping(prefix)
def get_link_dep_subdirs(self):
def get_link_dep_subdirs(self) -> T.AbstractSet[str]:
return self.target.get_link_dep_subdirs()
def is_linkable_target(self) -> bool:

Loading…
Cancel
Save