Skip to content

Commit 7a86096

Browse files
authored
Merge branch 'master' into koo-macro
2 parents e40e107 + 4d7e42a commit 7a86096

29 files changed

+298
-253
lines changed

.github/workflows/codspeed.yml

Lines changed: 3 additions & 3 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@v3
@@ -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: |
@@ -46,7 +46,7 @@ jobs:
4646
python -c 'import pendulum._pendulum'
4747
4848
- name: Run benchmarks
49-
uses: CodSpeedHQ/action@v1
49+
uses: CodSpeedHQ/action@v3
5050
with:
5151
token: ${{ secrets.CODSPEED_TOKEN }}
5252
run: pytest tests/ --codspeed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
id: check-version
129129
run: |
130130
[[ "${GITHUB_REF#refs/tags/}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \
131-
|| echo ::set-output name=prerelease::true
131+
|| echo prerelease=true >> $GITHUB_OUTPUT
132132
133133
- name: Create Release
134134
uses: ncipollo/release-action@v1

.github/workflows/tests.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,11 @@ 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: |
57-
curl -fsS https://install.python-poetry.org | python - --preview -y
58-
59-
- name: Update PATH
60-
if: ${{ matrix.os != 'Windows' }}
61-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
62-
63-
- name: Update Path for Windows
64-
if: ${{ matrix.os == 'Windows' }}
65-
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
57+
pipx install poetry>=2
6658
6759
- name: Configure poetry
6860
run: poetry config virtualenvs.in-project true
@@ -90,7 +82,7 @@ jobs:
9082

9183
- name: Uninstall typing dependencies
9284
# This ensures pendulum runs without typing_extensions installed
93-
run: poetry install --only main --only test --only build --sync --no-root -vvv
85+
run: poetry sync --only main --only test --only build --no-root -vvv
9486

9587
- name: Test Pure Python
9688
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
@@ -196,7 +196,7 @@ translations = {{}}
196196
v = repr(v)
197197

198198
s.append(f"{' ' * tab}{k!r}: {v},\n")
199-
s.append(f'{" " * (tab - 1)}}}')
199+
s.append(f"{' ' * (tab - 1)}}}")
200200

201201
return "".join(s)
202202

poetry.lock

Lines changed: 73 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ requires-python = ">=3.9"
77
license = { text = "MIT License" }
88
authors = [{ name = "Sébastien Eustace", email = "[email protected]" }]
99
keywords = ['datetime', 'date', 'time']
10-
1110
classifiers = [
1211
"License :: OSI Approved :: MIT License",
1312
"Programming Language :: Python :: 3",
@@ -20,6 +19,10 @@ classifiers = [
2019
dependencies = [
2120
"python-dateutil>=2.6",
2221
"tzdata>=2020.1",
22+
]
23+
24+
[project.optional-dependencies]
25+
test = [
2326
'time-machine>=2.6.0; implementation_name != "pypy"',
2427
]
2528

@@ -29,25 +32,6 @@ Documentation = "https://pendulum.eustace.io/docs"
2932
Repository = "https://github.com/sdispater/pendulum"
3033

3134

32-
[tool.poetry]
33-
name = "pendulum"
34-
version = "3.0.0"
35-
description = "Python datetimes made easy"
36-
authors = ["Sébastien Eustace <[email protected]>"]
37-
license = "MIT"
38-
readme = 'README.rst'
39-
homepage = "https://pendulum.eustace.io"
40-
repository = "https://github.com/sdispater/pendulum"
41-
documentation = "https://pendulum.eustace.io/docs"
42-
keywords = ['datetime', 'date', 'time']
43-
44-
45-
[tool.poetry.dependencies]
46-
python = ">=3.9"
47-
python-dateutil = ">=2.6"
48-
time-machine = { version = ">=2.16.0", markers = "implementation_name != 'pypy'", optional = true }
49-
tzdata = ">=2020.1"
50-
5135
[tool.poetry.group.test.dependencies]
5236
pytest = "^7.1.2"
5337
pytz = ">=2022.1"
@@ -79,53 +63,55 @@ pytest-codspeed = "^3.0.0"
7963
[tool.poetry.group.build.dependencies]
8064
maturin = ">=1.0,<2.0"
8165

82-
[tool.poetry.extras]
83-
test = ["time-machine"]
84-
8566
[tool.maturin]
8667
module-name = "pendulum._pendulum"
8768

88-
8969
[tool.ruff]
9070
fix = true
91-
unfixable = [
92-
"ERA", # do not autoremove commented out code
93-
]
94-
target-version = "py39"
9571
line-length = 88
72+
target-version = "py39"
73+
extend-exclude = [
74+
# External to the project's coding standards:
75+
"docs/*",
76+
# Machine-generated, too many false-positives
77+
"src/pendulum/locales/*",
78+
# ruff disagrees with black when it comes to formatting
79+
"*.pyi",
80+
]
81+
82+
[tool.ruff.lint]
9683
extend-select = [
97-
"B", # flake8-bugbear
98-
"C4", # flake8-comprehensions
84+
"B", # flake8-bugbear
85+
"C4", # flake8-comprehensions
9986
"ERA", # flake8-eradicate/eradicate
100-
"I", # isort
101-
"N", # pep8-naming
87+
"I", # isort
88+
"N", # pep8-naming
10289
"PIE", # flake8-pie
10390
"PGH", # pygrep
10491
"RUF", # ruff checks
10592
"SIM", # flake8-simplify
93+
"T20", # flake8-print
10694
"TCH", # flake8-type-checking
10795
"TID", # flake8-tidy-imports
108-
"UP", # pyupgrade
96+
"UP", # pyupgrade
10997
]
11098
ignore = [
11199
"B904", # use 'raise ... from err'
112100
"B905", # use explicit 'strict=' parameter with 'zip()'
113-
"N818", # Exception name should be named with an Error suffix
114-
"RUF001",
101+
"N818",
102+
"RUF001"
115103
]
116-
extend-exclude = [
117-
# External to the project's coding standards:
118-
"docs/*",
119-
# Machine-generated, too many false-positives
120-
"src/pendulum/locales/*",
121-
# ruff disagrees with black when it comes to formatting
122-
"*.pyi",
104+
extend-safe-fixes = [
105+
"TCH", # move import from and to TYPE_CHECKING blocks
106+
]
107+
unfixable = [
108+
"ERA", # do not autoremove commented out code
123109
]
124110

125-
[tool.ruff.flake8-tidy-imports]
111+
[tool.ruff.lint.flake8-tidy-imports]
126112
ban-relative-imports = "all"
127113

128-
[tool.ruff.isort]
114+
[tool.ruff.lint.isort]
129115
force-single-line = true
130116
lines-between-types = 1
131117
lines-after-imports = 2
@@ -139,7 +125,7 @@ known-third-party = [
139125
]
140126
required-imports = ["from __future__ import annotations"]
141127

142-
[tool.ruff.extend-per-file-ignores]
128+
[tool.ruff.lint.extend-per-file-ignores]
143129
"build.py" = ["I002"]
144130
"clock" = ["RUF012"]
145131

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

0 commit comments

Comments
 (0)