Skip to content
Draft
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
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"stubs/Flask-SocketIO",
"stubs/fpdf2",
"stubs/gdb",
"stubs/geojson",
"stubs/geopandas",
"stubs/google-cloud-ndb",
"stubs/grpcio-channelz/grpc_channelz/v1",
Expand Down
2 changes: 2 additions & 0 deletions stubs/geojson/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
geojson
geojson.examples.SimpleWebFeature.__geo_interface__
2 changes: 2 additions & 0 deletions stubs/geojson/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "3.2.*"
upstream-repository = "https://github.com/jazzband/geojson"
28 changes: 28 additions & 0 deletions stubs/geojson/geojson/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from geojson._version import __version__, __version_info__
from geojson.base import GeoJSON
from geojson.codec import GeoJSONEncoder, dump, dumps, load, loads
from geojson.feature import Feature, FeatureCollection
from geojson.geometry import GeometryCollection, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon
from geojson.utils import coords, map_coords

__all__ = [
"dump",
"dumps",
"load",
"loads",
"GeoJSONEncoder",
"coords",
"map_coords",
"Point",
"LineString",
"Polygon",
"MultiLineString",
"MultiPoint",
"MultiPolygon",
"GeometryCollection",
"Feature",
"FeatureCollection",
"GeoJSON",
"__version__",
"__version_info__",
]
2 changes: 2 additions & 0 deletions stubs/geojson/geojson/_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__version__: str
__version_info__: tuple[int, ...]
16 changes: 16 additions & 0 deletions stubs/geojson/geojson/base.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections.abc import Callable, Iterable
from typing import Any

class GeoJSON(dict[str, Any]):
def __init__(self, iterable: Iterable[Any] = (), **extra) -> None: ...
def __getattr__(self, name) -> Any: ...
def __setattr__(self, name, value) -> None: ...
def __delattr__(self, name) -> None: ...
@property
def __geo_interface__(self) -> None | GeoJSON: ...
@classmethod
def to_instance(cls, ob: Any, default: Any = None, strict: bool = False) -> Any: ...
@property
def is_valid(self) -> bool: ...
def check_list_errors(self, checkFunc: Callable[..., Any], lst: list[Any]) -> list[str]: ...
def errors(self) -> list[str] | None: ...
32 changes: 32 additions & 0 deletions stubs/geojson/geojson/codec.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import json
from _typeshed import SupportsRead, SupportsWrite
from collections.abc import Callable
from typing import Any

from geojson import GeoJSON

class GeoJSONEncoder(json.JSONEncoder):
def default(self, obj) -> GeoJSON: ...

def dump(
obj: Any, fp: SupportsWrite[str], cls: type[json.JSONEncoder] | None = json.JSONEncoder, allow_nan: bool = False, **kwargs
) -> None: ...
def dumps(
obj: Any, cls: type[json.JSONEncoder] | None = json.JSONEncoder, allow_nan: bool = False, ensure_ascii: bool = False, **kwargs
) -> str: ...
def load(
fp: SupportsRead[str],
cls: type[json.JSONDecoder] = json.JSONDecoder,
parse_constant: Callable[[Any], None] = ...,
object_hook: Callable[..., GeoJSON] = GeoJSON.to_instance,
**kwargs,
) -> GeoJSON: ...
def loads(
s: str,
cls: type[json.JSONDecoder] = json.JSONDecoder,
parse_constant: Callable[[Any], None] = ...,
object_hook: Callable[..., GeoJSON] = GeoJSON.to_instance,
**kwargs,
) -> GeoJSON: ...

PyGFPEncoder = GeoJSONEncoder
21 changes: 21 additions & 0 deletions stubs/geojson/geojson/examples.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Any, Literal

from geojson import GeoJSON
from geojson.geometry import Geometry

class SimpleWebFeature:
id: None | int | str
geometry: None | Geometry
properties: dict[Literal["title", "summary", "link"], str]
__geo_interface__: dict[str, Any]
def __init__(
self,
id: None | int | str = None,
geometry: None | dict[str, Any] = None,
title: None | str = None,
summary: None | str = None,
link: None | str = None,
) -> None: ...
def as_dict(self) -> dict[str, Any]: ...

def create_simple_web_feature(o: dict[str, Any]) -> GeoJSON: ...
15 changes: 15 additions & 0 deletions stubs/geojson/geojson/feature.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import Any

from geojson.base import GeoJSON
from geojson.geometry import Geometry

class Feature(GeoJSON):
def __init__(
self, id: None | str | int = None, geometry: None | Geometry = None, properties: None | dict[str, Any] = None, **extra
) -> None: ...
def errors(self) -> list[str] | None: ...

class FeatureCollection(GeoJSON):
def __init__(self, features: list[Feature | Geometry], **extra) -> None: ...
def errors(self) -> list[str] | None: ...
def __getitem__(self, key) -> Feature: ...
47 changes: 47 additions & 0 deletions stubs/geojson/geojson/geometry.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from collections.abc import Iterable
from typing import Any

from geojson import Feature
from geojson.base import GeoJSON

DEFAULT_PRECISION: int

class Geometry(GeoJSON):
def __init__(
self, coordinates: None | Feature | Iterable[Any] = None, validate: bool = False, precision: None | int = None, **extra
) -> None: ...
@classmethod
def clean_coordinates(
cls, coords: Geometry | tuple[Any, ...] | list[tuple[Any, ...]], precision: None | int
) -> None | tuple[Any, ...] | list[tuple[Any, ...]]: ...

class GeometryCollection(GeoJSON):
def __init__(self, geometries=..., **extra) -> None: ...
def errors(self) -> list[str] | None: ...
def __getitem__(self, key) -> Geometry | tuple[()] | None: ...

def check_point(coord) -> str | None: ...

class Point(Geometry):
def errors(self) -> list[str] | None: ...

class MultiPoint(Geometry):
def errors(self) -> list[str] | None: ...

def check_line_string(coord) -> str | None: ...

class LineString(MultiPoint):
def errors(self) -> list[str] | None: ...

class MultiLineString(Geometry):
def errors(self) -> list[str] | None: ...

def check_polygon(coord) -> str | None: ...

class Polygon(Geometry):
def errors(self) -> list[str] | None: ...

class MultiPolygon(Geometry):
def errors(self) -> list[str] | None: ...

class Default: ...
6 changes: 6 additions & 0 deletions stubs/geojson/geojson/mapping.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from typing import Any, Literal

GEO_INTERFACE_MARKER: Literal["__geo_interface__"]

def is_mapping(obj) -> bool: ...
def to_mapping(obj) -> dict[str, Any]: ...
15 changes: 15 additions & 0 deletions stubs/geojson/geojson/utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from collections.abc import Generator
from typing import Any, Literal

from geojson import Feature, GeoJSON
from geojson.geometry import Geometry

def coords(obj: Feature | Geometry | dict[str, Any]) -> Generator[tuple[Any]]: ...
def map_coords(func, obj) -> dict[str, Any]: ...
def map_tuples(func, obj) -> list[tuple[float]]: ...
def map_geometries(func, obj) -> GeoJSON: ...
def generate_random(
featureType: Literal["Point", "LineString", "Polygon"],
numberVertices: int = 3,
boundingBox: list[float] = [-180.0, -90.0, 180.0, 90.0],
) -> Feature: ...
Loading