Skip to content

Commit 801bb24

Browse files
authored
TYP: Update typing for 3.10 (#61453)
* update typing for 3.10 * add 2 more TypeAlias * add 2 more TypeAlias * fix hook for stubtest - make it work on Windows. remove combine from nattype.pyi
1 parent 6879598 commit 801bb24

22 files changed

+177
-180
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ repos:
140140
pass_filenames: false
141141
types: [python]
142142
stages: [manual]
143-
- id: mypy
143+
- id: stubtest
144144
# note: assumes python env is setup and activated
145145
# note: requires pandas dev to be installed
146146
name: mypy (stubtest)

pandas/_libs/arrays.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33
import numpy as np
44

pandas/_libs/hashtable.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from collections.abc import Hashable
12
from typing import (
23
Any,
3-
Hashable,
44
Literal,
55
overload,
66
)

pandas/_libs/internals.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from typing import (
1+
from collections.abc import (
22
Iterator,
33
Sequence,
4+
)
5+
from typing import (
46
final,
57
overload,
68
)

pandas/_libs/json.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from collections.abc import Callable
12
from typing import (
23
Any,
3-
Callable,
44
)
55

66
def ujson_dumps(

pandas/_libs/lib.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# TODO(npdtypes): Many types specified here can be made more specific/accurate;
22
# the more specific versions are specified in comments
3+
from collections.abc import (
4+
Callable,
5+
Generator,
6+
Hashable,
7+
)
38
from decimal import Decimal
49
from typing import (
510
Any,
6-
Callable,
711
Final,
8-
Generator,
9-
Hashable,
1012
Literal,
1113
TypeAlias,
1214
overload,

pandas/_libs/ops.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
from typing import (
2-
Any,
1+
from collections.abc import (
32
Callable,
43
Iterable,
4+
)
5+
from typing import (
6+
Any,
57
Literal,
68
TypeAlias,
79
overload,

pandas/_libs/parsers.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
from collections.abc import Hashable
12
from typing import (
2-
Hashable,
33
Literal,
44
)
55

pandas/_libs/properties.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
from collections.abc import Sequence
12
from typing import (
2-
Sequence,
33
overload,
44
)
55

pandas/_libs/sparse.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33
import numpy as np
44

pandas/_libs/testing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Mapping
1+
from collections.abc import Mapping
22

33
def assert_dict_equal(a: Mapping, b: Mapping, compare_keys: bool = ...) -> bool: ...
44
def assert_almost_equal(

pandas/_libs/tslibs/nattype.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from datetime import (
2-
date as date_,
32
datetime,
4-
time as time_,
53
timedelta,
64
tzinfo as _tzinfo,
75
)
@@ -99,7 +97,6 @@ class NaTType:
9997
ambiguous: bool | Literal["raise"] | NaTType = ...,
10098
nonexistent: TimestampNonexistent = ...,
10199
) -> NaTType: ...
102-
def combine(cls, date: date_, time: time_) -> NoReturn: ...
103100
@property
104101
def tzinfo(self) -> None: ...
105102
@property

pandas/_libs/tslibs/offsets.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from collections.abc import Collection
12
from datetime import (
23
datetime,
34
time,
45
timedelta,
56
)
67
from typing import (
78
Any,
8-
Collection,
99
Literal,
1010
TypeVar,
1111
overload,

pandas/_libs/tslibs/timezones.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from collections.abc import Callable
12
from datetime import (
23
datetime,
34
tzinfo,
45
)
5-
from typing import Callable
66

77
import numpy as np
88

pandas/_libs/tslibs/tzconversion.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from collections.abc import Iterable
12
from datetime import (
23
timedelta,
34
tzinfo,
45
)
5-
from typing import Iterable
66

77
import numpy as np
88

pandas/_libs/window/aggregations.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from collections.abc import Callable
12
from typing import (
23
Any,
3-
Callable,
44
Literal,
55
)
66

pandas/_libs/window/aggregations.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,8 @@ def roll_quantile(const float64_t[:] values, ndarray[int64_t] start,
13541354
if interpolation_type == LINEAR:
13551355
vlow = skiplist_get(skiplist, idx, &ret)
13561356
vhigh = skiplist_get(skiplist, idx + 1, &ret)
1357-
output[i] = ((vlow + (vhigh - vlow) *
1358-
(idx_with_fraction - idx)))
1357+
output[i] = (vlow + (vhigh - vlow) *
1358+
(idx_with_fraction - idx))
13591359
elif interpolation_type == LOWER:
13601360
output[i] = skiplist_get(skiplist, idx, &ret)
13611361
elif interpolation_type == HIGHER:

pandas/_testing/contexts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from contextlib import contextmanager
44
import os
55
from pathlib import Path
6+
import sys
67
import tempfile
78
from typing import (
89
IO,
@@ -81,7 +82,9 @@ def setTZ(tz) -> None:
8182
pass
8283
else:
8384
os.environ["TZ"] = tz
84-
time.tzset()
85+
# Next line allows typing checks to pass on Windows
86+
if sys.platform != "win32":
87+
time.tzset()
8588

8689
orig_tz = os.environ.get("TZ")
8790
setTZ(tz)

0 commit comments

Comments
 (0)