Skip to content

Commit

Permalink
Merge pull request #836 from michi42/master
Browse files Browse the repository at this point in the history
Add type stubs for JPype internal customizers
  • Loading branch information
marscher authored Nov 26, 2020
2 parents 74555b0 + 9d2065c commit c5906ad
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jpype/_core.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class _JRuntime:
pass
93 changes: 93 additions & 0 deletions jpype/_jcollection.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from typing import Iterable, Collection, List, Set, Mapping, Tuple, TypeVar, Iterator, Generator, Union, overload

E = TypeVar('E')
K = TypeVar('K')
V = TypeVar('V')


class _JIterable(Iterable[E]):
def __iter__(self) -> Iterator[E]: ...


class _JCollection(Collection[E]):
def __len__(self) -> int: ...

def __delitem__(self, i: E) -> None: ...

def __contains__(self, i: E) -> bool: ...


class _JList(List[E]):
@overload
def __getitem__(self, ndx: int) -> E: ...

@overload
def __getitem__(self, ndx: slice) -> E: ...

def __setitem__(self, ndx: int, v: E) -> None: ...

def __delitem__(self, ndx: int) -> E: ...

def __reversed__(self) -> Generator[E, None, None]: ...

def index(self, obj: E) -> int: ...

def count(self, obj: E) -> int: ...

def insert(self, idx: int, obj: E) -> '_JList'[E]: ...

def append(self, obj: E) -> '_JList'[E]: ...

def reverse(self) -> None: ...

def extend(self, lst: Iterable[E]) -> None: ...

def pop(self, idx: int = ...) -> E: ...

def __iadd__(self, obj: List[E]) -> '_JList'[E]: ...

def __add__(self, obj: List[E]) -> '_JList'[E]: ...

def remove(self, obj: E) -> None: ...


class _JMap(Mapping[K, V]):
def __len__(self) -> int: ...

def __iter__(self) -> Iterator[K]: ...

def __delitem__(self, i: K) -> V: ...

def __getitem__(self, ndx: K) -> V: ...

def __setitem__(self, ndx: K, v: V) -> None: ...

def items(self) -> Set['_JMapEntry'[K, V]]: ...

def keys(self) -> Set[K]: ...

def __contains__(self, item: V) -> bool: ...


class _JSet(Set[E]):
def __delitem__(self, i: E): ...


class _JMapEntry(Tuple[K, V]):
def __len__(self) -> int: ...

def __getitem__(self, x: int) -> Union[K, V]: ...


class _JIterator(Iterator[E]):
def __next__(self) -> E: ...

def __iter__(self) -> Iterator[E]: ...


class _JEnumeration(Iterator[E]):
def __next__(self) -> E: ...

def __iter__(self) -> Iterator[E]: ...

def next(self) -> E: ...
9 changes: 9 additions & 0 deletions jpype/_jio.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from types import TracebackType
from typing import ContextManager, Optional, Type


class _JCloseable(ContextManager['_JCloseable']):
def __enter__(self) -> '_JCloseable': ...

def __exit__(self, exception_type: Optional[Type[BaseException]], exception_value: Optional[BaseException],
traceback: Optional[TracebackType]) -> bool: ...
13 changes: 13 additions & 0 deletions jpype/_jstring.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Any, Text


class _JStringProto(Text):
def __add__(self, other: Text) -> Text: ...

def __len__(self) -> int: ...

def __getitem__(self, i: int) -> Text: ...

def __contains__(self, other: Text) -> bool: ...

def __hash__(self) -> Any: ...
12 changes: 12 additions & 0 deletions jpype/_jthread.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class _JThread:
@staticmethod
def isAttached() -> bool: ...

@staticmethod
def attach() -> None: ...

@staticmethod
def attachAsDaemon() -> None: ...

@staticmethod
def detach() -> None: ...

0 comments on commit c5906ad

Please sign in to comment.