Skip to content

Commit

Permalink
Add all type declarations
Browse files Browse the repository at this point in the history
If we want everything exposed from the top-level
module, it needs to be declared here. Ideally,
we'd only need to declare the cython parts but
mypy wants everything.

Please let me know if there's a better way to
do this.
  • Loading branch information
invisiblefunnel committed Jan 26, 2023
1 parent 7e6ea25 commit 5464aea
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/flatrtree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flatrtree.rtree import RTree
from flatrtree.serialization import deserialize, serialize

DEFAULT_DEGREE = 8
DEFAULT_DEGREE: int = 8

__all__ = [
"RTree",
Expand Down
30 changes: 29 additions & 1 deletion src/flatrtree/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
from flatrtree.rtree import RTree
from typing import Callable, Iterator, List, Optional, Tuple

DEFAULT_DEGREE: int

class RTree:
def __init__(self, count: int, refs: List[int], boxes: List[float]): ...
def search(
self, minx: float, miny: float, maxx: float, maxy: float
) -> Iterator[int]: ...
def neighbors(
self,
x: float,
y: float,
box_dist: Callable[
# x, y, minx, miny, maxx, maxy
[float, float, float, float, float, float],
float, # dist
],
item_dist: Optional[
Callable[
# x, y, ref
[float, float, int],
float, # dist
]
] = None,
) -> Iterator[Tuple[int, float]]: ...

def serialize(rtree: RTree, precision: int) -> bytes: ...
def deserialize(data: bytes) -> RTree: ...

class HilbertBuilder:
def add(self, ref: int, minx: float, miny: float, maxx: float, maxy: float): ...
Expand Down

0 comments on commit 5464aea

Please sign in to comment.