Skip to content

Commit bd8f881

Browse files
authored
annotate some variables, remove some unused (#39466)
1 parent 067d4fd commit bd8f881

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

pandas/_config/display.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
import locale
66
import sys
7+
from typing import Optional
78

89
from pandas._config import config as cf
910

1011
# -----------------------------------------------------------------------------
1112
# Global formatting options
12-
_initial_defencoding = None
13+
_initial_defencoding: Optional[str] = None
1314

1415

1516
def detect_console_encoding() -> str:

pandas/core/computation/expressions.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
77
"""
88
import operator
9-
from typing import List, Set
9+
from typing import List, Optional, Set
1010
import warnings
1111

1212
import numpy as np
1313

1414
from pandas._config import get_option
1515

16+
from pandas._typing import FuncType
17+
1618
from pandas.core.dtypes.generic import ABCDataFrame
1719

1820
from pandas.core.computation.check import NUMEXPR_INSTALLED
@@ -21,11 +23,11 @@
2123
if NUMEXPR_INSTALLED:
2224
import numexpr as ne
2325

24-
_TEST_MODE = None
26+
_TEST_MODE: Optional[bool] = None
2527
_TEST_RESULT: List[bool] = []
2628
USE_NUMEXPR = NUMEXPR_INSTALLED
27-
_evaluate = None
28-
_where = None
29+
_evaluate: Optional[FuncType] = None
30+
_where: Optional[FuncType] = None
2931

3032
# the set of dtypes that we will allow pass to numexpr
3133
_ALLOWED_DTYPES = {

pandas/core/generic.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class NDFrame(PandasObject, SelectionMixin, indexing.IndexingMixin):
180180
["_AXIS_NAMES", "_AXIS_NUMBERS", "get_values", "tshift"]
181181
)
182182
_metadata: List[str] = []
183-
_is_copy = None
183+
_is_copy: Optional[weakref.ReferenceType[NDFrame]] = None
184184
_mgr: Manager
185185
_attrs: Dict[Optional[Hashable], Any]
186186
_typ: str
@@ -389,7 +389,6 @@ def _data(self):
389389
# Axis
390390
_stat_axis_number = 0
391391
_stat_axis_name = "index"
392-
_ix = None
393392
_AXIS_ORDERS: List[str]
394393
_AXIS_TO_AXIS_NUMBER: Dict[Axis, int] = {0: 0, "index": 0, "rows": 0}
395394
_AXIS_REVERSED: bool
@@ -3815,7 +3814,7 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries:
38153814
return result
38163815

38173816
@final
3818-
def _set_is_copy(self, ref, copy: bool_t = True) -> None:
3817+
def _set_is_copy(self, ref: FrameOrSeries, copy: bool_t = True) -> None:
38193818
if not copy:
38203819
self._is_copy = None
38213820
else:

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def _constructor_expanddim(self) -> Type[DataFrame]:
444444
def _can_hold_na(self) -> bool:
445445
return self._mgr._can_hold_na
446446

447-
_index = None
447+
_index: Optional[Index] = None
448448

449449
def _set_axis(self, axis: int, labels, fastpath: bool = False) -> None:
450450
"""

pandas/io/excel/_base.py

-1
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,6 @@ def __new__(cls, path, engine=None, **kwargs):
758758
return object.__new__(cls)
759759

760760
# declare external properties you can count on
761-
curr_sheet = None
762761
path = None
763762

764763
@property

pandas/io/excel/_util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import List
1+
from typing import List, MutableMapping
22

33
from pandas.compat._optional import import_optional_dependency
44

55
from pandas.core.dtypes.common import is_integer, is_list_like
66

7-
_writers = {}
7+
_writers: MutableMapping[str, str] = {}
88

99

1010
def register_writer(klass):

pandas/io/sql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DatabaseError(IOError):
3535
# -----------------------------------------------------------------------------
3636
# -- Helper functions
3737

38-
_SQLALCHEMY_INSTALLED = None
38+
_SQLALCHEMY_INSTALLED: Optional[bool] = None
3939

4040

4141
def _is_sqlalchemy_connectable(con):

0 commit comments

Comments
 (0)