Skip to content

Commit 517a75e

Browse files
authored
MatchingInOrder and MatchInAnyOrder are generics (#269)
LGTM.
1 parent d2fe226 commit 517a75e

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/hamcrest/library/collection/issequence_containinginanyorder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import MutableSequence, Optional, Sequence, TypeVar, Union, cast
1+
from typing import Generic, Optional, Sequence, TypeVar, Union
22

33
from hamcrest.core.base_matcher import BaseMatcher
44
from hamcrest.core.description import Description
@@ -12,11 +12,11 @@
1212
T = TypeVar("T")
1313

1414

15-
class MatchInAnyOrder(object):
15+
class MatchInAnyOrder(Generic[T]):
1616
def __init__(
1717
self, matchers: Sequence[Matcher[T]], mismatch_description: Optional[Description]
1818
) -> None:
19-
self.matchers = cast(MutableSequence[Matcher[T]], matchers[:])
19+
self.matchers = list(matchers)
2020
self.mismatch_description = mismatch_description
2121

2222
def matches(self, item: T) -> bool:

src/hamcrest/library/collection/issequence_containinginorder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import warnings
2-
from typing import Optional, Sequence, TypeVar, Union
2+
from typing import Generic, Optional, Sequence, TypeVar, Union
33

44
from hamcrest.core.base_matcher import BaseMatcher
55
from hamcrest.core.description import Description
@@ -13,7 +13,7 @@
1313
T = TypeVar("T")
1414

1515

16-
class MatchingInOrder(object):
16+
class MatchingInOrder(Generic[T]):
1717
def __init__(
1818
self, matchers: Sequence[Matcher[T]], mismatch_description: Optional[Description]
1919
) -> None:

0 commit comments

Comments
 (0)