Skip to content

TYP: future annotations #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10']
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: pyupgrade
types_or: [python, pyi]
types: [text] # overwrite types: [python]
args: [--py38-plus, --keep-runtime-typing]
args: [--py38-plus]
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
Expand All @@ -30,7 +30,7 @@ repos:
- flake8-pyi==22.5.1
types: [pyi]
args: [
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y022 Y026 Y027 Y034 Y037,
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y026 Y027 Y034 Y037,
# TypeVars in private files are already private
--per-file-ignores=_*.pyi:Y001
]
2 changes: 2 additions & 0 deletions pandas-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import pandas.testing as testing

from . import (
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_config/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .config import (
describe_option as describe_option,
get_option as get_option,
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_config/config.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from contextlib import ContextDecorator
from typing import (
Any,
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from .interval import Interval as Interval
from .tslibs import (
NaT as NaT,
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/indexing.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

class _NDFrameIndexerBase:
def __init__(self, name: str, obj: object) -> None: ...
@property
Expand Down
23 changes: 9 additions & 14 deletions pandas-stubs/_libs/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ from typing import (
Any,
Generic,
TypeVar,
Union,
overload,
)

Expand Down Expand Up @@ -79,9 +78,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
@overload
def __contains__(self: Interval[_OrderableTimesT], _OrderableTimesT) -> bool: ...
@overload
def __contains__(
self: Interval[_OrderableScalarT], key: Union[int, float]
) -> bool: ...
def __contains__(self: Interval[_OrderableScalarT], key: int | float) -> bool: ...
@overload
def __add__(
self: Interval[_OrderableTimesT], y: Timedelta
Expand All @@ -91,7 +88,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __add__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ...
def __add__(self: Interval[float], y: int | float) -> Interval[float]: ...
@overload
def __radd__(
self: Interval[_OrderableTimesT], y: Timedelta
Expand All @@ -101,7 +98,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __radd__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ...
def __radd__(self: Interval[float], y: int | float) -> Interval[float]: ...
@overload
def __sub__(
self: Interval[_OrderableTimesT], y: Timedelta
Expand All @@ -111,7 +108,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __sub__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ...
def __sub__(self: Interval[float], y: int | float) -> Interval[float]: ...
@overload
def __rsub__(
self: Interval[_OrderableTimesT], y: Timedelta
Expand All @@ -121,33 +118,31 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __rsub__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ...
def __rsub__(self: Interval[float], y: int | float) -> Interval[float]: ...
@overload
def __mul__(
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __mul__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ...
def __mul__(self: Interval[float], y: int | float) -> Interval[float]: ...
@overload
def __rmul__(
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __rmul__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ...
def __rmul__(self: Interval[float], y: int | float) -> Interval[float]: ...
@overload
def __truediv__(
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __truediv__(self: Interval[float], y: Union[int, float]) -> Interval[float]: ...
def __truediv__(self: Interval[float], y: int | float) -> Interval[float]: ...
@overload
def __floordiv__(
self: Interval[int], y: _OrderableScalarT
) -> Interval[_OrderableScalarT]: ...
@overload
def __floordiv__(
self: Interval[float], y: Union[int, float]
) -> Interval[float]: ...
def __floordiv__(self: Interval[float], y: int | float) -> Interval[float]: ...
def overlaps(self: Interval[_OrderableT], other: Interval[_OrderableT]) -> bool: ...

def intervals_to_interval_bounds(
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/json.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

def decode(*args, **kwargs): ...
def dumps(*args, **kwargs): ...
def encode(*args, **kwargs): ...
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/lib.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

no_default = None

def infer_dtype(value: object, skipna: bool = ...) -> str: ...
6 changes: 2 additions & 4 deletions pandas-stubs/_libs/missing.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from typing import Union

class NAType:
def __new__(cls, *args, **kwargs) -> NAType: ...
def __format__(self, format_spec: str) -> str: ...
Expand Down Expand Up @@ -36,9 +34,9 @@ class NAType:
def __invert__(self, other) -> NAType: ...
def __pow__(self, other) -> NAType: ...
def __rpow__(self, other) -> NAType: ...
def __and__(self, other) -> Union[None, NAType]: ...
def __and__(self, other) -> NAType | None: ...
__rand__ = __and__
def __or__(self, other) -> Union[bool, NAType]: ...
def __or__(self, other) -> bool | NAType: ...
__ror__ = __or__
def __xor__(self, other) -> NAType: ...
__rxor__ = __xor__
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/ops_dispatch.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

DISPATCHED_UFUNCS = ...
REVERSED_NAMES = ...
UFUNC_ALIASES = ...
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/properties.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Callable

class CachedProperty:
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/sparse.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

class SparseIndex: ...
class BlockIndex(SparseIndex): ...
class IntIndex(SparseIndex): ...
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

__all__ = [
"Period",
"Timestamp",
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/base.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import datetime

class ABCTimestamp(datetime): ...
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/ccalendar.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Sequence

def dayofweek(y: int, m: int, d: int) -> int: ...
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/conversion.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import datetime

def localize_pydatetime(dt: datetime, tz: object) -> datetime: ...
Expand Down
5 changes: 3 additions & 2 deletions pandas-stubs/_libs/tslibs/dtypes.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from enum import Enum
from typing import Dict

from .offsets import BaseOffset

Expand All @@ -13,7 +14,7 @@ class PeriodDtypeBase:
@classmethod
def from_date_offset(cls, offset: BaseOffset) -> PeriodDtypeBase: ...

attrname_to_abbrevs: Dict[str, str]
attrname_to_abbrevs: dict[str, str]

class FreqGroup:
FR_ANN: int
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/nattype.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import (
datetime,
timedelta,
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/np_datetime.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from __future__ import annotations

class OutOfBoundsDatetime(ValueError): ...
4 changes: 2 additions & 2 deletions pandas-stubs/_libs/tslibs/offsets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class _CustomBusinessMonth(BusinessMixin):
n: int = ...,
normalize: bool = ...,
offset: timedelta = ...,
holidays: None | list = ...,
holidays: list | None = ...,
): ...

class CustomBusinessDay(BusinessDay):
Expand All @@ -224,7 +224,7 @@ class CustomBusinessHour(BusinessHour):
start: str = ...,
end: str = ...,
offset: timedelta = ...,
holidays: None | list = ...,
holidays: list | None = ...,
): ...

class CustomBusinessMonthEnd(_CustomBusinessMonth): ...
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/parsing.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any

def parse_time_string(*args, **kwargs) -> Any: ...
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/strptime.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Any

def array_strptime(*args, **kwargs) -> Any: ...
7 changes: 4 additions & 3 deletions pandas-stubs/_libs/tslibs/timedeltas.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from datetime import timedelta
from typing import (
ClassVar,
Literal,
Type,
TypeVar,
overload,
)
Expand Down Expand Up @@ -80,7 +81,7 @@ class Timedelta(timedelta):
resolution: ClassVar[Timedelta]
value: int # np.int64
def __new__(
cls: Type[_S],
cls: type[_S],
value=...,
unit: str = ...,
**kwargs: int | float | np.integer | np.floating,
Expand Down Expand Up @@ -130,7 +131,7 @@ class Timedelta(timedelta):
@overload
def __rfloordiv__(self, other: timedelta | str) -> int: ...
@overload
def __rfloordiv__(self, other: None | NaTType) -> NaTType: ...
def __rfloordiv__(self, other: NaTType | None) -> NaTType: ...
@overload
def __rfloordiv__(self, other: np.ndarray) -> npt.NDArray[np.timedelta64]: ...
@overload
Expand Down
6 changes: 4 additions & 2 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import (
date as _date,
datetime,
Expand Down Expand Up @@ -40,8 +42,8 @@ class Timestamp(datetime):
| _date
| datetime
| np.datetime64 = ...,
freq: int | None | str | BaseOffset = ...,
tz: str | _tzinfo | None | int = ...,
freq: int | str | BaseOffset | None = ...,
tz: str | _tzinfo | int | None = ...,
unit: str | int | None = ...,
year: int | None = ...,
month: int | None = ...,
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/_libs/tslibs/tzconversion.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from __future__ import annotations

def tz_convert_from_utc_single(val: int, tz: str) -> int: ...
22 changes: 9 additions & 13 deletions pandas-stubs/_libs/tslibs/vectorized.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
from typing import (
List,
Optional,
Sequence,
)
from __future__ import annotations

from typing import Sequence

import numpy as np

from .dtypes import Resolution

def normalize_i8_timestamps(
stamps: Sequence[int], tz: Optional[str] = ...
) -> List[int]: ...
def is_date_array_normalized(
stamps: Sequence[int], tz: Optional[str] = ...
) -> bool: ...
stamps: Sequence[int], tz: str | None = ...
) -> list[int]: ...
def is_date_array_normalized(stamps: Sequence[int], tz: str | None = ...) -> bool: ...
def dt64arr_to_periodarr(
stamps: Sequence[int], freq: int, tz: Optional[str] = ...
) -> List[int]: ...
stamps: Sequence[int], freq: int, tz: str | None = ...
) -> list[int]: ...
def ints_to_pydatetime(
arr: Sequence[int], tz: str = ..., freq: str = ..., fold: bool = ..., box: str = ...
) -> np.ndarray: ...
def get_resolution(stamps: Sequence[int], tz: Optional[str] = ...) -> Resolution: ...
def get_resolution(stamps: Sequence[int], tz: str | None = ...) -> Resolution: ...
Loading