Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type stubs for JPype internal customizers #836

Merged
merged 2 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ...