Skip to content

Commit 949592a

Browse files
TYP: clean for PY3.8 (final) (#42422)
1 parent b4aa48f commit 949592a

File tree

14 files changed

+33
-35
lines changed

14 files changed

+33
-35
lines changed

pandas/_libs/internals.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import (
22
Iterator,
33
Sequence,
4+
final,
45
overload,
56
)
67

@@ -50,10 +51,12 @@ class SharedBlock:
5051

5152
class NumpyBlock(SharedBlock):
5253
values: np.ndarray
54+
@final
5355
def getitem_block_index(self: T, slicer: slice) -> T: ...
5456

5557
class NDArrayBackedBlock(SharedBlock):
5658
values: NDArrayBackedExtensionArray
59+
@final
5760
def getitem_block_index(self: T, slicer: slice) -> T: ...
5861

5962
class Block(SharedBlock): ...

pandas/_libs/internals.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ cdef class NumpyBlock(SharedBlock):
517517
# set placement and ndim
518518
self.values = values
519519

520-
# @final # not useful in cython, but we _would_ annotate with @final
521520
cpdef NumpyBlock getitem_block_index(self, slice slicer):
522521
"""
523522
Perform __getitem__-like specialized to slicing along index.
@@ -540,7 +539,6 @@ cdef class NDArrayBackedBlock(SharedBlock):
540539
# set placement and ndim
541540
self.values = values
542541

543-
# @final # not useful in cython, but we _would_ annotate with @final
544542
cpdef NDArrayBackedBlock getitem_block_index(self, slice slicer):
545543
"""
546544
Perform __getitem__-like specialized to slicing along index.

pandas/_typing.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
# and use a string literal forward reference to it in subsequent types
3838
# https://mypy.readthedocs.io/en/latest/common_issues.html#import-cycles
3939
if TYPE_CHECKING:
40-
from typing import (
41-
TypedDict,
42-
final,
43-
)
40+
from typing import TypedDict
4441

4542
import numpy.typing as npt
4643

@@ -76,8 +73,6 @@
7673
from pandas.tseries.offsets import DateOffset
7774
else:
7875
npt: Any = None
79-
# typing.final does not exist until py38
80-
final = lambda x: x
8176
# typing.TypedDict does not exist until py38
8277
TypedDict = dict
8378

pandas/core/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Literal,
1414
TypeVar,
1515
cast,
16+
final,
1617
)
1718

1819
import numpy as np
@@ -24,7 +25,6 @@
2425
FrameOrSeries,
2526
IndexLabel,
2627
Shape,
27-
final,
2828
npt,
2929
)
3030
from pandas.compat import PYPY

pandas/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Mapping,
1919
Sequence,
2020
cast,
21+
final,
2122
overload,
2223
)
2324
import warnings
@@ -54,7 +55,6 @@
5455
TimedeltaConvertibleTypes,
5556
TimestampConvertibleTypes,
5657
ValueKeyFunc,
57-
final,
5858
npt,
5959
)
6060
from pandas.compat._optional import import_optional_dependency

pandas/core/groupby/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class providing the base-class of operations.
2929
TypeVar,
3030
Union,
3131
cast,
32+
final,
3233
)
3334
import warnings
3435

@@ -49,7 +50,6 @@ class providing the base-class of operations.
4950
RandomState,
5051
Scalar,
5152
T,
52-
final,
5353
)
5454
from pandas.compat.numpy import function as nv
5555
from pandas.errors import AbstractMethodError

pandas/core/groupby/grouper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
"""
55
from __future__ import annotations
66

7-
from typing import Hashable
7+
from typing import (
8+
Hashable,
9+
final,
10+
)
811
import warnings
912

1013
import numpy as np
1114

1215
from pandas._typing import (
1316
ArrayLike,
1417
FrameOrSeries,
15-
final,
1618
)
1719
from pandas.errors import InvalidIndexError
1820
from pandas.util._decorators import cache_readonly

pandas/core/groupby/ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Hashable,
1515
Iterator,
1616
Sequence,
17+
final,
1718
overload,
1819
)
1920

@@ -31,7 +32,6 @@
3132
F,
3233
FrameOrSeries,
3334
Shape,
34-
final,
3535
npt,
3636
)
3737
from pandas.errors import AbstractMethodError

pandas/core/indexes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Sequence,
1414
TypeVar,
1515
cast,
16+
final,
1617
overload,
1718
)
1819
import warnings
@@ -44,7 +45,6 @@
4445
F,
4546
Shape,
4647
T,
47-
final,
4848
npt,
4949
)
5050
from pandas.compat.numpy import function as nv

pandas/core/indexes/datetimelike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Sequence,
1212
TypeVar,
1313
cast,
14+
final,
1415
)
1516
import warnings
1617

@@ -28,7 +29,6 @@
2829
Tick,
2930
parsing,
3031
)
31-
from pandas._typing import final
3232
from pandas.compat.numpy import function as nv
3333
from pandas.util._decorators import (
3434
Appender,

0 commit comments

Comments
 (0)