Skip to content
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

Enables python 3.13 #871

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
make formats
rudolfix committed Dec 28, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit adc533afa50e0b723f87b5f09d2c3e1bf91b2678
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -71,8 +71,8 @@ jobs:
- os: macos
target: aarch64
interpreter: 3.9 3.10 3.11 3.12 3.13 pypy3.8 pypy3.9 pypy3.10



runs-on: ${{ matrix.os }}-latest
steps:
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ jobs:
run: pip install pre-commit
- name: "Install Rust toolchain"
run: rustup component add rustfmt clippy
- run: pre-commit run --all-files
- run: make lint

Tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -23,7 +23,8 @@ dev:

lint:
poetry run mypy
pre-commit run --all-files

test:
PENDULUM_EXTENSIONS=0 poetry run pytest -q tests
poetry run pytest -q tests
poetry run pytest -q tests
9 changes: 5 additions & 4 deletions clock
Original file line number Diff line number Diff line change
@@ -190,10 +190,11 @@ translations = {{}}
def format_dict(self, d, tab=1):
s = ["{\n"]
for k, v in d.items():
if isinstance(v, (dict, LocaleDataDict)):
v = self.format_dict(v, tab + 1)
else:
v = repr(v)
v = (
self.format_dict(v, tab + 1)
if isinstance(v, (dict, LocaleDataDict))
else repr(v)
)

s.append(f"{' ' * tab}{k!r}: {v},\n")
s.append(f'{" " * (tab - 1)}}}')
21 changes: 1 addition & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -80,7 +80,6 @@ ruff = "^0.7.3"

[tool.poetry.group.build.dependencies]
maturin = ">=1.0,<2.0"
patchelf = ">=0.17"

[tool.poetry.extras]
test = ["time-machine"]
@@ -95,7 +94,7 @@ unfixable = [
"ERA", # do not autoremove commented out code
]
target-version = "py39"
line-length = 88
line-length = 100
extend-select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
18 changes: 12 additions & 6 deletions src/pendulum/__init__.py
Original file line number Diff line number Diff line change
@@ -59,15 +59,18 @@


@overload
def timezone(name: int) -> FixedTimezone: ...
def timezone(name: int) -> FixedTimezone:
...


@overload
def timezone(name: str) -> Timezone: ...
def timezone(name: str) -> Timezone:
...


@overload
def timezone(name: str | int) -> Timezone | FixedTimezone: ...
def timezone(name: str | int) -> Timezone | FixedTimezone:
...


def timezone(name: str | int) -> Timezone | FixedTimezone:
@@ -202,21 +205,24 @@ def time(hour: int, minute: int = 0, second: int = 0, microsecond: int = 0) -> T
def instance(
obj: _datetime.datetime,
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
) -> DateTime: ...
) -> DateTime:
...


@overload
def instance(
obj: _datetime.date,
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
) -> Date: ...
) -> Date:
...


@overload
def instance(
obj: _datetime.time,
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
) -> Time: ...
) -> Time:
...


def instance(
6 changes: 4 additions & 2 deletions src/pendulum/date.py
Original file line number Diff line number Diff line change
@@ -257,10 +257,12 @@ def __add__(self, other: timedelta) -> Self:
return self._add_timedelta(other)

@overload # type: ignore[override] # this is only needed because of Python 3.7
def __sub__(self, __delta: timedelta) -> Self: ...
def __sub__(self, __delta: timedelta) -> Self:
...

@overload
def __sub__(self, __dt: datetime) -> NoReturn: ...
def __sub__(self, __dt: datetime) -> NoReturn:
...

@overload
def __sub__(self, __dt: Self) -> Interval[Date]:
9 changes: 6 additions & 3 deletions src/pendulum/datetime.py
Original file line number Diff line number Diff line change
@@ -146,11 +146,13 @@ def instance(

@overload
@classmethod
def now(cls, tz: datetime.tzinfo | None = None) -> Self: ...
def now(cls, tz: datetime.tzinfo | None = None) -> Self:
...

@overload
@classmethod
def now(cls, tz: str | Timezone | FixedTimezone | None = None) -> Self: ...
def now(cls, tz: str | Timezone | FixedTimezone | None = None) -> Self:
...

@classmethod
def now(
@@ -1184,7 +1186,8 @@ def average( # type: ignore[override]
)

@overload # type: ignore[override]
def __sub__(self, other: datetime.timedelta) -> Self: ...
def __sub__(self, other: datetime.timedelta) -> Self:
...

@overload
def __sub__(self, other: DateTime) -> Interval[datetime.datetime]:
12 changes: 8 additions & 4 deletions src/pendulum/duration.py
Original file line number Diff line number Diff line change
@@ -375,10 +375,12 @@ def __mul__(self, other: int | float) -> Self:
__rmul__ = __mul__

@overload
def __floordiv__(self, other: timedelta) -> int: ...
def __floordiv__(self, other: timedelta) -> int:
...

@overload
def __floordiv__(self, other: int) -> Self: ...
def __floordiv__(self, other: int) -> Self:
...

def __floordiv__(self, other: int | timedelta) -> int | Duration:
if not isinstance(other, (int, timedelta)):
@@ -401,10 +403,12 @@ def __floordiv__(self, other: int | timedelta) -> int | Duration:
)

@overload
def __truediv__(self, other: timedelta) -> float: ...
def __truediv__(self, other: timedelta) -> float:
...

@overload
def __truediv__(self, other: float) -> Self: ...
def __truediv__(self, other: float) -> Self:
...

def __truediv__(self, other: int | float | timedelta) -> Self | float:
if not isinstance(other, (int, float, timedelta)):
7 changes: 3 additions & 4 deletions src/pendulum/formatting/formatter.py
Original file line number Diff line number Diff line change
@@ -440,10 +440,9 @@ def _check_parsed(
# we use it and don't go any further
if parsed["timestamp"] is not None:
str_us = str(parsed["timestamp"])
if "." in str_us:
microseconds = int(f'{str_us.split(".")[1].ljust(6, "0")}')
else:
microseconds = 0
microseconds = (
int(f"{str_us.split('.')[1].ljust(6, '0')}") if "." in str_us else 0
)

from pendulum.helpers import local_time

3 changes: 2 additions & 1 deletion src/pendulum/helpers.py
Original file line number Diff line number Diff line change
@@ -62,7 +62,8 @@ def add_duration(
minutes: int = 0,
seconds: float = 0,
microseconds: int = 0,
) -> _DT: ...
) -> _DT:
...


@overload
12 changes: 8 additions & 4 deletions src/pendulum/interval.py
Original file line number Diff line number Diff line change
@@ -336,21 +336,25 @@ def __mul__(self, other: int | float) -> Duration: # type: ignore[override]
__rmul__ = __mul__ # type: ignore[assignment]

@overload # type: ignore[override]
def __floordiv__(self, other: timedelta) -> int: ...
def __floordiv__(self, other: timedelta) -> int:
...

@overload
def __floordiv__(self, other: int) -> Duration: ...
def __floordiv__(self, other: int) -> Duration:
...

def __floordiv__(self, other: int | timedelta) -> int | Duration:
return self.as_duration().__floordiv__(other)

__div__ = __floordiv__ # type: ignore[assignment]

@overload # type: ignore[override]
def __truediv__(self, other: timedelta) -> float: ...
def __truediv__(self, other: timedelta) -> float:
...

@overload
def __truediv__(self, other: float) -> Duration: ...
def __truediv__(self, other: float) -> Duration:
...

def __truediv__(self, other: float | timedelta) -> Duration | float:
return self.as_duration().__truediv__(other)
3 changes: 1 addition & 2 deletions src/pendulum/parsing/__init__.py
Original file line number Diff line number Diff line change
@@ -44,8 +44,7 @@
" )"
")?"
# Time (optional) # noqa: ERA001
"(?P<time>"
r" (?P<timesep>\ )?" # Separator (space)
"(?P<time>" r" (?P<timesep>\ )?" # Separator (space)
# HH:mm:ss (optional mm and ss)
r" (?P<hour>\d{1,2}):(?P<minute>\d{1,2})?(?::(?P<second>\d{1,2}))?"
# Subsecond part (optional)
3 changes: 1 addition & 2 deletions src/pendulum/parsing/iso8601.py
Original file line number Diff line number Diff line change
@@ -42,8 +42,7 @@
" )"
")?"
# Time (optional) # noqa: ERA001
"(?P<time>"
r" (?P<timesep>[T\ ])?" # Separator (T or space)
"(?P<time>" r" (?P<timesep>[T\ ])?" # Separator (T or space)
# HH:mm:ss (optional mm and ss)
r" (?P<hour>\d{1,2})(?P<minsep>:)?(?P<minute>\d{1,2})?(?P<secsep>:)?(?P<second>\d{1,2})?"
# Subsecond part (optional)
3 changes: 2 additions & 1 deletion src/pendulum/testing/traveller.py
Original file line number Diff line number Diff line change
@@ -47,7 +47,8 @@ def __exit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType,
) -> None: ...
) -> None:
...

def _not_implemented(self) -> NotImplementedError:
return NotImplementedError()
12 changes: 8 additions & 4 deletions src/pendulum/time.py
Original file line number Diff line number Diff line change
@@ -168,10 +168,12 @@ def __add__(self, other: datetime.timedelta) -> Time:
return self.add_timedelta(other)

@overload
def __sub__(self, other: time) -> pendulum.Duration: ...
def __sub__(self, other: time) -> pendulum.Duration:
...

@overload
def __sub__(self, other: datetime.timedelta) -> Time: ...
def __sub__(self, other: datetime.timedelta) -> Time:
...

def __sub__(self, other: time | datetime.timedelta) -> pendulum.Duration | Time:
if not isinstance(other, (Time, time, timedelta)):
@@ -191,10 +193,12 @@ def __sub__(self, other: time | datetime.timedelta) -> pendulum.Duration | Time:
return other.diff(self, False)

@overload
def __rsub__(self, other: time) -> pendulum.Duration: ...
def __rsub__(self, other: time) -> pendulum.Duration:
...

@overload
def __rsub__(self, other: datetime.timedelta) -> Time: ...
def __rsub__(self, other: datetime.timedelta) -> Time:
...

def __rsub__(self, other: time | datetime.timedelta) -> pendulum.Duration | Time:
if not isinstance(other, (Time, time)):
Loading