Skip to content

Commit 74779c8

Browse files
committed
feat: add pre-commit configuration and improve code formatting across multiple files
1 parent 365a35a commit 74779c8

15 files changed

+491
-117
lines changed

.github/workflows/build_image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- master
77
paths-ignore:
88
- "**/coverage.svg"
9-
9+
1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
1212
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: local
9+
hooks:
10+
- id: pytest-check
11+
name: pytest-check
12+
entry: pipenv run pytest
13+
language: system
14+
pass_filenames: false
15+
always_run: true
16+
- repo: https://github.com/PyCQA/flake8
17+
rev: 6.0.0
18+
hooks:
19+
- id: flake8
20+
args: [--max-line-length=160]
21+
exclude: venv|assets
22+
- repo: https://github.com/psf/black
23+
rev: 25.1.0
24+
hooks:
25+
- id: black
26+
args: [--line-length=160, --diff]
27+
exclude: "/venv/|/assets/"

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pytest = "~=8.3"
1818
pytest-asyncio = "~=0.25"
1919
pytest-cov = "~=6.0"
2020
pytest-mock = "~=3.14"
21+
pre-commit = "*"
2122

2223
[requires]
2324
python_version = "3.11"

Pipfile.lock

Lines changed: 117 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/graphics_chart_drawer.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ async def create_loc_graph(yearly_data: Dict, save_path: str):
2929
languages_all_loc = dict()
3030
for i, y in enumerate(sorted(yearly_data.keys())):
3131
for q in yearly_data[y].keys():
32-
langs = sorted(yearly_data[y][q].keys(), key=lambda n: yearly_data[y][q][n]["add"] + yearly_data[y][q][n]["del"], reverse=True)[0:MAX_LANGUAGES]
32+
langs = sorted(
33+
yearly_data[y][q].keys(),
34+
key=lambda n: yearly_data[y][q][n]["add"] + yearly_data[y][q][n]["del"],
35+
reverse=True,
36+
)[0:MAX_LANGUAGES]
3337

3438
for lang in langs:
3539
if lang not in languages_all_loc:
3640
languages_all_loc[lang] = zeros((years, 4, 2), dtype=int)
37-
languages_all_loc[lang][i][q - 1] = array([yearly_data[y][q][lang]["add"], yearly_data[y][q][lang]["del"]])
41+
languages_all_loc[lang][i][q - 1] = array(
42+
[yearly_data[y][q][lang]["add"], yearly_data[y][q][lang]["del"]]
43+
)
3844

3945
fig = plt.figure()
4046
ax = fig.add_axes([0, 0, 1.5, 1])
@@ -47,19 +53,41 @@ async def create_loc_graph(yearly_data: Dict, save_path: str):
4753
language_handles += [mpatches.Patch(color=color, label=key)]
4854

4955
for quarter in range(4):
50-
ax.bar(year_indexes + quarter * 0.21, value[:, quarter][:, 0], 0.2, bottom=cumulative[:, quarter][:, 0], color=color)
51-
ax.bar(year_indexes + quarter * 0.21, -value[:, quarter][:, 1], 0.2, bottom=-cumulative[:, quarter][:, 1], color=color)
56+
ax.bar(
57+
year_indexes + quarter * 0.21,
58+
value[:, quarter][:, 0],
59+
0.2,
60+
bottom=cumulative[:, quarter][:, 0],
61+
color=color,
62+
)
63+
ax.bar(
64+
year_indexes + quarter * 0.21,
65+
-value[:, quarter][:, 1],
66+
0.2,
67+
bottom=-cumulative[:, quarter][:, 1],
68+
color=color,
69+
)
5270
cumulative[:, quarter] = add(cumulative[:, quarter], value[:, quarter])
5371
ax.axhline(y=0.5, lw=0.5, snap=True, color="k")
5472

5573
ax.set_ylabel("LOC added", fontdict=dict(weight="bold"))
56-
ax.set_xticks(array([arange(i, i + 0.84, step=0.21) for i in year_indexes]).flatten(), labels=["Q1", "Q2", "Q3", "Q4"] * years)
74+
ax.set_xticks(
75+
array([arange(i, i + 0.84, step=0.21) for i in year_indexes]).flatten(),
76+
labels=["Q1", "Q2", "Q3", "Q4"] * years,
77+
)
5778

5879
sax = ax.secondary_xaxis("top")
5980
sax.set_xticks(year_indexes + 0.42, labels=sorted(yearly_data.keys()))
6081
sax.spines["top"].set_visible(False)
6182

62-
ax.legend(title="Language", handles=language_handles, loc="upper left", bbox_to_anchor=(1, 1), framealpha=0, title_fontproperties=dict(weight="bold"))
83+
ax.legend(
84+
title="Language",
85+
handles=language_handles,
86+
loc="upper left",
87+
bbox_to_anchor=(1, 1),
88+
framealpha=0,
89+
title_fontproperties=dict(weight="bold"),
90+
)
6391

6492
sax.tick_params(axis="both", length=0)
6593
sax.spines["top"].set_visible(False)

0 commit comments

Comments
 (0)