Skip to content

Commit 5441d4e

Browse files
authored
CI: run pyright (#43672)
1 parent 63e11e4 commit 5441d4e

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ repos:
8181
- flake8-comprehensions==3.1.0
8282
- flake8-bugbear==21.3.2
8383
- pandas-dev-flaker==0.2.0
84+
- repo: local
85+
hooks:
86+
- id: pyright
87+
name: pyright
88+
entry: pyright
89+
language: node
90+
pass_filenames: false
91+
types: [python]
92+
additional_dependencies: ['[email protected]']
8493
- repo: local
8594
hooks:
8695
- id: flake8-rst

pandas/core/computation/expr.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ def f(self, *args, **kwargs):
265265
return f
266266

267267

268-
_T = TypeVar("_T", bound="BaseExprVisitor")
268+
# should be bound by BaseExprVisitor but that creates a circular dependency:
269+
# _T is used in disallow, but disallow is used to define BaseExprVisitor
270+
# https://github.com/microsoft/pyright/issues/2315
271+
_T = TypeVar("_T")
269272

270273

271274
def disallow(nodes: set[str]) -> Callable[[type[_T]], type[_T]]:
@@ -279,11 +282,13 @@ def disallow(nodes: set[str]) -> Callable[[type[_T]], type[_T]]:
279282
"""
280283

281284
def disallowed(cls: type[_T]) -> type[_T]:
282-
cls.unsupported_nodes = ()
285+
# error: "Type[_T]" has no attribute "unsupported_nodes"
286+
cls.unsupported_nodes = () # type: ignore[attr-defined]
283287
for node in nodes:
284288
new_method = _node_not_implemented(node)
285289
name = f"visit_{node}"
286-
cls.unsupported_nodes += (name,)
290+
# error: "Type[_T]" has no attribute "unsupported_nodes"
291+
cls.unsupported_nodes += (name,) # type: ignore[attr-defined]
287292
setattr(cls, name, new_method)
288293
return cls
289294

pandas/core/reshape/tile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
Quantilization functions and related stuff
33
"""
4+
from __future__ import annotations
5+
46
from typing import (
57
Any,
68
Callable,

pandas/core/tools/timedeltas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
timedelta support tools
33
"""
4+
from __future__ import annotations
45

56
import numpy as np
67

pyproject.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,47 @@ force_grid_wrap = 2
116116
force_sort_within_sections = true
117117
skip_glob = "env"
118118
skip = "pandas/__init__.py"
119+
120+
[tool.pyright]
121+
pythonVersion = "3.8"
122+
typeCheckingMode = "strict"
123+
include = ["pandas"]
124+
exclude = ["pandas/tests"]
125+
reportGeneralTypeIssues = false
126+
reportConstantRedefinition = false
127+
reportFunctionMemberAccess = false
128+
reportImportCycles = false
129+
reportIncompatibleMethodOverride = false
130+
reportIncompatibleVariableOverride = false
131+
reportInvalidStubStatement = false
132+
reportInvalidTypeVarUse = false
133+
reportMissingImports = false
134+
reportMissingModuleSource = false
135+
reportMissingTypeArgument = false
136+
reportMissingTypeStubs = false
137+
reportOptionalCall = false
138+
reportOptionalIterable = false
139+
reportOptionalMemberAccess = false
140+
reportOptionalOperand = false
141+
reportOptionalSubscript = false
142+
reportOverlappingOverload = false
143+
reportPrivateImportUsage = false
144+
reportPrivateUsage = false
145+
reportPropertyTypeMismatch = false
146+
reportSelfClsParameterName = false
147+
reportUnboundVariable = false
148+
reportUnknownArgumentType = false
149+
reportUnknownLambdaType = false
150+
reportUnknownMemberType = false
151+
reportUnknownParameterType = false
152+
reportUnknownVariableType = false
153+
reportUnnecessaryComparison = false
154+
reportUnnecessaryIsInstance = false
155+
reportUnsupportedDunderAll = false
156+
reportUntypedBaseClass = false
157+
reportUntypedFunctionDecorator = false
158+
reportUntypedNamedTuple = false
159+
reportUnusedClass = false
160+
reportUnusedFunction = false
161+
reportUnusedImport = false
162+
reportUnusedVariable = false

0 commit comments

Comments
 (0)