Skip to content

Commit 5544b6d

Browse files
TYP: annotation of __init__ return type (PEP 484) (pandas-dev#46254)
1 parent 622c92d commit 5544b6d

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

pandas/core/computation/engines.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AbstractEngine(metaclass=abc.ABCMeta):
4848

4949
has_neg_frac = False
5050

51-
def __init__(self, expr):
51+
def __init__(self, expr) -> None:
5252
self.expr = expr
5353
self.aligned_axes = None
5454
self.result_type = None

pandas/core/computation/expr.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ class BaseExprVisitor(ast.NodeVisitor):
393393

394394
unsupported_nodes: tuple[str, ...]
395395

396-
def __init__(self, env, engine, parser, preparser=_preparse):
396+
def __init__(self, env, engine, parser, preparser=_preparse) -> None:
397397
self.env = env
398398
self.engine = engine
399399
self.parser = parser
@@ -768,13 +768,13 @@ def __init__(
768768
_preparse,
769769
f=_compose(_replace_locals, _replace_booleans, clean_backtick_quoted_toks),
770770
),
771-
):
771+
) -> None:
772772
super().__init__(env, engine, parser, preparser)
773773

774774

775775
@disallow(_unsupported_nodes | _python_not_supported | frozenset(["Not"]))
776776
class PythonExprVisitor(BaseExprVisitor):
777-
def __init__(self, env, engine, parser, preparser=lambda x: x):
777+
def __init__(self, env, engine, parser, preparser=lambda x: x) -> None:
778778
super().__init__(env, engine, parser, preparser=preparser)
779779

780780

@@ -802,7 +802,7 @@ def __init__(
802802
parser: str = "pandas",
803803
env: Scope | None = None,
804804
level: int = 0,
805-
):
805+
) -> None:
806806
self.expr = expr
807807
self.env = env or Scope(level=level + 1)
808808
self.engine = engine

pandas/core/computation/ops.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class UndefinedVariableError(NameError):
7070
NameError subclass for local variables.
7171
"""
7272

73-
def __init__(self, name: str, is_local: bool | None = None):
73+
def __init__(self, name: str, is_local: bool | None = None) -> None:
7474
base_msg = f"{repr(name)} is not defined"
7575
if is_local:
7676
msg = f"local variable {base_msg}"
@@ -88,7 +88,7 @@ def __new__(cls, name, env, side=None, encoding=None):
8888

8989
is_local: bool
9090

91-
def __init__(self, name, env, side=None, encoding=None):
91+
def __init__(self, name, env, side=None, encoding=None) -> None:
9292
# name is a str for Term, but may be something else for subclasses
9393
self._name = name
9494
self.env = env
@@ -189,7 +189,7 @@ def ndim(self) -> int:
189189

190190

191191
class Constant(Term):
192-
def __init__(self, value, env, side=None, encoding=None):
192+
def __init__(self, value, env, side=None, encoding=None) -> None:
193193
super().__init__(value, env, side=side, encoding=encoding)
194194

195195
def _resolve_name(self):
@@ -215,7 +215,7 @@ class Op:
215215

216216
op: str
217217

218-
def __init__(self, op: str, operands: Iterable[Term | Op], encoding=None):
218+
def __init__(self, op: str, operands: Iterable[Term | Op], encoding=None) -> None:
219219
self.op = _bool_op_map.get(op, op)
220220
self.operands = operands
221221
self.encoding = encoding
@@ -375,7 +375,7 @@ class BinOp(Op):
375375
rhs : Term or Op
376376
"""
377377

378-
def __init__(self, op: str, lhs, rhs):
378+
def __init__(self, op: str, lhs, rhs) -> None:
379379
super().__init__(op, (lhs, rhs))
380380
self.lhs = lhs
381381
self.rhs = rhs
@@ -530,7 +530,7 @@ class Div(BinOp):
530530
The Terms or Ops in the ``/`` expression.
531531
"""
532532

533-
def __init__(self, lhs, rhs):
533+
def __init__(self, lhs, rhs) -> None:
534534
super().__init__("/", lhs, rhs)
535535

536536
if not isnumeric(lhs.return_type) or not isnumeric(rhs.return_type):
@@ -566,7 +566,7 @@ class UnaryOp(Op):
566566
* If no function associated with the passed operator token is found.
567567
"""
568568

569-
def __init__(self, op: str, operand):
569+
def __init__(self, op: str, operand) -> None:
570570
super().__init__(op, (operand,))
571571
self.operand = operand
572572

@@ -598,7 +598,7 @@ def return_type(self) -> np.dtype:
598598

599599

600600
class MathCall(Op):
601-
def __init__(self, func, args):
601+
def __init__(self, func, args) -> None:
602602
super().__init__(func.name, args)
603603
self.func = func
604604

@@ -614,7 +614,7 @@ def __repr__(self) -> str:
614614

615615

616616
class FuncNode:
617-
def __init__(self, name: str):
617+
def __init__(self, name: str) -> None:
618618
if name not in MATHOPS:
619619
raise ValueError(f'"{name}" is not a supported function')
620620
self.name = name

pandas/core/computation/pytables.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848
global_dict=None,
4949
local_dict=None,
5050
queryables: dict[str, Any] | None = None,
51-
):
51+
) -> None:
5252
super().__init__(level + 1, global_dict=global_dict, local_dict=local_dict)
5353
self.queryables = queryables or {}
5454

@@ -63,7 +63,7 @@ def __new__(cls, name, env, side=None, encoding=None):
6363
klass = Constant
6464
return object.__new__(klass)
6565

66-
def __init__(self, name, env: PyTablesScope, side=None, encoding=None):
66+
def __init__(self, name, env: PyTablesScope, side=None, encoding=None) -> None:
6767
super().__init__(name, env, side=side, encoding=encoding)
6868

6969
def _resolve_name(self):
@@ -87,7 +87,7 @@ def value(self):
8787

8888

8989
class Constant(Term):
90-
def __init__(self, value, env: PyTablesScope, side=None, encoding=None):
90+
def __init__(self, value, env: PyTablesScope, side=None, encoding=None) -> None:
9191
assert isinstance(env, PyTablesScope), type(env)
9292
super().__init__(value, env, side=side, encoding=encoding)
9393

@@ -103,7 +103,7 @@ class BinOp(ops.BinOp):
103103
queryables: dict[str, Any]
104104
condition: str | None
105105

106-
def __init__(self, op: str, lhs, rhs, queryables: dict[str, Any], encoding):
106+
def __init__(self, op: str, lhs, rhs, queryables: dict[str, Any], encoding) -> None:
107107
super().__init__(op, lhs, rhs)
108108
self.queryables = queryables
109109
self.encoding = encoding
@@ -407,7 +407,7 @@ class PyTablesExprVisitor(BaseExprVisitor):
407407
const_type = Constant
408408
term_type = Term
409409

410-
def __init__(self, env, engine, parser, **kwargs):
410+
def __init__(self, env, engine, parser, **kwargs) -> None:
411411
super().__init__(env, engine, parser)
412412
for bin_op in self.binary_ops:
413413
bin_node = self.binary_op_nodes_map[bin_op]
@@ -552,7 +552,7 @@ def __init__(
552552
queryables: dict[str, Any] | None = None,
553553
encoding=None,
554554
scope_level: int = 0,
555-
):
555+
) -> None:
556556

557557
where = _validate_where(where)
558558

@@ -624,7 +624,7 @@ def evaluate(self):
624624
class TermValue:
625625
"""hold a term value the we use to construct a condition/filter"""
626626

627-
def __init__(self, value, converted, kind: str):
627+
def __init__(self, value, converted, kind: str) -> None:
628628
assert isinstance(kind, str), kind
629629
self.value = value
630630
self.converted = converted

pandas/core/computation/scope.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Scope:
113113

114114
def __init__(
115115
self, level: int, global_dict=None, local_dict=None, resolvers=(), target=None
116-
):
116+
) -> None:
117117
self.level = level + 1
118118

119119
# shallow copy because we don't want to keep filling this up with what

0 commit comments

Comments
 (0)