Skip to content

Commit 0dc5c7e

Browse files
committed
πŸ”§ Change default EOL day to be end of the month
This is also how endoflife.date does it: https://endoflife.date/python See also discussion in #16 (comment)
1 parent ba0a201 commit 0dc5c7e

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

β€Žpirel/releases.pyβ€Ž

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from __future__ import annotations
22

3+
import calendar
34
import datetime
45
import json
56
import logging
67
import urllib.error
78
import urllib.request
8-
from typing import Any, Optional
9+
from typing import Any, Literal, Optional
910

1011
import humanize
1112
import typer
@@ -35,10 +36,16 @@
3536
logger = logging.getLogger("pirel")
3637

3738

38-
def parse_date(date_str: str) -> datetime.date:
39+
def parse_date(
40+
date_str: str, default_day: Literal["first", "last"] = "last"
41+
) -> datetime.date:
3942
if len(date_str) == len("yyyy-mm"):
40-
# We need a full yyyy-mm-dd, so let's approximate
41-
return datetime.date.fromisoformat(date_str + "-01")
43+
if default_day == "last":
44+
last_day_of_month = calendar.monthrange(*map(int, date_str.split("-")))[1]
45+
_date_str = f"{date_str}-{last_day_of_month}"
46+
else:
47+
_date_str = f"{date_str}-01"
48+
return datetime.date.fromisoformat(_date_str)
4249
return datetime.date.fromisoformat(date_str)
4350

4451

β€Žtests/test_cli.pyβ€Ž

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
┏━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
2929
┃ Version ┃ Status ┃ Released ┃ End-of-life ┃
3030
┑━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
31-
β”‚ 3.14 β”‚ feature β”‚ 2025-10-01 β”‚ 2030-10-01 β”‚
32-
β”‚ 3.13 β”‚ bugfix β”‚ 2024-10-07 β”‚ 2029-10-01 β”‚
33-
β”‚ 3.12 β”‚ bugfix β”‚ 2023-10-02 β”‚ 2028-10-01 β”‚
34-
β”‚ 3.11 β”‚ security β”‚ 2022-10-24 β”‚ 2027-10-01 β”‚
35-
β”‚ 3.10 β”‚ security β”‚ 2021-10-04 β”‚ 2026-10-01 β”‚
36-
β”‚ 3.9 β”‚ security β”‚ 2020-10-05 β”‚ 2025-10-01 β”‚
31+
β”‚ 3.14 β”‚ feature β”‚ 2025-10-01 β”‚ 2030-10-31 β”‚
32+
β”‚ 3.13 β”‚ bugfix β”‚ 2024-10-07 β”‚ 2029-10-31 β”‚
33+
β”‚ 3.12 β”‚ bugfix β”‚ 2023-10-02 β”‚ 2028-10-31 β”‚
34+
β”‚ 3.11 β”‚ security β”‚ 2022-10-24 β”‚ 2027-10-31 β”‚
35+
β”‚ 3.10 β”‚ security β”‚ 2021-10-04 β”‚ 2026-10-31 β”‚
36+
β”‚ 3.9 β”‚ security β”‚ 2020-10-05 β”‚ 2025-10-31 β”‚
3737
β”‚ 3.8 β”‚ end-of-life β”‚ 2019-10-14 β”‚ 2024-10-07 β”‚
3838
β”‚ 3.7 β”‚ end-of-life β”‚ 2018-06-27 β”‚ 2023-06-27 β”‚
3939
β”‚ 3.6 β”‚ end-of-life β”‚ 2016-12-23 β”‚ 2021-12-23 β”‚
@@ -50,12 +50,12 @@
5050

5151
PYVER_TO_CHECK_OUTPUT = {
5252
"3.8": ":warning: You are using Python 3.8 which has reached end-of-life! Please upgrade to a newer version of Python (EOL 2024-10-07)",
53-
"3.9": ":heavy_check_mark: You are using Python 3.9 which has security support for more than 10 months (EOL 2025-10-01)",
54-
"3.10": ":heavy_check_mark: You are using Python 3.10 which has security support for more than 1 year, 10 months (EOL 2026-10-01)",
55-
"3.11": ":heavy_check_mark: You are using Python 3.11 which has security support for more than 2 years (EOL 2027-10-01)",
56-
"3.12": ":rocket: You are using Python 3.12 which is actively maintained (bugfixes) and has security support for more than 3 years (EOL 2028-10-01)",
57-
"3.13": ":rocket: You are using Python 3.13 which is actively maintained (bugfixes) and has security support for more than 4 years (EOL 2029-10-01)",
58-
"3.14": ":sparkles: You are using Python 3.14 which is not released yet and still accepts new features (EOL 2030-10-01)",
53+
"3.9": ":heavy_check_mark: You are using Python 3.9 which has security support for more than 10 months (EOL 2025-10-31)",
54+
"3.10": ":heavy_check_mark: You are using Python 3.10 which has security support for more than 1 year, 10 months (EOL 2026-10-31)",
55+
"3.11": ":heavy_check_mark: You are using Python 3.11 which has security support for more than 2 years (EOL 2027-10-31)",
56+
"3.12": ":rocket: You are using Python 3.12 which is actively maintained (bugfixes) and has security support for more than 3 years (EOL 2028-10-31)",
57+
"3.13": ":rocket: You are using Python 3.13 which is actively maintained (bugfixes) and has security support for more than 4 years (EOL 2029-10-31)",
58+
"3.14": ":sparkles: You are using Python 3.14 which is not released yet and still accepts new features (EOL 2030-10-31)",
5959
}
6060
DATE_FREEZE = datetime.date(2024, 11, 3)
6161
RELEASE_CYCLE_DATA_PATH = (

0 commit comments

Comments
Β (0)