Skip to content

Commit 8ef497a

Browse files
authored
Merge pull request #637 from Secrus/refresh
Project refresh
2 parents 2a538f9 + 9709ae1 commit 8ef497a

File tree

112 files changed

+1981
-1713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+1981
-1713
lines changed

.coveragerc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.flake8

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
[flake8]
22
max-line-length = 88
3-
ignore = E501, E203, W503
43
per-file-ignores =
5-
__init__.py:F401
4+
# F401: Module imported but unused
5+
# TC001: Move import into type checking block
6+
__init__.py:F401, TC001
7+
# F811: Redefinition of unused name from line n
68
pendulum/tz/timezone.py:F811
7-
exclude =
8-
.git
9-
__pycache__
10-
setup.py
11-
build
12-
dist
13-
releases
14-
.idea
15-
.venv
16-
.tox
17-
.mypy_cache
18-
.pytest_cache
19-
.vscode
20-
.github
9+
min_python_version = 3.7.0
10+
ban-relative-imports = true
11+
# flake8-use-fstring: https://github.com/MichaelKim0407/flake8-use-fstring#--percent-greedy-and---format-greedy
12+
format-greedy = 1
13+
inline-quotes = double
14+
enable-extensions = TC, TC1
15+
type-checking-exempt-modules = typing, typing-extensions
16+
eradicate-whitelist-extend = ^-.*;
17+
extend-ignore =
18+
# E501: Line too long
19+
E501,
20+
# E203: Whitespace before ':'
21+
E203,
22+
# SIM106: Handle error-cases first
23+
SIM106,
24+
extend-exclude =
25+
# External to the project's coding standards:
26+
docs/*,
27+
# Machine-generated, too many false-positives
28+
pendulum/locales/*,

.pre-commit-config.yaml

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,68 @@ ci:
22
autofix_prs: false
33

44
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.0.1
7+
hooks:
8+
- id: trailing-whitespace
9+
exclude: ^tests/.*/fixtures/.*
10+
- id: end-of-file-fixer
11+
exclude: ^tests/.*/fixtures/.*
12+
- id: debug-statements
13+
14+
- repo: https://github.com/hadialqattan/pycln
15+
rev: v2.1.1
16+
hooks:
17+
- id: pycln
18+
args: [--all]
19+
520
- repo: https://github.com/psf/black
621
rev: 22.6.0
722
hooks:
823
- id: black
924

10-
- repo: https://gitlab.com/pycqa/flake8
25+
- repo: https://github.com/pycqa/isort
26+
rev: 5.10.1
27+
hooks:
28+
- id: isort
29+
args: [--add-import, from __future__ import annotations]
30+
31+
- repo: https://github.com/pycqa/flake8
1132
rev: 4.0.1
1233
hooks:
1334
- id: flake8
35+
additional_dependencies: &flake8_deps
36+
- flake8-broken-line==0.4.0
37+
- flake8-bugbear==22.7.1
38+
- flake8-comprehensions==3.10.0
39+
- flake8-eradicate==1.2.1
40+
- flake8-quotes==3.3.1
41+
- flake8-simplify==0.19.2
42+
- flake8-tidy-imports==4.8.0
43+
- flake8-type-checking==2.0.3
44+
- flake8-typing-imports==1.12.0
45+
- flake8-use-fstring==1.3
46+
- pep8-naming==0.13.1
1447

15-
- repo: https://github.com/timothycrosley/isort
16-
rev: 5.10.1
48+
- repo: https://github.com/asottile/yesqa
49+
rev: v1.3.0
1750
hooks:
18-
- id: isort
19-
exclude: ^.*/?setup\.py$
51+
- id: yesqa
52+
additional_dependencies: *flake8_deps
2053

2154
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.29.0
55+
rev: v2.37.3
2356
hooks:
2457
- id: pyupgrade
58+
exclude: ^build\.py$
59+
args:
60+
- --py37-plus
2561

26-
- repo: https://github.com/pre-commit/pre-commit-hooks
27-
rev: v4.0.1
62+
- repo: https://github.com/pre-commit/mirrors-mypy
63+
rev: v0.971
2864
hooks:
29-
- id: trailing-whitespace
30-
exclude: ^tests/.*/fixtures/.*
31-
- id: end-of-file-fixer
32-
exclude: ^tests/.*/fixtures/.*
33-
- id: debug-statements
65+
- id: mypy
66+
pass_filenames: false
67+
exclude: ^build\.py$
68+
additional_dependencies:
69+
- pytest>=7.1.2

build.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ def build_extension(self, ext):
5151
build_ext.build_extension(self, ext)
5252
except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
5353
print(
54-
' Unable to build the "{}" C extension, '
55-
"Pendulum will use the pure python version of the extension.".format(
56-
ext.name
57-
)
54+
f' Unable to build the "{ext.name}" C extension, '
55+
"Pendulum will use the pure python version of the extension."
5856
)
5957

6058

clock

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22

3+
from __future__ import annotations
4+
35
import glob
46
import json
57
import os
@@ -191,16 +193,16 @@ translations = {{}}
191193
else:
192194
v = repr(v)
193195

194-
s.append("{}{!r}: {},\n".format(" " * tab, k, v))
195-
s.append("%s}" % (" " * (tab - 1)))
196+
s.append(f"{' ' * tab}{k!r}: {v},\n")
197+
s.append(f'{" " * (tab - 1)}}}')
196198

197199
return "".join(s)
198200

199201
def plural_rule_to_lambda(self, rule):
200202
to_py = _LambdaCompiler().compile
201203
result = ["lambda n: "]
202204
for tag, ast in PluralRule.parse(rule).abstract:
203-
result.append("'{}' if {} else ".format(tag, to_py(ast)))
205+
result.append(f"'{tag}' if {to_py(ast)} else ")
204206
result.append("'other'")
205207
return "".join(result)
206208

@@ -215,13 +217,13 @@ translations = {{}}
215217
limit = PATTERN_CHARS[fieldchar]
216218
if limit and fieldnum not in limit:
217219
raise ValueError(
218-
"Invalid length for field: %r" % (fieldchar * fieldnum)
220+
f"Invalid length for field: {(fieldchar * fieldnum)!r}"
219221
)
220222
result.append(
221223
self.TOKENS_MAP.get(fieldchar * fieldnum, fieldchar * fieldnum)
222224
)
223225
else:
224-
raise NotImplementedError("Unknown token type: %s" % tok_type)
226+
raise NotImplementedError(f"Unknown token type: {tok_type}")
225227

226228
return "".join(result)
227229

@@ -250,17 +252,16 @@ class WindowsTzDump(Command):
250252

251253
def handle(self):
252254
raw_tznames = get_global("windows_zone_mapping")
253-
sorted_names = sorted(list(raw_tznames.keys()))
255+
sorted_names = sorted(raw_tznames.keys())
254256

255257
tznames = {}
256258
for name in sorted_names:
257259
tznames[name] = raw_tznames[name]
258260

259-
mapping = json.dumps(tznames, indent=4)
260-
mapping = "windows_timezones = " + mapping.replace('"', "'") + "\n"
261+
mapping = json.dumps(tznames, indent=4).replace('"', "'")
261262

262263
with open(os.path.join(self.MAPPING_DIR, "windows.py"), "w") as f:
263-
f.write(mapping)
264+
f.write(f"windows_timezones = {mapping}\n")
264265

265266

266267
app = Application("clock", __version__)

0 commit comments

Comments
 (0)