Skip to content

Commit

Permalink
Minor geopandas tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdanal committed Jul 27, 2024
1 parent ac9126d commit 95bc0c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion stubs/geopandas-stubs/_decorator.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _Func = TypeVar("_Func", bound=_AnyCallable)
# - docstring from the original function properly displayed (at least with Pylance)
# Using the other overloads returns the signature of the decorated function instead
@overload
def doc(func: _Func, /) -> Callable[[_AnyCallable], _Func]: ...
def doc(func: _Func, /, **params: object) -> Callable[[_AnyCallable], _Func]: ...
@overload
def doc(docstring: str, /, *docstrings: str | _AnyCallable, **params: object) -> Callable[[_Func], _Func]: ...
@overload
Expand Down
9 changes: 6 additions & 3 deletions stubs/geopandas-stubs/geodataframe.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
import os
from _typeshed import Incomplete, SupportsGetItem, SupportsRead, SupportsWrite
from collections.abc import Callable, Hashable, Iterable, Iterator, Mapping
Expand Down Expand Up @@ -227,18 +228,20 @@ class GeoDataFrame(GeoPandasBase, pd.DataFrame): # type: ignore[misc]
# Keep method to_file roughly in line with GeoSeries.to_file
def to_file(
self,
# TODO verify SupportsWrite[Any] is correct and remove Incomplete
filename: str | os.PathLike[str] | SupportsWrite[Any] | Incomplete,
filename: str | os.PathLike[str] | io.BytesIO,
driver: str | None = None,
schema: dict[str, Any] | None = None,
index: bool | None = None,
*,
# kwargs from `_to_file` function
mode: Literal["w", "a"] = "w",
crs: _ConvertibleToCRS | None = None,
engine: Literal["fiona", "pyogrio"] | None = None,
metadata: dict[str, str] | None = None,
# kwargs extracted from engines
layer: int | str | None = None,
encoding: str | None = None,
overwrite: bool | Incomplete = ..., # TODO can it be None? (accepted by fiona, not sure about pyogrio)
overwrite: bool | None = ...,
**kwargs: Any, # engine and driver dependent
) -> None: ...
@overload
Expand Down
10 changes: 7 additions & 3 deletions stubs/geopandas-stubs/geoseries.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io
import json
import os
from _typeshed import Incomplete, SupportsRead, SupportsWrite, Unused
from _typeshed import SupportsRead, Unused
from collections.abc import Callable, Hashable
from typing import Any, Literal, final, overload
from typing_extensions import Self, deprecated
Expand Down Expand Up @@ -127,17 +128,20 @@ class GeoSeries(GeoPandasBase, pd.Series[BaseGeometry]): # type: ignore[type-va
# Keep method to_file roughly in line with GeoDataFrame.to_file
def to_file(
self,
filename: str | os.PathLike[str] | SupportsWrite[Any] | Incomplete,
filename: str | os.PathLike[str] | io.BytesIO,
driver: str | None = None,
index: bool | None = None,
*,
# kwargs from `_to_file` function
schema: dict[str, Any] | None = None,
mode: Literal["w", "a"] = "w",
crs: _ConvertibleToCRS | None = None,
engine: Literal["fiona", "pyogrio"] | None = None,
metadata: dict[str, str] | None = None,
# kwargs extracted from engines
layer: int | str | None = None,
encoding: str | None = None,
overwrite: bool | Incomplete = ..., # TODO can it be None? (accepted by fiona, not sure about pyogrio)
overwrite: bool | None = ...,
**kwargs: Any, # engine and driver dependent
) -> None: ...
# *** TODO: compare `__getitem__` with pandas-stubs ***
Expand Down

0 comments on commit 95bc0c7

Please sign in to comment.