Skip to content

Commit a4aa0c8

Browse files
authored
chore: use pyright as static type checker (#227)
* use pyright as static type checker * make pyright happy
1 parent 59bf9e0 commit a4aa0c8

File tree

11 files changed

+134
-95
lines changed

11 files changed

+134
-95
lines changed

.github/workflows/lint.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,28 @@ on:
1010
- synchronize
1111

1212
jobs:
13-
taplo-lint:
14-
name: taplo lint
13+
taplo:
14+
name: taplo
1515
runs-on: ubuntu-22.04
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: uncenter/setup-taplo@v1
1919
with:
2020
version: "0.9.3"
2121
- run: taplo fmt --check
22+
23+
pyright:
24+
name: pyright
25+
runs-on: ubuntu-22.04
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-python@v4
29+
with:
30+
python-version: "3.11"
31+
cache: pyright
32+
- run: |
33+
python -m venv .venv
34+
source .venv/bin/activate
35+
pip install pandas numpy scipy sparse
36+
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
37+
- uses: jakebailey/pyright-action@v2

.pre-commit-config.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
ci:
22
autofix_prs: false
3+
skip: [pyright]
34

45
default_language_version:
56
python: python3.11
7+
node: 23.9.0
68

79
repos:
810
- repo: https://github.com/pre-commit/pre-commit-hooks
@@ -25,7 +27,7 @@ repos:
2527
args: [--fix]
2628
- id: ruff-format
2729

28-
- repo: https://github.com/pre-commit/mirrors-mypy
29-
rev: v1.15.0
30+
- repo: https://github.com/RobertCraigie/pyright-python
31+
rev: v1.1.400
3032
hooks:
31-
- id: mypy
33+
- id: pyright

pixi.lock

Lines changed: 100 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyarrow-stubs/__lib_pxi/array.pyi

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# mypy: disable-error-code="overload-overlap,misc,type-arg"
2-
31
import datetime as dt
42
import sys
53

@@ -63,7 +61,6 @@ from .types import (
6361
_IndexT,
6462
_RunEndType,
6563
_Size,
66-
_ValueT,
6764
)
6865

6966
_T = TypeVar("_T")
@@ -1627,25 +1624,25 @@ class RunEndEncodedArray(Array[scalar.RunEndEncodedScalar[_RunEndType, _BasicVal
16271624
def from_arrays(
16281625
run_ends: Int16Array,
16291626
values: Array,
1630-
type: _ValueT | None = None,
1627+
type: DataType | None = None,
16311628
) -> RunEndEncodedArray[types.Int16Type, _BasicValueT]: ...
16321629
@overload
16331630
@staticmethod
16341631
def from_arrays(
16351632
run_ends: Int32Array,
16361633
values: Array,
1637-
type: _ValueT | None = None,
1634+
type: DataType | None = None,
16381635
) -> RunEndEncodedArray[types.Int32Type, _BasicValueT]: ...
16391636
@overload
16401637
@staticmethod
16411638
def from_arrays(
16421639
run_ends: Int64Array,
16431640
values: Array,
1644-
type: _ValueT | None = None,
1641+
type: DataType | None = None,
16451642
) -> RunEndEncodedArray[types.Int64Type, _BasicValueT]: ...
16461643
@staticmethod
1647-
def from_buffers( # type: ignore[override]
1648-
type: _ValueT,
1644+
def from_buffers(
1645+
type: DataType,
16491646
length: int,
16501647
buffers: list[Buffer],
16511648
null_count: int = -1,

pyarrow-stubs/__lib_pxi/pandas_shim.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# mypy: disable-error-code="name-defined"
21
from types import ModuleType
32
from typing import Any, Iterable, TypeGuard
43

pyarrow-stubs/__lib_pxi/scalar.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# mypy: disable-error-code="overload-overlap,misc,type-arg"
21
import collections.abc
32
import datetime as dt
43
import sys

pyarrow-stubs/__lib_pxi/table.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# mypy: disable-error-code="overload-overlap,type-arg,misc"
2-
31
import datetime as dt
42
import sys
53

pyarrow-stubs/__lib_pxi/tensor.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# mypy: disable-error-code="import-untyped"
2-
31
import sys
42

53
if sys.version_info >= (3, 11):
@@ -10,8 +8,8 @@ else:
108
import numpy as np
119

1210
from pyarrow.lib import _Weakrefable
13-
from pydata.sparse import COO # type: ignore[import-not-found]
1411
from scipy.sparse import coo_matrix, csr_matrix
12+
from sparse import COO
1513

1614
class Tensor(_Weakrefable):
1715
@classmethod

pyarrow-stubs/_stubs_typing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Compression: TypeAlias = Literal[
2929
NullEncoding: TypeAlias = Literal["mask", "encode"]
3030
NullSelectionBehavior: TypeAlias = Literal["drop", "emit_null"]
3131
Mask: TypeAlias = Sequence[bool | None] | NDArray[np.bool_] | BooleanArray
32-
Indices: TypeAlias = Sequence[int] | NDArray[np.integer] | IntegerArray
32+
Indices: TypeAlias = Sequence[int] | NDArray[np.integer[Any]] | IntegerArray
3333
PyScalar: TypeAlias = (
3434
bool | int | float | Decimal | str | bytes | dt.date | dt.datetime | dt.time | dt.timedelta
3535
)

pyarrow-stubs/compute.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# mypy: disable-error-code="misc,type-var,var-annotated"
21
# ruff: noqa: I001
32
from typing import Literal, TypeAlias, TypeVar, overload, Any, Iterable, ParamSpec, Sequence
43
from collections.abc import Callable

pyproject.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ pyarrow-stubs = { path = ".", editable = true }
4848
ipython = "*"
4949
scipy = "*"
5050
pre-commit = "*"
51-
mypy = ">=1.11"
5251
ruff = ">=0.5"
5352
types-cffi = "*"
5453
pandas-stubs = "*"
5554
hatchling = "*"
5655
fsspec = "*"
56+
sparse = "*"
5757
pyright = { version = ">=1.1.385,<2", extras = ["nodejs"] }
5858

5959
[tool.pixi.tasks]
@@ -85,9 +85,6 @@ lines-between-types = 1
8585
[tool.ruff.format]
8686
docstring-code-format = true
8787

88-
[tool.mypy]
89-
explicit_package_bases = true
90-
files = "pyarrow-stubs"
91-
namespace_packages = true
92-
show_error_codes = true
93-
disable_error_code = ["overload-overlap", "import-not-found"]
88+
[tool.pyright]
89+
typeCheckingMode = "basic"
90+
reportMissingImports = false

0 commit comments

Comments
 (0)