Skip to content

Commit 2e9b37e

Browse files
[pre-commit.ci] pre-commit autoupdate (#712)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.3.0 → 23.7.0](psf/black@23.3.0...23.7.0) - https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.0.270 → v0.0.283](astral-sh/ruff-pre-commit@v0.0.270...v0.0.283) * Fix issues raised by Ruff update --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bartek Sokorski <[email protected]>
1 parent 5954bb3 commit 2e9b37e

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ repos:
1212
- id: debug-statements
1313

1414
- repo: https://github.com/psf/black
15-
rev: 23.3.0
15+
rev: 23.7.0
1616
hooks:
1717
- id: black
1818

19-
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: v0.0.270
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.0.283
2121
hooks:
2222
- id: ruff

pendulum/date.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from datetime import datetime
1010
from datetime import timedelta
1111
from typing import TYPE_CHECKING
12+
from typing import ClassVar
1213
from typing import NoReturn
1314
from typing import cast
1415
from typing import overload
@@ -38,7 +39,7 @@
3839

3940
class Date(FormattableMixin, date):
4041
# Names of days of the week
41-
_days = {
42+
_days: ClassVar[dict[int, str]] = {
4243
SUNDAY: "Sunday",
4344
MONDAY: "Monday",
4445
TUESDAY: "Tuesday",
@@ -48,7 +49,14 @@ class Date(FormattableMixin, date):
4849
SATURDAY: "Saturday",
4950
}
5051

51-
_MODIFIERS_VALID_UNITS = ["day", "week", "month", "year", "decade", "century"]
52+
_MODIFIERS_VALID_UNITS: ClassVar[list[str]] = [
53+
"day",
54+
"week",
55+
"month",
56+
"year",
57+
"decade",
58+
"century",
59+
]
5260

5361
# Getters/Setters
5462

pendulum/datetime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class DateTime(datetime.datetime, Date):
5656

5757
# Formats
5858

59-
_FORMATS: dict[str, str | Callable[[datetime.datetime], str]] = {
59+
_FORMATS: ClassVar[dict[str, str | Callable[[datetime.datetime], str]]] = {
6060
"atom": ATOM,
6161
"cookie": COOKIE,
6262
"iso8601": lambda dt: dt.isoformat(),
@@ -70,7 +70,7 @@ class DateTime(datetime.datetime, Date):
7070
"w3c": W3C,
7171
}
7272

73-
_MODIFIERS_VALID_UNITS: list[str] = [
73+
_MODIFIERS_VALID_UNITS: ClassVar[list[str]] = [
7474
"second",
7575
"minute",
7676
"hour",

pendulum/formatting/formatter.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import TYPE_CHECKING
77
from typing import Any
88
from typing import Callable
9+
from typing import ClassVar
910
from typing import Match
1011
from typing import Sequence
1112
from typing import cast
@@ -66,7 +67,9 @@ class Formatter:
6667

6768
_FROM_FORMAT_RE: re.Pattern[str] = re.compile(r"(?<!\\\[)" + _TOKENS + r"(?!\\\])")
6869

69-
_LOCALIZABLE_TOKENS: dict[str, str | Callable[[Locale], Sequence[str]] | None] = {
70+
_LOCALIZABLE_TOKENS: ClassVar[
71+
dict[str, str | Callable[[Locale], Sequence[str]] | None]
72+
] = {
7073
"Qo": None,
7174
"MMMM": "months.wide",
7275
"MMM": "months.abbreviated",
@@ -91,7 +94,7 @@ class Formatter:
9194
),
9295
}
9396

94-
_TOKENS_RULES: dict[str, Callable[[pendulum.DateTime], str]] = {
97+
_TOKENS_RULES: ClassVar[dict[str, Callable[[pendulum.DateTime], str]]] = {
9598
# Year
9699
"YYYY": lambda dt: f"{dt.year:d}",
97100
"YY": lambda dt: f"{dt.year:d}"[2:],
@@ -137,7 +140,7 @@ class Formatter:
137140
"z": lambda dt: f'{dt.timezone_name or ""}',
138141
}
139142

140-
_DATE_FORMATS = {
143+
_DATE_FORMATS: ClassVar[dict[str, str]] = {
141144
"LTS": "formats.time.full",
142145
"LT": "formats.time.short",
143146
"L": "formats.date.short",
@@ -146,7 +149,7 @@ class Formatter:
146149
"LLLL": "formats.datetime.full",
147150
}
148151

149-
_DEFAULT_DATE_FORMATS = {
152+
_DEFAULT_DATE_FORMATS: ClassVar[dict[str, str]] = {
150153
"LTS": "h:mm:ss A",
151154
"LT": "h:mm A",
152155
"L": "MM/DD/YYYY",
@@ -155,7 +158,7 @@ class Formatter:
155158
"LLLL": "dddd, MMMM D, YYYY h:mm A",
156159
}
157160

158-
_REGEX_TOKENS: dict[str, str | Sequence[str] | None] = {
161+
_REGEX_TOKENS: ClassVar[dict[str, str | Sequence[str] | None]] = {
159162
"Y": _MATCH_SIGNED,
160163
"YY": (_MATCH_1_TO_2, _MATCH_2),
161164
"YYYY": (_MATCH_1_TO_4, _MATCH_4),
@@ -196,7 +199,7 @@ class Formatter:
196199
"z": _MATCH_TIMEZONE,
197200
}
198201

199-
_PARSE_TOKENS: dict[str, Callable[[str], Any]] = {
202+
_PARSE_TOKENS: ClassVar[dict[str, Callable[[str], Any]]] = {
200203
"YYYY": lambda year: int(year),
201204
"YY": lambda year: int(year),
202205
"Q": lambda quarter: int(quarter),

pendulum/parsing/iso8601.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def parse_iso8601(
185185
if ambiguous_date:
186186
# We can "safely" assume that the ambiguous date
187187
# was actually a time in the form hhmmss
188-
hhmmss = f"{year!s}{str(month):0>2}"
188+
hhmmss = f"{year!s}{month!s:0>2}"
189189

190190
return datetime.time(int(hhmmss[:2]), int(hhmmss[2:4]), int(hhmmss[4:]))
191191

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ required-imports = ["from __future__ import annotations"]
127127

128128
[tool.ruff.extend-per-file-ignores]
129129
"build.py" = ["I002"]
130+
"clock" = ["RUF012"]
130131

131132
[tool.mypy]
132133
strict = true

0 commit comments

Comments
 (0)