Skip to content
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
14 changes: 14 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,17 @@ jobs:
- name: Install dependencies
run: uv sync --frozen
- run: uv run python run.py pyright
ty:
name: Run ty on the tests and on the stubs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ env.UV_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.UV_PYTHON }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: uv sync --frozen
- run: uv run python run.py ty-check
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dev = [
"rich-argparse>=1.8.0",
"mypy[native-parser]>=2.1.0",
"pyright>=1.1.409",
"ty>=0.0.40",
{ include-group = "tests" },
]

Expand Down Expand Up @@ -121,5 +122,10 @@ reportIncompatibleVariableOverride = "none"
reportPropertyTypeMismatch = "none"
reportSelfClsParameterName = "none"

[tool.ty]
analysis.respect-type-ignore-comments = false
rules.invalid-method-override = "ignore" # out of control of the stubs (inherited from implementation)
terminal.output-format = "concise"

[tool.pytest.ini_options]
testpaths = ["tests"]
1 change: 1 addition & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ruff-format": ["tests", "stubs"],
"mypy": ["tests", "stubs"],
"pyright": ["tests", "stubs"],
"ty-check": ["tests", "stubs"],
"stubtest": ["--allowlist=stubtest_allowlist.txt", "pandapower", "pyogrio"],
"pytest": [],
}
Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/auxiliary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class GeoAccessor:
@property
def type(self) -> str: ...
@property
def as_shapely_obj(self) -> pd.Series[BaseGeometry]: ... # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments]
def as_shapely_obj(self) -> pd.Series[BaseGeometry]: ... # type: ignore[type-var] # pyright: ignore[reportInvalidTypeArguments] # ty:ignore[invalid-type-arguments]
@property
def as_geoseries(self) -> gpd.GeoSeries: ...
def __getattr__(self, item: str) -> Any: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/plotting/plotly/draw_layers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from collections.abc import Sequence
from pathlib import Path
from typing import Any, Literal

import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]

def version_check() -> None: ...
def draw_layers(
Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/plotting/plotly/layers_plotly.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import SupportsGetItem
from typing import Literal

import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]

from pandapower.auxiliary import pandapowerNet

Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/plotting/plotly/pf_res_plotly.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Literal

import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]

from pandapower.auxiliary import pandapowerNet
from pandapower.plotting.plotly.mapbox_plot import *
Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/plotting/plotly/simple_plotly.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from collections.abc import Iterable, Mapping
from typing import Any, Literal, overload

import pandas as pd
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]

from pandapower.auxiliary import pandapowerNet
from pandapower.plotting.plotly.mapbox_plot import *
Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/plotting/plotly/traces.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from collections.abc import Collection, Iterable, Mapping
from typing import Any, Literal

import pandas as pd
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]

from pandapower._typing import Float, Int
from pandapower.auxiliary import pandapowerNet
Expand Down
2 changes: 1 addition & 1 deletion stubs/pandapower-stubs/plotting/plotly/vlevel_plotly.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Literal

import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
import plotly.graph_objs as go # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]

from pandapower.auxiliary import pandapowerNet
from pandapower.plotting.plotly.traces import _MapStyle
Expand Down
4 changes: 3 additions & 1 deletion stubs/pandapower-stubs/topology/graph_tool_interface.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ from _typeshed import Incomplete
from collections.abc import Iterable
from typing import Literal

from graph_tool import Graph # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
from graph_tool import ( # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
Graph,
)

class GraphToolInterface(Graph): # type: ignore[misc] # pyright: ignore[reportUntypedBaseClass]
pp_buses: set[int]
Expand Down
4 changes: 3 additions & 1 deletion stubs/psqlextra-stubs/error.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django import db
from psycopg import Error as _Psycopg3Error # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
from psycopg import ( # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
Error as _Psycopg3Error,
)
from psycopg2 import Error as _Psycopg2Error

Psycopg2Error: type[_Psycopg2Error] | None
Expand Down
8 changes: 4 additions & 4 deletions tests/geopandas/test_explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def test_explore() -> None:
if TYPE_CHECKING:
assert_type(GDF.explore(tooltip=False, popup=True, k=4, map_kwds={}), folium.Map)
assert_type(_explore(GDF, tooltip=False, popup=True, k=4, map_kwds={}), folium.Map)
GDF.explore(map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
_explore(GDF, map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
GDF.explore(map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
_explore(GDF, map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]


def test_geoseries_explore() -> None:
Expand All @@ -27,5 +27,5 @@ def test_geoseries_explore() -> None:
_explore_geoseries(GDF.geometry, highlight=False, control_scale=False, map_kwds={}),
folium.Map,
)
GDF.geometry.explore(map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
_explore_geoseries(GDF.geometry, map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
GDF.geometry.explore(map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
_explore_geoseries(GDF.geometry, map_kwds=False) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
30 changes: 15 additions & 15 deletions tests/geopandas/test_geodataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def test_geometry() -> None:
gdf.geometry = geo.values
gdf.geometry = [Point(1, 2), Point(3, 4)]
with pytest.raises(Exception):
gdf.geometry = "geometry" # type: ignore[assignment] # pyright: ignore[reportAttributeAccessIssue]
gdf.geometry = "geometry" # type: ignore[assignment] # pyright: ignore[reportAttributeAccessIssue] # ty:ignore[invalid-assignment]
with pytest.raises(Exception):
gdf.geometry = [1, 2] # type: ignore[list-item] # pyright: ignore[reportAttributeAccessIssue]
gdf.geometry = [1, 2] # type: ignore[list-item] # pyright: ignore[reportAttributeAccessIssue] # ty:ignore[invalid-assignment]

# set_geometry
check(assert_type(gdf.set_geometry(geo), GeoDataFrame), GeoDataFrame)
Expand Down Expand Up @@ -66,7 +66,7 @@ def test_crs() -> None:
gdf.crs = "EPSG:4326"
gdf.crs = 4326
with pytest.raises(Exception):
gdf.crs = 1.5 # type: ignore[assignment] # pyright: ignore[reportAttributeAccessIssue]
gdf.crs = 1.5 # type: ignore[assignment] # pyright: ignore[reportAttributeAccessIssue] # ty:ignore[invalid-assignment]

# set_crs
check(assert_type(gdf.set_crs(crs), GeoDataFrame), GeoDataFrame)
Expand All @@ -76,11 +76,11 @@ def test_crs() -> None:
check(assert_type(gdf.set_crs(crs=4326), GeoDataFrame), GeoDataFrame)
check(assert_type(gdf.set_crs(epsg=4326), GeoDataFrame), GeoDataFrame)
with pytest.raises(Exception):
gdf.set_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
gdf.set_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gdf.set_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
gdf.set_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
with pytest.raises(Exception):
gdf.set_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
gdf.set_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] # ty:ignore[no-matching-overload]

# to_crs
check(assert_type(gdf.to_crs(crs), GeoDataFrame), GeoDataFrame)
Expand All @@ -90,24 +90,24 @@ def test_crs() -> None:
check(assert_type(gdf.to_crs(crs=4326), GeoDataFrame), GeoDataFrame)
check(assert_type(gdf.to_crs(epsg=4326), GeoDataFrame), GeoDataFrame)
with pytest.raises(Exception):
gdf.to_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
gdf.to_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gdf.to_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
gdf.to_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
with pytest.raises(Exception):
gdf.to_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
gdf.to_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gdf.to_crs(inplace=True) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
gdf.to_crs(inplace=True) # type: ignore[call-overload] # pyright: ignore[reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gdf.to_crs(None, inplace=True) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
gdf.to_crs(None, inplace=True) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gdf.to_crs(None, None, inplace=True) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
gdf.to_crs(None, None, inplace=True) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gdf.to_crs(None, None, True) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
gdf.to_crs(None, None, True) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] # ty:ignore[no-matching-overload]

# estimate_utm_crs
check(assert_type(gdf.estimate_utm_crs(), CRS), CRS)
check(assert_type(gdf.estimate_utm_crs("WGS 84"), CRS), CRS)
with pytest.raises(Exception):
gdf.estimate_utm_crs(84) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
gdf.estimate_utm_crs(84) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
with pytest.raises(Exception):
gdf.estimate_utm_crs(CRS) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
gdf.estimate_utm_crs(CRS) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
18 changes: 9 additions & 9 deletions tests/geopandas/test_geoseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_crs() -> None:
gs.crs = 4326
assert isinstance(gs.crs, CRS)
with pytest.raises(Exception):
gs.crs = 1.5 # type: ignore[assignment] # pyright: ignore[reportAttributeAccessIssue]
gs.crs = 1.5 # type: ignore[assignment] # pyright: ignore[reportAttributeAccessIssue] # ty:ignore[invalid-assignment]

# set_crs
check(assert_type(gs.set_crs(crs), GeoSeries), GeoSeries)
Expand All @@ -53,28 +53,28 @@ def test_crs() -> None:
check(assert_type(gs.set_crs(crs=4326), GeoSeries), GeoSeries)
check(assert_type(gs.set_crs(epsg=4326), GeoSeries), GeoSeries)
with pytest.raises(Exception):
gs.set_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
gs.set_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gs.set_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
gs.set_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
with pytest.raises(Exception):
gs.set_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
gs.set_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] # ty:ignore[no-matching-overload]

# to_crs
check(assert_type(gs.to_crs(crs), GeoSeries), GeoSeries)
check(assert_type(gs.to_crs("EPSG:4326"), GeoSeries), GeoSeries)
check(assert_type(gs.to_crs(crs=4326), GeoSeries), GeoSeries)
check(assert_type(gs.to_crs(epsg=4326), GeoSeries), GeoSeries)
with pytest.raises(Exception):
gs.to_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
gs.to_crs() # type: ignore[call-overload] # pyright: ignore[reportCallIssue] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
gs.to_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
gs.to_crs(None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
with pytest.raises(Exception):
gs.to_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue]
gs.to_crs(None, None) # type: ignore[call-overload] # pyright: ignore[reportArgumentType,reportCallIssue] # ty:ignore[no-matching-overload]

# estimate_utm_crs
check(assert_type(gs.estimate_utm_crs(), CRS), CRS)
check(assert_type(gs.estimate_utm_crs("WGS 84"), CRS), CRS)
with pytest.raises(Exception):
gs.estimate_utm_crs(84) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
gs.estimate_utm_crs(84) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
with pytest.raises(Exception):
gs.estimate_utm_crs(CRS) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
gs.estimate_utm_crs(CRS) # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]
2 changes: 1 addition & 1 deletion tests/geopandas/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_read_file(tmp_path: Path) -> None:
assert not isinstance(df, gpd.GeoDataFrame)

with pytest.raises(Exception):
gpd.read_file(file, engine="toto") # type: ignore[call-overload] # pyright: ignore[reportArgumentType]
gpd.read_file(file, engine="toto") # type: ignore[call-overload] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]


def test_infer_schema() -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/shapely/test_affinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_rotate() -> None:
check(assert_type(shapely.affinity.rotate(LS, 90, origin=(x, y, 0)), LineString), LineString)

with pytest.raises(Exception):
shapely.affinity.rotate(LS, 90, origin="centred") # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
shapely.affinity.rotate(LS, 90, origin="centred") # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]


def test_scale() -> None:
Expand All @@ -77,7 +77,7 @@ def test_scale() -> None:
check(assert_type(shapely.affinity.scale(LS, 90, origin=(1, 1.0, 0.0)), LineString), LineString)

with pytest.raises(Exception):
shapely.affinity.scale(PO, origin="centred") # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
shapely.affinity.scale(PO, origin="centred") # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]


def test_skew() -> None:
Expand All @@ -93,7 +93,7 @@ def test_skew() -> None:
check(assert_type(shapely.affinity.skew(PO, 20, origin=(1.0, 2.0, 0)), Polygon), Polygon)

with pytest.raises(Exception):
shapely.affinity.skew(PO, 20, origin="centred") # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
shapely.affinity.skew(PO, 20, origin="centred") # type: ignore[arg-type] # pyright: ignore[reportArgumentType] # ty:ignore[invalid-argument-type]


def test_translate() -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/shapely/test_constructive.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def test_polygonize() -> None:
dtype=GeometryCollection,
)
with pytest.raises(Exception):
shapely.polygonize(LS) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType]
shapely.polygonize(LS) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType] # ty:ignore[no-matching-overload]


def test_polygonize_full() -> None:
Expand Down Expand Up @@ -352,7 +352,7 @@ def test_polygonize_full() -> None:
dtype=np.ndarray,
)
with pytest.raises(Exception):
shapely.polygonize_full(LS) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType]
shapely.polygonize_full(LS) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType] # ty:ignore[no-matching-overload]


def test_remove_repeated_points() -> None:
Expand Down
10 changes: 5 additions & 5 deletions tests/shapely/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def test_get_coordinates() -> None:
# bool fallback
check(
assert_type(
shapely.get_coordinates(P, return_index=bool(1)),
shapely.get_coordinates(P, return_index=bool(int("1"))),
tuple[NDArray[np.float64], NDArray[np.int64]] | NDArray[np.float64],
),
tuple,
dtype=np.ndarray,
)
check(
assert_type(
shapely.get_coordinates(P, return_index=bool(0)),
shapely.get_coordinates(P, return_index=bool(int("0"))),
tuple[NDArray[np.float64], NDArray[np.int64]] | NDArray[np.float64],
),
np.ndarray,
Expand All @@ -129,8 +129,8 @@ def test_set_coordinates() -> None:
dtype=Point,
)
with pytest.raises(Exception):
shapely.set_coordinates(None, []) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType]
shapely.set_coordinates(None, []) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
shapely.set_coordinates(None, [1, 1]) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType]
shapely.set_coordinates(None, [1, 1]) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType] # ty:ignore[no-matching-overload]
with pytest.raises(Exception):
shapely.set_coordinates(None, [[1, 1]]) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType]
shapely.set_coordinates(None, [[1, 1]]) # type: ignore[call-overload] # pyright: ignore[reportCallIssue, reportArgumentType] # ty:ignore[no-matching-overload]
Loading
Loading