Skip to content

Commit 409875c

Browse files
TYP: Clean up annotations for undocumented elements (#1563)
* Clean up annotations for undocumented elements * PR Feedback * PR Feedback
1 parent 6d02ca8 commit 409875c

File tree

19 files changed

+22
-213
lines changed

19 files changed

+22
-213
lines changed

pandas-stubs/core/computation/engines.pyi

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import ast
2-
from typing import Any
32

4-
from pandas.core.computation.ops import Term as Term
53
from pandas.core.computation.scope import Scope as Scope
64

75
class BaseExprVisitor(ast.NodeVisitor):
@@ -19,47 +17,10 @@ class BaseExprVisitor(ast.NodeVisitor):
1917
parser = ...
2018
preparser = ...
2119
assigner = ...
22-
def __init__(self, env, engine, parser, preparser=...) -> None: ...
23-
def visit(self, node, **kwargs: Any): ...
24-
def visit_Module(self, node, **kwargs: Any): ...
25-
def visit_Expr(self, node, **kwargs: Any): ...
26-
def visit_BinOp(self, node, **kwargs: Any): ...
27-
def visit_Div(self, node, **kwargs: Any): ...
28-
def visit_UnaryOp(self, node, **kwargs: Any): ...
29-
def visit_Name(self, node, **kwargs: Any): ...
30-
def visit_NameConstant(self, node, **kwargs: Any): ...
31-
def visit_Num(self, node, **kwargs: Any): ...
32-
def visit_Constant(self, node, **kwargs: Any): ...
33-
def visit_Str(self, node, **kwargs: Any): ...
34-
def visit_List(self, node, **kwargs: Any): ...
35-
def visit_Index(self, node, **kwargs: Any): ...
36-
def visit_Subscript(self, node, **kwargs: Any): ...
37-
def visit_Slice(self, node, **kwargs: Any): ...
38-
def visit_Assign(self, node, **kwargs: Any): ...
39-
def visit_Attribute(self, node, **kwargs: Any): ...
40-
def visit_Call(self, node, side=..., **kwargs: Any): ...
41-
def translate_In(self, op): ...
42-
def visit_Compare(self, node, **kwargs: Any): ...
43-
def visit_BoolOp(self, node, **kwargs: Any): ...
4420

4521
class Expr:
4622
env: Scope
4723
engine: str
4824
parser: str
4925
expr = ...
5026
terms = ...
51-
def __init__(
52-
self,
53-
expr,
54-
engine: str = ...,
55-
parser: str = ...,
56-
env: Scope | None = ...,
57-
level: int = ...,
58-
) -> None: ...
59-
@property
60-
def assigner(self): ...
61-
def __call__(self): ...
62-
def __len__(self) -> int: ...
63-
def parse(self): ...
64-
@property
65-
def names(self): ...

pandas-stubs/core/computation/ops.pyi

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,34 @@ from typing import Any
33

44
import numpy as np
55

6-
class UndefinedVariableError(NameError):
7-
def __init__(self, name, is_local: bool = ...) -> None: ...
6+
class UndefinedVariableError(NameError): ...
87

98
class Term:
10-
def __new__(cls, name, env, side=..., encoding=...): ...
119
is_local: bool
1210
env = ...
1311
side = ...
1412
encoding = ...
15-
def __init__(self, name, env, side=..., encoding=...) -> None: ...
1613
@property
1714
def local_name(self) -> str: ...
18-
def __call__(self, *args: Any, **kwargs: Any): ...
19-
def evaluate(self, *args: Any, **kwargs: Any): ...
20-
def update(self, value) -> None: ...
2115
@property
2216
def is_scalar(self) -> bool: ...
23-
@property
24-
def type(self): ...
2517
return_type = ...
2618
@property
2719
def raw(self) -> str: ...
2820
@property
2921
def is_datetime(self) -> bool: ...
3022
@property
31-
def value(self): ...
32-
@value.setter
33-
def value(self, new_value) -> None: ...
34-
@property
35-
def name(self): ...
36-
@property
3723
def ndim(self) -> int: ...
3824

39-
class Constant(Term):
40-
@property
41-
def name(self): ...
25+
class Constant(Term): ...
4226

4327
class Op:
4428
op: str
4529
operands = ...
4630
encoding = ...
47-
def __init__(self, op: str, operands, *args: Any, **kwargs: Any) -> None: ...
48-
def __iter__(self): ...
49-
@property
50-
def return_type(self): ...
5131
@property
5232
def has_invalid_return_type(self) -> bool: ...
5333
@property
54-
def operand_types(self): ...
55-
@property
5634
def is_scalar(self) -> bool: ...
5735
@property
5836
def is_datetime(self) -> bool: ...
@@ -61,21 +39,14 @@ class BinOp(Op):
6139
lhs = ...
6240
rhs = ...
6341
func = ...
64-
def __init__(self, op: str, lhs, rhs, **kwargs: Any) -> None: ...
65-
def __call__(self, env): ...
66-
def evaluate(self, env, engine: str, parser, term_type, eval_in_python): ...
67-
def convert_values(self): ...
6842

69-
def isnumeric(dtype) -> bool: ...
43+
def isnumeric(dtype: type) -> bool: ...
7044

71-
class Div(BinOp):
72-
def __init__(self, lhs, rhs, **kwargs: Any) -> None: ...
45+
class Div(BinOp): ...
7346

7447
class UnaryOp(Op):
7548
operand = ...
7649
func = ...
77-
def __init__(self, op: str, operand) -> None: ...
78-
def __call__(self, env): ...
7950
if sys.version_info >= (3, 11):
8051
@property
8152
def return_type(self) -> np.dtype: ...
@@ -85,11 +56,8 @@ class UnaryOp(Op):
8556

8657
class MathCall(Op):
8758
func = ...
88-
def __init__(self, func, args) -> None: ...
89-
def __call__(self, env): ...
9059

9160
class FuncNode:
9261
name = ...
9362
func = ...
9463
def __init__(self, name: str) -> None: ...
95-
def __call__(self, *args: Any): ...

pandas-stubs/core/computation/pytables.pyi

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,87 +3,23 @@ from typing import Any
33
from pandas.core.computation import (
44
expr as expr,
55
ops as ops,
6-
scope as _scope,
76
)
87
from pandas.core.computation.expr import BaseExprVisitor as BaseExprVisitor
98
from pandas.core.indexes.base import Index
109

11-
class PyTablesScope(_scope.Scope):
12-
queryables: dict[str, Any]
13-
def __init__(
14-
self,
15-
level: int,
16-
global_dict=...,
17-
local_dict=...,
18-
queryables: dict[str, Any] | None = ...,
19-
) -> None: ...
20-
21-
class Term(ops.Term):
22-
env = ...
23-
def __new__(cls, name, env, side=..., encoding=...): ...
24-
def __init__(self, name, env: PyTablesScope, side=..., encoding=...) -> None: ...
25-
@property
26-
def value(self): ...
27-
@value.setter
28-
def value(self, new_value) -> None: ...
29-
30-
class Constant(Term):
31-
def __init__(self, name, env: PyTablesScope, side=..., encoding=...) -> None: ...
32-
3310
class BinOp(ops.BinOp):
3411
op: str
3512
queryables: dict[str, Any]
3613
encoding = ...
3714
condition = ...
38-
def __init__(
39-
self, op: str, lhs, rhs, queryables: dict[str, Any], encoding
40-
) -> None: ...
41-
def prune(self, klass): ...
42-
def conform(self, rhs): ...
4315
@property
4416
def is_valid(self) -> bool: ...
4517
@property
4618
def is_in_table(self) -> bool: ...
47-
@property
48-
def kind(self): ...
49-
@property
50-
def meta(self): ...
51-
@property
52-
def metadata(self): ...
53-
def generate(self, v) -> str: ...
54-
def convert_value(self, v) -> TermValue: ...
5519
def convert_values(self) -> None: ...
5620

5721
class FilterBinOp(BinOp):
5822
filter: tuple[Any, Any, Index] | None = ...
59-
def invert(self): ...
60-
def format(self): ...
61-
def generate_filter_op(self, invert: bool = ...): ...
62-
63-
class JointFilterBinOp(FilterBinOp):
64-
def format(self) -> None: ...
65-
66-
class ConditionBinOp(BinOp):
67-
def invert(self) -> None: ...
68-
def format(self): ...
69-
condition = ...
70-
71-
class JointConditionBinOp(ConditionBinOp):
72-
condition = ...
73-
74-
class UnaryOp(ops.UnaryOp):
75-
def prune(self, klass): ...
76-
77-
class PyTablesExprVisitor(BaseExprVisitor):
78-
const_type = ...
79-
term_type = ...
80-
def __init__(self, env, engine, parser, **kwargs: Any) -> None: ...
81-
def visit_UnaryOp(self, node, **kwargs: Any): ...
82-
def visit_Index(self, node, **kwargs: Any): ...
83-
def visit_Assign(self, node, **kwargs: Any): ...
84-
def visit_Subscript(self, node, **kwargs: Any): ...
85-
def visit_Attribute(self, node, **kwargs: Any): ...
86-
def translate_In(self, op): ...
8723

8824
class PyTablesExpr(expr.Expr):
8925
encoding = ...
@@ -93,16 +29,13 @@ class PyTablesExpr(expr.Expr):
9329
expr = ...
9430
def __init__(
9531
self,
96-
where,
32+
where: Any,
9733
queryables: dict[str, Any] | None = ...,
98-
encoding=...,
34+
encoding: Any = ...,
9935
scope_level: int = ...,
10036
) -> None: ...
101-
def evaluate(self): ...
10237

10338
class TermValue:
10439
value = ...
10540
converted = ...
10641
kind = ...
107-
def __init__(self, value, converted, kind: str) -> None: ...
108-
def tostring(self, encoding) -> str: ...

pandas-stubs/core/computation/scope.pyi

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@ class Scope:
44
target = ...
55
resolvers = ...
66
temps = ...
7-
def __init__(
8-
self, level, global_dict=..., local_dict=..., resolvers=..., target=...
9-
) -> None: ...
107
@property
118
def has_resolvers(self) -> bool: ...
12-
def resolve(self, key: str, is_local: bool): ...
13-
def swapkey(self, old_key: str, new_key: str, new_value=...): ...
14-
def add_tmp(self, value) -> str: ...
159
@property
1610
def ntemps(self) -> int: ...
17-
@property
18-
def full_scope(self): ...

pandas-stubs/core/groupby/ops.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from collections.abc import (
2-
Iterator,
3-
)
1+
from collections.abc import Iterator
42
from typing import Generic
53

64
from pandas._typing import (

pandas-stubs/io/api.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ from pandas.io.parsers import (
1414
read_fwf as read_fwf,
1515
read_table as read_table,
1616
)
17-
from pandas.io.pickle import (
18-
read_pickle as read_pickle,
19-
)
17+
from pandas.io.pickle import read_pickle as read_pickle
2018
from pandas.io.pytables import (
2119
HDFStore as HDFStore,
2220
read_hdf as read_hdf,

pandas-stubs/io/json/__init__.pyi

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from pandas.io.json._json import (
2-
read_json as read_json,
3-
)
1+
from pandas.io.json._json import read_json as read_json
42

53
# below are untyped imports so commented out
64
# to_json as to_json,; ujson_dumps as ujson_dumps,; ujson_loads as ujson_loads,

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ ignore = [
205205
"PYI042", # https://docs.astral.sh/ruff/rules/snake-case-type-alias/
206206
"ERA001", "PLR0402", "PLC0105"
207207
]
208-
"*computation*" = [
209-
# TODO: remove when computations are fully typed
208+
"*window*" = [
209+
# TODO: remove when window is fully typed
210210
"ANN001", "ANN201", "ANN204", "ANN206",
211211
]
212212
"*generic.pyi" = [

tests/indexes/bool/test_add.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import pandas as pd
44
from typing_extensions import assert_type
55

6-
from tests import (
7-
check,
8-
)
6+
from tests import check
97
from tests._typing import (
108
np_ndarray_bool,
119
np_ndarray_int64,

0 commit comments

Comments
 (0)