Skip to content

Commit b98d48a

Browse files
committed
Merge branch 'main' into tst-string-xfails
2 parents 3102045 + a3d9049 commit b98d48a

30 files changed

+275
-413
lines changed

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ jobs:
140140

141141
moto:
142142
image: motoserver/moto:5.0.27
143-
env:
144-
AWS_ACCESS_KEY_ID: foobar_key
145-
AWS_SECRET_ACCESS_KEY: foobar_secret
146143
ports:
147144
- 5000:5000
148145

environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ dependencies:
6464
- dask-core
6565
- seaborn-base
6666

67-
# local testing dependencies
67+
# Mocking s3 tests
6868
- moto
69-
- flask
7069

7170
# benchmarks
7271
- asv>=0.6.1

pandas/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,3 +2116,9 @@ def temp_file(tmp_path):
21162116
file_path = tmp_path / str(uuid.uuid4())
21172117
file_path.touch()
21182118
return file_path
2119+
2120+
2121+
@pytest.fixture(scope="session")
2122+
def monkeysession():
2123+
with pytest.MonkeyPatch.context() as mp:
2124+
yield mp

pandas/core/apply.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
TYPE_CHECKING,
1111
Any,
1212
Literal,
13+
TypeAlias,
1314
cast,
1415
)
1516

@@ -71,7 +72,7 @@
7172
from pandas.core.resample import Resampler
7273
from pandas.core.window.rolling import BaseWindow
7374

74-
ResType = dict[int, Any]
75+
ResType: TypeAlias = dict[int, Any]
7576

7677

7778
class BaseExecutionEngine(abc.ABC):

pandas/core/arrays/datetimelike.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
TYPE_CHECKING,
1111
Any,
1212
Literal,
13+
TypeAlias,
1314
Union,
1415
cast,
1516
final,
@@ -161,7 +162,7 @@
161162
TimedeltaArray,
162163
)
163164

164-
DTScalarOrNaT = Union[DatetimeLikeScalar, NaTType]
165+
DTScalarOrNaT: TypeAlias = DatetimeLikeScalar | NaTType
165166

166167

167168
def _make_unpacked_invalid_op(op_name: str):
@@ -386,7 +387,7 @@ def __getitem__(self, key: PositionalIndexer2D) -> Self | DTScalarOrNaT:
386387
# Use cast as we know we will get back a DatetimeLikeArray or DTScalar,
387388
# but skip evaluating the Union at runtime for performance
388389
# (see https://github.com/pandas-dev/pandas/pull/44624)
389-
result = cast("Union[Self, DTScalarOrNaT]", super().__getitem__(key))
390+
result = cast(Union[Self, DTScalarOrNaT], super().__getitem__(key))
390391
if lib.is_scalar(result):
391392
return result
392393
else:

pandas/core/arrays/interval.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import (
1010
TYPE_CHECKING,
1111
Literal,
12-
Union,
12+
TypeAlias,
1313
overload,
1414
)
1515

@@ -109,8 +109,8 @@
109109
)
110110

111111

112-
IntervalSide = Union[TimeArrayLike, np.ndarray]
113-
IntervalOrNA = Union[Interval, float]
112+
IntervalSide: TypeAlias = TimeArrayLike | np.ndarray
113+
IntervalOrNA: TypeAlias = Interval | float
114114

115115
_interval_shared_docs: dict[str, str] = {}
116116

pandas/core/arrays/string_arrow.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55
from typing import (
66
TYPE_CHECKING,
7-
Union,
87
)
98
import warnings
109

@@ -63,9 +62,6 @@
6362
from pandas import Series
6463

6564

66-
ArrowStringScalarOrNAT = Union[str, libmissing.NAType]
67-
68-
6965
def _chk_pyarrow_available() -> None:
7066
if pa_version_under10p1:
7167
msg = "pyarrow>=10.0.1 is required for PyArrow backed ArrowExtensionArray."

pandas/core/groupby/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
Any,
1818
Literal,
1919
NamedTuple,
20+
TypeAlias,
2021
TypeVar,
21-
Union,
2222
cast,
2323
)
2424
import warnings
@@ -102,7 +102,7 @@
102102
from pandas.core.generic import NDFrame
103103

104104
# TODO(typing) the return value on this callable should be any *scalar*.
105-
AggScalar = Union[str, Callable[..., Any]]
105+
AggScalar: TypeAlias = str | Callable[..., Any]
106106
# TODO: validate types on ScalarResult and move to _typing
107107
# Blocked from using by https://github.com/python/mypy/issues/1484
108108
# See note at _mangle_lambda_list

pandas/core/groupby/groupby.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class providing the base-class of operations.
2626
from typing import (
2727
TYPE_CHECKING,
2828
Literal,
29+
TypeAlias,
2930
TypeVar,
3031
Union,
3132
cast,
@@ -449,13 +450,13 @@ def f(self):
449450
return attr
450451

451452

452-
_KeysArgType = Union[
453-
Hashable,
454-
list[Hashable],
455-
Callable[[Hashable], Hashable],
456-
list[Callable[[Hashable], Hashable]],
457-
Mapping[Hashable, Hashable],
458-
]
453+
_KeysArgType: TypeAlias = (
454+
Hashable
455+
| list[Hashable]
456+
| Callable[[Hashable], Hashable]
457+
| list[Callable[[Hashable], Hashable]]
458+
| Mapping[Hashable, Hashable]
459+
)
459460

460461

461462
class BaseGroupBy(PandasObject, SelectionMixin[NDFrameT], GroupByIndexingMixin):
@@ -957,9 +958,8 @@ def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]:
957958
level = self.level
958959
result = self._grouper.get_iterator(self._selected_obj)
959960
# mypy: Argument 1 to "len" has incompatible type "Hashable"; expected "Sized"
960-
if (
961-
(is_list_like(level) and len(level) == 1) # type: ignore[arg-type]
962-
or (isinstance(keys, list) and len(keys) == 1)
961+
if (is_list_like(level) and len(level) == 1) or ( # type: ignore[arg-type]
962+
isinstance(keys, list) and len(keys) == 1
963963
):
964964
# GH#42795 - when keys is a list, return tuples even when length is 1
965965
result = (((key,), group) for key, group in result)

pandas/core/indexing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import (
66
TYPE_CHECKING,
77
Any,
8-
TypeVar,
98
cast,
109
final,
1110
)
@@ -83,6 +82,7 @@
8382
Axis,
8483
AxisInt,
8584
Self,
85+
T,
8686
npt,
8787
)
8888

@@ -91,7 +91,6 @@
9191
Series,
9292
)
9393

94-
T = TypeVar("T")
9594
# "null slice"
9695
_NS = slice(None, None)
9796
_one_ellipsis_message = "indexer may only contain one '...' entry"

0 commit comments

Comments
 (0)