Skip to content

Commit 2a1f301

Browse files
authored
Merge branch 'master' into enables-python-3.13
2 parents 4e513e5 + ec1ea54 commit 2a1f301

32 files changed

+565
-245
lines changed

.github/workflows/codspeed.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
benchmarks:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-22.04
1515
steps:
1616
- uses: actions/checkout@v3
1717
- uses: actions/setup-python@v4
@@ -21,7 +21,7 @@ jobs:
2121
- name: Get full Python version
2222
id: full-python-version
2323
run: |
24-
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
24+
echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
2525
2626
- name: Install poetry
2727
run: |

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
id: check-version
144144
run: |
145145
[[ "${GITHUB_REF#refs/tags/}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \
146-
|| echo ::set-output name=prerelease::true
146+
|| echo prerelease=true >> $GITHUB_OUTPUT
147147
148148
- name: Create Release
149149
uses: ncipollo/release-action@v1

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Get full Python version
5151
id: full-python-version
5252
run: |
53-
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
53+
echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
5454
5555
- name: Install poetry
5656
run: |

.pre-commit-config.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ repos:
1111
exclude: ^tests/.*/fixtures/.*
1212
- id: debug-statements
1313

14-
- repo: https://github.com/psf/black
15-
rev: 23.7.0
16-
hooks:
17-
- id: black
18-
1914
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.0.291
15+
rev: v0.11.2
2116
hooks:
22-
- id: ruff
17+
- id: ruff
18+
- id: ruff-format
2319

2420
- repo: local
2521
hooks:

clock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ translations = {{}}
197197
)
198198

199199
s.append(f"{' ' * tab}{k!r}: {v},\n")
200-
s.append(f'{" " * (tab - 1)}}}')
200+
s.append(f"{' ' * (tab - 1)}}}")
201201

202202
return "".join(s)
203203

pyproject.toml

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,44 +71,50 @@ python-packages = ["pendulum"]
7171

7272
[tool.ruff]
7373
fix = true
74-
unfixable = [
75-
"ERA", # do not autoremove commented out code
76-
]
77-
target-version = "py39"
7874
line-length = 88
75+
target-version = "py39"
76+
extend-exclude = [
77+
# External to the project's coding standards:
78+
"docs/*",
79+
# Machine-generated, too many false-positives
80+
"src/pendulum/locales/*",
81+
# ruff disagrees with black when it comes to formatting
82+
"*.pyi",
83+
]
84+
85+
[tool.ruff.lint]
7986
extend-select = [
80-
"B", # flake8-bugbear
81-
"C4", # flake8-comprehensions
87+
"B", # flake8-bugbear
88+
"C4", # flake8-comprehensions
8289
"ERA", # flake8-eradicate/eradicate
83-
"I", # isort
84-
"N", # pep8-naming
90+
"I", # isort
91+
"N", # pep8-naming
8592
"PIE", # flake8-pie
8693
"PGH", # pygrep
8794
"RUF", # ruff checks
8895
"SIM", # flake8-simplify
96+
"T20", # flake8-print
8997
"TCH", # flake8-type-checking
9098
"TID", # flake8-tidy-imports
91-
"UP", # pyupgrade
99+
"UP", # pyupgrade
92100
]
93101
ignore = [
94102
"B904", # use 'raise ... from err'
95103
"B905", # use explicit 'strict=' parameter with 'zip()'
96-
"N818", # Exception name should be named with an Error suffix
97-
"RUF001",
104+
"N818",
105+
"RUF001"
98106
]
99-
extend-exclude = [
100-
# External to the project's coding standards:
101-
"docs/*",
102-
# Machine-generated, too many false-positives
103-
"src/pendulum/locales/*",
104-
# ruff disagrees with black when it comes to formatting
105-
"*.pyi",
107+
extend-safe-fixes = [
108+
"TCH", # move import from and to TYPE_CHECKING blocks
109+
]
110+
unfixable = [
111+
"ERA", # do not autoremove commented out code
106112
]
107113

108-
[tool.ruff.flake8-tidy-imports]
114+
[tool.ruff.lint.flake8-tidy-imports]
109115
ban-relative-imports = "all"
110116

111-
[tool.ruff.isort]
117+
[tool.ruff.lint.isort]
112118
force-single-line = true
113119
lines-between-types = 1
114120
lines-after-imports = 2
@@ -122,7 +128,7 @@ known-third-party = [
122128
]
123129
required-imports = ["from __future__ import annotations"]
124130

125-
[tool.ruff.extend-per-file-ignores]
131+
[tool.ruff.lint.extend-per-file-ignores]
126132
"build.py" = ["I002"]
127133
"clock" = ["RUF012"]
128134

rust/src/python/helpers.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::useless_conversion)]
12
use std::cmp::Ordering;
23

34
use pyo3::{
@@ -123,32 +124,32 @@ pub fn get_offset(dt: &Bound<PyAny>) -> PyResult<i32> {
123124
}
124125

125126
#[pyfunction]
126-
pub fn is_leap(year: i32) -> PyResult<bool> {
127-
Ok(helpers::is_leap(year))
127+
pub fn is_leap(year: i32) -> bool {
128+
helpers::is_leap(year)
128129
}
129130

130131
#[pyfunction]
131-
pub fn is_long_year(year: i32) -> PyResult<bool> {
132-
Ok(helpers::is_long_year(year))
132+
pub fn is_long_year(year: i32) -> bool {
133+
helpers::is_long_year(year)
133134
}
134135

135136
#[pyfunction]
136-
pub fn week_day(year: i32, month: u32, day: u32) -> PyResult<u32> {
137-
Ok(helpers::week_day(year, month, day))
137+
pub fn week_day(year: i32, month: u32, day: u32) -> u32 {
138+
helpers::week_day(year, month, day)
138139
}
139140

140141
#[pyfunction]
141-
pub fn days_in_year(year: i32) -> PyResult<u32> {
142-
Ok(helpers::days_in_year(year))
142+
pub fn days_in_year(year: i32) -> u32 {
143+
helpers::days_in_year(year)
143144
}
144145

145146
#[pyfunction]
146147
pub fn local_time(
147148
unix_time: f64,
148149
utc_offset: isize,
149150
microsecond: usize,
150-
) -> PyResult<(usize, usize, usize, usize, usize, usize, usize)> {
151-
Ok(helpers::local_time(unix_time, utc_offset, microsecond))
151+
) -> (usize, usize, usize, usize, usize, usize, usize) {
152+
helpers::local_time(unix_time, utc_offset, microsecond)
152153
}
153154

154155
#[pyfunction]

rust/src/python/parsing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::useless_conversion)]
12
use pyo3::exceptions;
23
use pyo3::prelude::*;
34
use pyo3::types::PyDate;

rust/src/python/types/timezone.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::useless_conversion)]
12
use pyo3::prelude::*;
23
use pyo3::types::{PyDelta, PyDict, PyTzInfo};
34

src/pendulum/__init__.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,15 @@
5959

6060

6161
@overload
62-
def timezone(name: int) -> FixedTimezone:
63-
...
62+
def timezone(name: int) -> FixedTimezone: ...
6463

6564

6665
@overload
67-
def timezone(name: str) -> Timezone:
68-
...
66+
def timezone(name: str) -> Timezone: ...
6967

7068

7169
@overload
72-
def timezone(name: str | int) -> Timezone | FixedTimezone:
73-
...
70+
def timezone(name: str | int) -> Timezone | FixedTimezone: ...
7471

7572

7673
def timezone(name: str | int) -> Timezone | FixedTimezone:
@@ -119,7 +116,7 @@ def _safe_timezone(
119116

120117
obj = int(offset.total_seconds())
121118

122-
obj = cast(Union[str, int], obj)
119+
obj = cast("Union[str, int]", obj)
123120

124121
return timezone(obj)
125122

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

211207

212208
@overload
213209
def instance(
214210
obj: _datetime.date,
215211
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
216-
) -> Date:
217-
...
212+
) -> Date: ...
218213

219214

220215
@overload
221216
def instance(
222217
obj: _datetime.time,
223218
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
224-
) -> Time:
225-
...
219+
) -> Time: ...
226220

227221

228222
def instance(
@@ -350,22 +344,27 @@ def interval(
350344
travel_back = _traveller.travel_back
351345

352346
__all__ = [
353-
"__version__",
354347
"DAYS_PER_WEEK",
355348
"HOURS_PER_DAY",
356349
"MINUTES_PER_HOUR",
357350
"MONTHS_PER_YEAR",
358351
"SECONDS_PER_DAY",
359352
"SECONDS_PER_HOUR",
360353
"SECONDS_PER_MINUTE",
354+
"UTC",
361355
"WEEKS_PER_YEAR",
362356
"YEARS_PER_CENTURY",
363357
"YEARS_PER_DECADE",
364358
"Date",
365359
"DateTime",
366360
"Duration",
361+
"FixedTimezone",
367362
"Formatter",
363+
"Interval",
364+
"Time",
365+
"Timezone",
368366
"WeekDay",
367+
"__version__",
369368
"date",
370369
"datetime",
371370
"duration",
@@ -377,18 +376,13 @@ def interval(
377376
"instance",
378377
"interval",
379378
"local",
379+
"local_timezone",
380380
"locale",
381381
"naive",
382382
"now",
383-
"set_locale",
384-
"week_ends_at",
385-
"week_starts_at",
386383
"parse",
387-
"Interval",
388-
"Time",
389-
"UTC",
390-
"local_timezone",
391384
"set_local_timezone",
385+
"set_locale",
392386
"test_local_timezone",
393387
"time",
394388
"timezone",
@@ -398,7 +392,7 @@ def interval(
398392
"travel",
399393
"travel_back",
400394
"travel_to",
401-
"FixedTimezone",
402-
"Timezone",
395+
"week_ends_at",
396+
"week_starts_at",
403397
"yesterday",
404398
]

0 commit comments

Comments
 (0)