Skip to content

CI: run pyright #43672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 25, 2021
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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ repos:
- flake8-comprehensions==3.1.0
- flake8-bugbear==21.3.2
- pandas-dev-flaker==0.2.0
- repo: local
hooks:
- id: pyright
name: pyright
entry: pyright
language: node
pass_filenames: false
types: [python]
additional_dependencies: ['[email protected]']
- repo: local
hooks:
- id: flake8-rst
Expand Down
11 changes: 8 additions & 3 deletions pandas/core/computation/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ def f(self, *args, **kwargs):
return f


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


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

def disallowed(cls: type[_T]) -> type[_T]:
cls.unsupported_nodes = ()
# error: "Type[_T]" has no attribute "unsupported_nodes"
cls.unsupported_nodes = () # type: ignore[attr-defined]
for node in nodes:
new_method = _node_not_implemented(node)
name = f"visit_{node}"
cls.unsupported_nodes += (name,)
# error: "Type[_T]" has no attribute "unsupported_nodes"
cls.unsupported_nodes += (name,) # type: ignore[attr-defined]
setattr(cls, name, new_method)
return cls

Expand Down
2 changes: 2 additions & 0 deletions pandas/core/reshape/tile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Quantilization functions and related stuff
"""
from __future__ import annotations

from typing import (
Any,
Callable,
Expand Down
1 change: 1 addition & 0 deletions pandas/core/tools/timedeltas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
timedelta support tools
"""
from __future__ import annotations

import numpy as np

Expand Down
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,47 @@ force_grid_wrap = 2
force_sort_within_sections = true
skip_glob = "env"
skip = "pandas/__init__.py"

[tool.pyright]
pythonVersion = "3.8"
typeCheckingMode = "strict"
include = ["pandas"]
exclude = ["pandas/tests"]
reportGeneralTypeIssues = false
reportConstantRedefinition = false
reportFunctionMemberAccess = false
reportImportCycles = false
reportIncompatibleMethodOverride = false
reportIncompatibleVariableOverride = false
reportInvalidStubStatement = false
reportInvalidTypeVarUse = false
reportMissingImports = false
reportMissingModuleSource = false
reportMissingTypeArgument = false
reportMissingTypeStubs = false
reportOptionalCall = false
reportOptionalIterable = false
reportOptionalMemberAccess = false
reportOptionalOperand = false
reportOptionalSubscript = false
reportOverlappingOverload = false
reportPrivateImportUsage = false
reportPrivateUsage = false
reportPropertyTypeMismatch = false
reportSelfClsParameterName = false
reportUnboundVariable = false
reportUnknownArgumentType = false
reportUnknownLambdaType = false
reportUnknownMemberType = false
reportUnknownParameterType = false
reportUnknownVariableType = false
reportUnnecessaryComparison = false
reportUnnecessaryIsInstance = false
reportUnsupportedDunderAll = false
reportUntypedBaseClass = false
reportUntypedFunctionDecorator = false
reportUntypedNamedTuple = false
reportUnusedClass = false
reportUnusedFunction = false
reportUnusedImport = false
reportUnusedVariable = false