Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae1184e

Browse files
hugovkCAM-Gerlach
andauthored
Apply suggestions from code review
Co-authored-by: C.A.M. Gerlach <[email protected]>
1 parent 9211356 commit ae1184e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.github/workflows/release-cycle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
with:
2121
python-version: "3"
2222
cache: pip
23+
cache-dependency-path: .github/workflows/release-cycle.yml
2324

2425
- name: Install Jinja
2526
run: python -m pip install jinja2

_tools/generate_release_cycle.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Read in a JSON and generate two CSVs and a SVG file."""
1+
"""Read in a JSON and generate two CSVs and an SVG file."""
22
from __future__ import annotations
33

44
import csv
@@ -69,6 +69,8 @@ def write_svg(self) -> None:
6969
env = jinja2.Environment(
7070
loader=jinja2.FileSystemLoader('_tools/'),
7171
autoescape=True,
72+
lstrip_blocks=True,
73+
trim_blocks=True,
7274
undefined=jinja2.StrictUndefined,
7375
)
7476
template = env.get_template("release_cycle_template.svg")
@@ -87,7 +89,7 @@ def write_svg(self) -> None:
8789
RIGHT_MARGIN = 0.5
8890

8991
# Height of one line. If you change this you'll need to tweak
90-
# some positioning nombers in the template as well.
92+
# some positioning numbers in the template as well.
9193
LINE_HEIGHT = 1.5
9294

9395
first_date = min(
@@ -98,23 +100,24 @@ def write_svg(self) -> None:
98100
)
99101

100102
def date_to_x(date):
101-
"""Convert datetime.date to a SVG X coordinate"""
103+
def date_to_x(date: dt.date) -> float:
104+
"""Convert datetime.date to an SVG X coordinate"""
102105
num_days = (date - first_date).days
103106
total_days = (last_date - first_date).days
104107
ratio = num_days / total_days
105108
x = ratio * (DIAGRAM_WIDTH - LEGEND_WIDTH - RIGHT_MARGIN)
106109
return x + LEGEND_WIDTH
107110

108-
def year_to_x(year):
109-
"""Convert year number to a SVG X coordinate of 1st January"""
111+
def year_to_x(year: int) -> float:
112+
"""Convert year number to an SVG X coordinate of 1st January"""
110113
return date_to_x(dt.date(year, 1, 1))
111114

112-
def format_year(year):
115+
def format_year(year: int) -> str:
113116
"""Format year number for display"""
114117
return f"'{year % 100:02}"
115118

116119
with open(
117-
"include/release-cycle.svg", "w", encoding="UTF-8",
120+
"include/release-cycle.svg", "w", encoding="UTF-8", newline="\n"
118121
) as f:
119122
template.stream(
120123
SCALE=SCALE,

0 commit comments

Comments
 (0)