Skip to content

Commit d6065cc

Browse files
[pre-commit.ci] pre-commit autoupdate (#204)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: c59bba8fb259db0fec2bbb77ad8ba51ea7341b56 → f12be1ebaa5351c1fc76472de98db2c3446c8253](astral-sh/ruff-pre-commit@c59bba8...f12be1e) - [github.com/python-jsonschema/check-jsonschema: 1a4bb160cab6417b3045e1b37b6b72449243e658 → 4f85d46a92dc17713078e5de73f8a13190edf6fc](python-jsonschema/check-jsonschema@1a4bb16...4f85d46) - [github.com/pre-commit/mirrors-mypy: d2823d321df3af8f878f7ee3414dc94d037145b9 → 2834ec6639549dd6796205c8f011dedcd587288b](pre-commit/mirrors-mypy@d2823d3...2834ec6) - [github.com/djlint/djLint: 9112cb64851c95a7802358af285d21ad8b7f6437 → 97266b950ee135d6ef89c9ace9d88baadced6f67](djlint/djLint@9112cb6...97266b9) - [github.com/zizmorcore/zizmor-pre-commit: e3eebf65325ccc992422292cb7a4baee967cf815 → fa412071e4f5d44d44f9e365f4676f9df92456a2](zizmorcore/zizmor-pre-commit@e3eebf6...fa41207) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply ruff unsafe fixes, fix broad exception handling and default logger usage * Bump ruff pre-commit version to omit 0.16.10 failures * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bump djLint pre-commit version to ensure latest checks * Move progress bar colors and gradient to CSS, ignore djlint inline style rule for width --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maciej Olko <maciej.olko@gmail.com>
1 parent 77aa1b6 commit d6065cc

12 files changed

Lines changed: 44 additions & 34 deletions

‎.pre-commit-config.yaml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: c59bba8fb259db0fec2bbb77ad8ba51ea7341b56 # frozen: v0.15.20
3+
rev: 38bfb07c0c64c304f47eb52090f8288150c77730 # frozen: v0.17.1
44
hooks:
55
- id: ruff-check
66
args: [--fix, --exit-non-zero-on-fix]
@@ -20,7 +20,7 @@ repos:
2020
- id: trailing-whitespace
2121

2222
- repo: https://github.com/python-jsonschema/check-jsonschema
23-
rev: 1a4bb160cab6417b3045e1b37b6b72449243e658 # frozen: 0.37.4
23+
rev: 4f85d46a92dc17713078e5de73f8a13190edf6fc # frozen: 0.38.2
2424
hooks:
2525
- id: check-github-workflows
2626

@@ -35,7 +35,7 @@ repos:
3535
- id: check-useless-excludes
3636

3737
- repo: https://github.com/pre-commit/mirrors-mypy
38-
rev: d2823d321df3af8f878f7ee3414dc94d037145b9 # frozen: v2.1.0
38+
rev: 2834ec6639549dd6796205c8f011dedcd587288b # frozen: v2.4.0
3939
hooks:
4040
- id: mypy
4141
additional_dependencies: [types-docutils, types-polib>=1.2.0.20250114, types-requests]
@@ -47,13 +47,13 @@ repos:
4747
args: [".", "--per-rule-ignores", "DEP002=python-docs-theme", "--package-module-name-map", "gitpython=git,sphinx-lint=sphinxlint"]
4848

4949
- repo: https://github.com/djlint/djLint
50-
rev: 9112cb64851c95a7802358af285d21ad8b7f6437 # frozen: v1.36.4
50+
rev: 1399b56bfc493191c39ff1a525a8ab9c11201cd3 # frozen: v1.46.6
5151
hooks:
5252
- id: djlint-reformat-jinja
5353
- id: djlint-jinja
5454

5555
- repo: https://github.com/zizmorcore/zizmor-pre-commit
56-
rev: e3eebf65325ccc992422292cb7a4baee967cf815 # frozen: v1.26.1
56+
rev: fa412071e4f5d44d44f9e365f4676f9df92456a2 # frozen: v1.30.1
5757
hooks:
5858
- id: zizmor
5959

‎generate.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
from __future__ import annotations
22

3-
import json
43
import concurrent.futures
54
import itertools
5+
import json
66
import logging
77
import subprocess
88
from collections.abc import Iterator
9-
from dataclasses import dataclass, asdict
10-
from datetime import datetime, timezone
9+
from dataclasses import asdict, dataclass
10+
from datetime import UTC, datetime
1111
from pathlib import Path
1212

1313
from git import Repo
1414
from jinja2 import Environment, FileSystemLoader
1515
from urllib3 import PoolManager
1616

17-
import translated_names
1817
import contribute
18+
import translated_names
1919
from completion import branches_from_peps, get_completion, release_cycle_from_peps
2020
from repositories import Language, get_languages_and_repos
2121

22-
generation_time = datetime.now(timezone.utc)
22+
logger = logging.getLogger('pydocs-translation-dashboard')
23+
generation_time = datetime.now(UTC)
2324

2425

2526
def get_completion_progress() -> Iterator[LanguageProjectData]:
@@ -111,7 +112,7 @@ def completion_score(self) -> float:
111112

112113
if __name__ == '__main__':
113114
logging.basicConfig(level=logging.INFO)
114-
logging.info(f'starting at {generation_time}')
115+
logger.info('starting at %s', generation_time)
115116
Path('build').mkdir(parents=True, exist_ok=True)
116117

117118
completion_progress = list(get_completion_progress())
@@ -123,7 +124,7 @@ def completion_score(self) -> float:
123124
python_version=python_version,
124125
release_cycle_status=release_cycle_from_peps()[python_version]['status'],
125126
generation_time=generation_time,
126-
duration=(datetime.now(timezone.utc) - generation_time).seconds,
127+
duration=(datetime.now(UTC) - generation_time).seconds,
127128
)
128129

129130
Path('build/style.css').write_bytes(Path('src/style.css').read_bytes())

‎generate_build_details.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import itertools
33
import logging
44
from collections.abc import Iterator, Sequence
5-
from datetime import datetime, timezone
5+
from datetime import UTC, datetime
66
from json import loads
77
from pathlib import Path
88
from sys import argv
@@ -17,7 +17,8 @@
1717
from generate import LanguageProjectData
1818
from repositories import Language
1919

20-
generation_time = datetime.now(timezone.utc)
20+
logger = logging.getLogger('pydocs-translation-dashboard')
21+
generation_time = datetime.now(UTC)
2122

2223

2324
def get_projects_build_details(
@@ -54,7 +55,7 @@ def get_language_repo_and_completion(
5455

5556
if __name__ == '__main__':
5657
logging.basicConfig(level=logging.INFO)
57-
logging.info(f'starting at {generation_time}')
58+
logger.info('starting at %s', generation_time)
5859
env = Environment(loader=FileSystemLoader('templates'))
5960
if (index_path := Path('build/index.json')).exists():
6061
index_json = loads(Path('build/index.json').read_text())
@@ -70,7 +71,7 @@ def get_language_repo_and_completion(
7071
completion_progress, get_projects_build_details(completion_progress)
7172
),
7273
generation_time=generation_time,
73-
duration=(datetime.now(timezone.utc) - generation_time).seconds,
74+
duration=(datetime.now(UTC) - generation_time).seconds,
7475
)
7576

7677
Path('build/build-details.html').write_text(output)

‎repositories.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66
from docutils import core
7-
from docutils.nodes import table, row
7+
from docutils.nodes import row, table
88

99

1010
def get_languages_and_repos(

‎sphinx_lint.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
def store_and_count_failures(clones_dir: str, repo: str, language_code: str) -> int:
99
failed_checks = list(chain.from_iterable(yield_failures(clones_dir, repo)))
1010
prefix = f'{Path(clones_dir, "rebased_translations", repo)}/'
11-
log = '\n'.join(
12-
map(lambda check: check.removeprefix(prefix), map(str, failed_checks))
13-
)
11+
log = '\n'.join(check.removeprefix(prefix) for check in map(str, failed_checks))
1412
filepath = Path(f'build/warnings-lint-{language_code}.txt')
1513
filepath.write_text(log)
1614
return len(failed_checks)

‎src/style.css‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ ul.links-row li:not(:first-child)::before {
220220
height: 20px;
221221
}
222222

223+
.progress-bar.main-bar {
224+
background: linear-gradient(
225+
to left,
226+
#94cf96 var(--progress-change, 0%),
227+
#4caf50 var(--progress-change, 0%)
228+
);
229+
}
230+
223231
.outer-label {
224232
display: none;
225233
padding-left: .5em;

‎templates/progress_bar.html.jinja‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
- change: numeric change value (same units as width) or falsy
55
#}
66
<div class="progress {{ extra_container_class }}">
7+
{% set relative_change_percent = change * 100 / width if change and width else 0 %}
8+
{# djlint:off H021 #}
79
<div class="progress-bar main-bar"
810
style="width: {{ width }}%;
9-
{%- if change and width -%} {# compute the relative change percentage safely #} {%- set rel = (change * 100 / width) -%} background: linear-gradient(to left, #94cf96 {{ rel }}%, #4caf50 {{ rel }}%);
10-
{%- else -%} background-color: #4caf50;
11-
{%- endif -%}">
11+
--progress-change: {{ relative_change_percent }}%">
12+
{# djlint:on #}
1213
{{ kind }}: {{ '{:.2f}%'.format(width) }}
1314
{% if change >= 0.01 %}
1415
({{ '{:+.2f}%'.format(change) }})

‎tests/support.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import contextlib
2+
import sys
33

44
# -------------------------------- Imports ----------------------------------- #
55

@@ -11,7 +11,7 @@ def import_scripts(dir='..'):
1111
yield cm
1212

1313

14-
class DirsOnSysPath(object):
14+
class DirsOnSysPath:
1515
def __init__(self, *paths):
1616
self.original_value = sys.path[:]
1717
self.original_object = sys.path

‎tests/test_contribute.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
2-
import urllib3
2+
33
import support
4+
import urllib3
45

56
with support.import_scripts():
67
import contribute
@@ -42,7 +43,7 @@ def test_links_are_valid(self):
4243
if isinstance(e.reason, urllib3.exceptions.ReadTimeoutError):
4344
self.skipTest(f'{link}: read timeout, skipping slow server')
4445
self.fail(f'{link}: {e}')
45-
except Exception as e:
46+
except urllib3.exceptions.HTTPError as e:
4647
self.fail(f'{link}: {e}')
4748

4849

‎tests/test_index.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import unittest
22
from dataclasses import replace
33
from datetime import datetime
4-
import support
54

5+
import support
66
from jinja2 import Environment, FileSystemLoader
77

88
with support.import_scripts():

0 commit comments

Comments
 (0)