Skip to content

Commit

Permalink
explicitly subclass typing.Generic instead
Browse files Browse the repository at this point in the history
Unfortunately isinstance will fail on some things
such as typing.Collection. Using typing.Generic
will prevent confusion.
  • Loading branch information
astrelsky committed Sep 5, 2024
1 parent f798c53 commit a7a7a70
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions jpype/_jarray.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ __all__ = ['JArray']
T = typing.TypeVar('T')


class JArray(typing.Collection[T], typing.Reversible[T]):
class JArray(typing.Generic[T]):

def __new__(cls, tp: typing.Type[T], dims=1) -> JArray[T]:
...
Expand All @@ -39,10 +39,6 @@ class JArray(typing.Collection[T], typing.Reversible[T]):
def __iter__(self) -> typing.Iterator[T]:
...

def __contains__(self, item: T) -> bool:
# this is implicitly implemented
...

def __reversed__(self) -> typing.Iterator[T]:
...

Expand All @@ -61,6 +57,3 @@ class JArray(typing.Collection[T], typing.Reversible[T]):
@typing.overload
def __setitem__(self, index: slice, value: typing.Sequence[T]):
...

def __class_getitem__(cls, key: T) -> typing.Type[JArray[T]]:
...

0 comments on commit a7a7a70

Please sign in to comment.