Skip to content

Commit c5fd8af

Browse files
committed
be explicit in what is replaced, via naming to avoid confusion. Type checker was complaining
1 parent 4dcc6c5 commit c5fd8af

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

scripts/shift_calculations.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,16 @@ def calculate_shift_parts(start_time: datetime, end_time: datetime) -> dict[str,
128128

129129
# hours on this day
130130
day_end = (current_time + timedelta(days=1)).replace(hour=0, minute=0, second=0)
131-
work_start = current_time.replace(**WORK_START_TIME)
132-
work_end = current_time.replace(**WORK_END_TIME)
131+
work_start = current_time.replace(
132+
hour=WORK_START_TIME["hour"],
133+
minute=WORK_START_TIME["minute"],
134+
second=WORK_START_TIME["second"]
135+
)
136+
work_end = current_time.replace(
137+
hour=WORK_END_TIME["hour"],
138+
minute=WORK_END_TIME["minute"],
139+
second=WORK_END_TIME["second"]
140+
)
133141

134142
if current_time < work_start:
135143
# difference to work starting time (or shift)
@@ -203,7 +211,7 @@ def test_working_hours_single_day():
203211

204212
# Main --------------------------------------------------------------------------
205213

206-
def calculate_shifts(file_path: str | Path, shift_type: str = None) -> dict[str, timedelta]:
214+
def calculate_shifts(file_path: str | Path, shift_type: str | None = None) -> dict[str, timedelta]:
207215
"""Calculate the shifts from Start/End Date columns of the first markdown table in a given file.
208216
209217
Args:
@@ -243,7 +251,7 @@ def calculate_shifts(file_path: str | Path, shift_type: str = None) -> dict[str
243251
return parts
244252

245253

246-
def manual_shifts(file_path: str | Path, shift_type: str = None) -> dict[str, float]:
254+
def manual_shifts(file_path: str | Path, shift_type: str | None = None) -> dict[str, float]:
247255
"""Calculate the shifts from Shifts column of the first markdown table in a given file.
248256
249257
Args:
@@ -269,7 +277,7 @@ def manual_shifts(file_path: str | Path, shift_type: str = None) -> dict[str, fl
269277
if not entry[COLUMN_SHIFTS]:
270278
continue
271279

272-
shift_split = re.findall(fr"([\d.]+)([WH]N?)", entry[COLUMN_SHIFTS])
280+
shift_split = re.findall(r"([\d.]+)([WH]N?)", entry[COLUMN_SHIFTS])
273281
for value, key in shift_split:
274282
parts[key] += float(value)
275283

@@ -280,7 +288,7 @@ def manual_shifts(file_path: str | Path, shift_type: str = None) -> dict[str, fl
280288
return parts
281289

282290

283-
def plot_results(parts, title: str = "", output_path: str | Path = None) -> Figure:
291+
def plot_results(parts, title: str = "", output_path: str | Path | None = None) -> Figure:
284292
"""Plot the results of a calculation.
285293
286294
Args:
@@ -324,7 +332,7 @@ def filter_by_data(array):
324332

325333

326334
def plot_all_machines_in_year(
327-
year: int, additional: dict[str, float], calculate: bool = False, output_path: str | Path = None
335+
year: int, additional: dict[str, float], calculate: bool = False, output_path: str | Path | None = None
328336
) -> Figure:
329337
"""Do a pychart for all machines of a specific year.
330338

0 commit comments

Comments
 (0)