From 8798105aa155ee38568ff1e89cd6480d97d3354e Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sat, 29 Aug 2026 11:55:43 +0200 Subject: [PATCH] Grade against 3.14 too, not just run on it The pre-commit workflow already installs `python-version: "3.x"`, but ruff was still grading the archive against py310 -- so it kept withholding the pyupgrade and type-checking fixes that only become safe at the newer target. `pin_ci_python.py` rewrites the knob. The 17 findings that appeared are what the stale target was hiding: `datetime.timezone.utc` where `datetime.UTC` is now correct (UP017), and 14 imports used only in annotations that belong under `TYPE_CHECKING` (TC002, TC003) -- safe here precisely because 3.14's PEP 649 defers annotation evaluation, which is the same reason ruff would not offer them at py310. `ruff check` and `ruff format --check` are clean again, so the zero-findings state this repo reached earlier today holds at the new target. Still contradictory and deliberately untouched: the four `Programming/ERSMS-project/*/Dockerfile` files say `FROM python:3.10-slim`. They build an archived coursework service against its own era's pinned dependencies, and nothing in this repo runs them; bumping the base image would be a rewrite of that project, not a lint-target change. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01SfnJmxxsZ534AKk16rC2Gr --- Programming/EARIN/lab3/main.py | 5 ++++- Programming/EARIN/project/final/code/main.py | 2 +- .../connector/Include/frontend_AI_connector.py | 6 ++---- Programming/NLP/gpt_alignment.py | 5 ++++- Programming/NLP/gpt_chunks.py | 8 ++++++-- Programming/PORR/code/richardson_method.py | 5 ++++- Programming/PORR/code/threads_indep.py | 5 ++++- Programming/PORR/code/threads_indep_old.py | 8 ++++++-- Programming/PORR/code/threads_too_simple.py | 5 ++++- Programming/PORR/code/time_measurement.py | 5 ++++- .../PSD/zin3/python/code/visualizer/alarm_visualizer.py | 4 ++-- pyproject.toml | 2 +- 12 files changed, 42 insertions(+), 18 deletions(-) diff --git a/Programming/EARIN/lab3/main.py b/Programming/EARIN/lab3/main.py index 0066cd22..fcbf8083 100755 --- a/Programming/EARIN/lab3/main.py +++ b/Programming/EARIN/lab3/main.py @@ -9,13 +9,16 @@ import logging import sys import tempfile import time -from collections.abc import Callable from pathlib import Path +from typing import TYPE_CHECKING import cv2 import matplotlib.pyplot as plt import numpy as np +if TYPE_CHECKING: + from collections.abc import Callable + # cv2.waitKey returns the ASCII code of the key pressed; 'q' quits. KEY_Q = ord("q") # NumPy's legacy np.random.* functions share one global state; Generator is diff --git a/Programming/EARIN/project/final/code/main.py b/Programming/EARIN/project/final/code/main.py index a515e4c2..d5e61eae 100755 --- a/Programming/EARIN/project/final/code/main.py +++ b/Programming/EARIN/project/final/code/main.py @@ -466,7 +466,7 @@ def write_test_results(title: str, result: object = "") -> None: Path("test_results").mkdir(parents=True) # Generate timestamped filename - timestamp = datetime.datetime.now(tz=datetime.timezone.utc).strftime( + timestamp = datetime.datetime.now(tz=datetime.UTC).strftime( "%Y%m%d%H%M%S" ) # e.g., 20230611235959 filename = f"{title}_{timestamp}.txt" diff --git a/Programming/ERSMS-project/connector/Include/frontend_AI_connector.py b/Programming/ERSMS-project/connector/Include/frontend_AI_connector.py index b791c8ab..e9063516 100755 --- a/Programming/ERSMS-project/connector/Include/frontend_AI_connector.py +++ b/Programming/ERSMS-project/connector/Include/frontend_AI_connector.py @@ -14,7 +14,7 @@ import os import time from configparser import ConfigParser from dataclasses import dataclass -from datetime import datetime, timezone +from datetime import UTC, datetime from typing import TYPE_CHECKING import pandas as pd @@ -89,9 +89,7 @@ MOVIES = Movies() @cache.cached(timeout=69) def hello() -> ResponseReturnValue: """Liveness check.""" - return jsonify( - {"response": "Hello there", "time": datetime.now(tz=timezone.utc)} - ), HTTP_OK + return jsonify({"response": "Hello there", "time": datetime.now(tz=UTC)}), HTTP_OK # endpoint do wyciągania danych o userze diff --git a/Programming/NLP/gpt_alignment.py b/Programming/NLP/gpt_alignment.py index 0b2ba207..855558c9 100755 --- a/Programming/NLP/gpt_alignment.py +++ b/Programming/NLP/gpt_alignment.py @@ -8,10 +8,13 @@ them here would put newlines into the middle of the prompt itself. import os from pathlib import Path +from typing import TYPE_CHECKING -import pandas as pd from openai import OpenAI +if TYPE_CHECKING: + import pandas as pd + PROMPTS = Path(__file__).parent / "prompts" THE_PROMPT = (PROMPTS / "alignment.txt").read_text(encoding="utf-8") THE_PROMPT_WITH_COMMENT = (PROMPTS / "alignment_with_comment.txt").read_text( diff --git a/Programming/NLP/gpt_chunks.py b/Programming/NLP/gpt_chunks.py index 9252eaa1..e6a414c6 100755 --- a/Programming/NLP/gpt_chunks.py +++ b/Programming/NLP/gpt_chunks.py @@ -4,11 +4,15 @@ import logging import os import re -from collections.abc import Callable from pathlib import Path +from typing import TYPE_CHECKING from openai import OpenAI -from openai.types.chat import ChatCompletion + +if TYPE_CHECKING: + from collections.abc import Callable + + from openai.types.chat import ChatCompletion logger = logging.getLogger(__name__) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/Programming/PORR/code/richardson_method.py b/Programming/PORR/code/richardson_method.py index f1c8c2f1..19be221f 100755 --- a/Programming/PORR/code/richardson_method.py +++ b/Programming/PORR/code/richardson_method.py @@ -4,13 +4,16 @@ import gc import logging import time +from typing import TYPE_CHECKING import linear_algebra_utils as lin_alg import numpy as np from processing_type import ProcessingType -from richardson_problem import Problem, Settings from time_measurement import tests_time, time_accumulator, time_measurement +if TYPE_CHECKING: + from richardson_problem import Problem, Settings + # These helpers are called with numpy arrays in some backends and plain # Python lists in others, which is the point of the comparison this course # is about, so the aliases name both. diff --git a/Programming/PORR/code/threads_indep.py b/Programming/PORR/code/threads_indep.py index 139f78f7..af0eb692 100755 --- a/Programming/PORR/code/threads_indep.py +++ b/Programming/PORR/code/threads_indep.py @@ -4,17 +4,20 @@ import gc import logging import time +from typing import TYPE_CHECKING import linear_algebra_utils as lin_alg import numpy as np from numba import njit, prange -from richardson_problem import Problem, Settings from time_measurement import ( longest_threads_time_accumulator, tests_time, time_measurement_longest, ) +if TYPE_CHECKING: + from richardson_problem import Problem, Settings + logger = logging.getLogger(__name__) # Called with numpy arrays here and with plain lists in the sequential diff --git a/Programming/PORR/code/threads_indep_old.py b/Programming/PORR/code/threads_indep_old.py index c68a662f..f6b9f357 100755 --- a/Programming/PORR/code/threads_indep_old.py +++ b/Programming/PORR/code/threads_indep_old.py @@ -5,18 +5,22 @@ import gc import logging import multiprocessing import time -from collections.abc import Callable from concurrent.futures import ThreadPoolExecutor +from typing import TYPE_CHECKING import linear_algebra_utils as lin_alg import numpy as np -from richardson_problem import Problem, Settings from time_measurement import ( longest_threads_time_accumulator, tests_time, time_measurement_longest, ) +if TYPE_CHECKING: + from collections.abc import Callable + + from richardson_problem import Problem, Settings + logger = logging.getLogger(__name__) # Called with numpy arrays here and with plain lists in the sequential diff --git a/Programming/PORR/code/threads_too_simple.py b/Programming/PORR/code/threads_too_simple.py index fbdd0835..08b6ce69 100755 --- a/Programming/PORR/code/threads_too_simple.py +++ b/Programming/PORR/code/threads_too_simple.py @@ -7,15 +7,18 @@ import multiprocessing import sys import threading import time +from typing import TYPE_CHECKING import numpy as np -from richardson_problem import Problem, Settings from time_measurement import ( longest_time_accumulator, tests_time, time_measurement_longest, ) +if TYPE_CHECKING: + from richardson_problem import Problem, Settings + logger = logging.getLogger(__name__) # Called with numpy arrays here and with plain lists in the sequential diff --git a/Programming/PORR/code/time_measurement.py b/Programming/PORR/code/time_measurement.py index 997daab4..176d7ae0 100755 --- a/Programming/PORR/code/time_measurement.py +++ b/Programming/PORR/code/time_measurement.py @@ -3,7 +3,10 @@ import sys import time -from collections.abc import Callable +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from collections.abc import Callable class TimeAccumulator: diff --git a/Programming/PSD/zin3/python/code/visualizer/alarm_visualizer.py b/Programming/PSD/zin3/python/code/visualizer/alarm_visualizer.py index cbd587d7..2f600f48 100755 --- a/Programming/PSD/zin3/python/code/visualizer/alarm_visualizer.py +++ b/Programming/PSD/zin3/python/code/visualizer/alarm_visualizer.py @@ -14,7 +14,7 @@ import sys import threading import tkinter as tk from collections import Counter -from datetime import datetime, timezone +from datetime import UTC, datetime from pathlib import Path from tkinter import ttk @@ -97,7 +97,7 @@ class AlarmVisualizer: # Format the timestamp timestamp_dt = datetime.fromtimestamp( - alarm.timestamp / MILLISECONDS, tz=timezone.utc + alarm.timestamp / MILLISECONDS, tz=UTC ).astimezone() formatted_date = timestamp_dt.strftime("%Y-%m-%d %H:%M:%S") diff --git a/pyproject.toml b/pyproject.toml index e26102ca..1a2a6edd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ # on its own, or the gates start disagreeing about what is kuhy's code. [tool.ruff] -target-version = "py310" +target-version = "py314" line-length = 88 include = ["*.py", "**/*.py", "*.ipynb", "**/*.ipynb"]