From b23831ca40fc9d20df89db3212b6adf3b2652896 Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Mon, 10 Mar 2025 23:39:00 +0100 Subject: [PATCH 1/7] feat(repo): remove pytz dependency --- .github/workflows/main.yml | 11 ++++++++--- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0997fac..0262d6b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,11 +11,16 @@ permissions: jobs: test: - name: Test - Python ${{ matrix.python-version }} - runs-on: ubuntu-latest + name: Test - Python ${{ matrix.python-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + python-version: ["3.9", "3.13"] + include: + - { os: "ubuntu-latest", python-version: "3.10" } + - { os: "ubuntu-latest", python-version: "3.11" } + - { os: "ubuntu-latest", python-version: "3.12" } env: UV_PYTHON: ${{ matrix.python-version }} steps: diff --git a/pyproject.toml b/pyproject.toml index f6c8e5a..1c3c928 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", ] -requires-python = "~=3.9" +requires-python = ">=3.9" dependencies = [] [project.urls] From b9b9fe77439a2cb38db4642ed61233dee8bd4bee Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Tue, 11 Mar 2025 00:43:07 +0100 Subject: [PATCH 2/7] feat(timezones): Use Python 3.9 timezones Also, force tests to use it, to check if it works with all OS --- pyproject.toml | 4 +++- tests/test_feedgenerator.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1c3c928..c962b91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,9 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", ] requires-python = ">=3.9" -dependencies = [] +dependencies = [ + "tzdata; sys_platform == 'win32'", +] [project.urls] Homepage = "https://github.com/getpelican/feedgenerator" diff --git a/tests/test_feedgenerator.py b/tests/test_feedgenerator.py index c389b54..5091a41 100644 --- a/tests/test_feedgenerator.py +++ b/tests/test_feedgenerator.py @@ -1,4 +1,5 @@ import datetime +from zoneinfo import ZoneInfo import pytest @@ -20,7 +21,7 @@ link="http://www.holovaty.com/täst/", description="Testing.", content="Full content of our testing entry.", - pubdate=datetime.datetime(2016,8,11,0,0,0,0), + pubdate=datetime.datetime(2016,8,11,0,0,0,0,tzinfo=ZoneInfo("America/New_York")), ) @@ -29,7 +30,7 @@ Umlauts: äöüßÄÖÜ Chinese: 老师是四十四,是不是? Finnish: Mustan kissan paksut posket. (ah, no special chars) Kärpänen sanoi kärpäselle: tuu kattoon kattoon ku kaveri tapettiin tapettiin. - en%DATE%Hellohttp://www.holovaty.com/t%C3%A4st/Testing.Thu, 11 Aug 2016 00:00:00 -0000""" + en%DATE%Hellohttp://www.holovaty.com/t%C3%A4st/Testing.Thu, 11 Aug 2016 00:00:00 -0400""" EXPECTED_RESULT_ATOM = """ Poynter E-Media Tidbitshttp://www.poynter.org/column.asp?id=31%DATE%A group Weblog by the sharpest minds in online media/journalism/publishing. From 105903ed5e54a723e6417b46c10c4c988c01dbc3 Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Wed, 12 Mar 2025 22:43:26 +0100 Subject: [PATCH 3/7] feat(repo): update pre-commit-config versions --- .pre-commit-config.yaml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b811c0..b202f20 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,21 @@ --- repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 - hooks: - - id: check-added-large-files - - id: check-ast - - id: check-case-conflict - - id: check-merge-conflict - - id: check-toml - - id: debug-statements - - id: detect-private-key - - id: end-of-file-fixer - - id: forbid-new-submodules - - id: trailing-whitespace + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-case-conflict + - id: check-merge-conflict + - id: check-toml + - id: debug-statements + - id: detect-private-key + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: trailing-whitespace - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 - hooks: - - id: pyupgrade - args: [--py38-plus] + - repo: https://github.com/asottile/pyupgrade + rev: v3.19.1 + hooks: + - id: pyupgrade + args: [--py39-plus] From 3d89c1cee10cedbb18ec704d3a1da9d8539a474d Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Wed, 12 Mar 2025 22:44:05 +0100 Subject: [PATCH 4/7] test(feedgenerator): explicitly test date handling --- tests/test_feedgenerator.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/test_feedgenerator.py b/tests/test_feedgenerator.py index 5091a41..7845378 100644 --- a/tests/test_feedgenerator.py +++ b/tests/test_feedgenerator.py @@ -5,6 +5,9 @@ import feedgenerator +AWARE_DATE = datetime.datetime(2016,8,11,0,0,0,0,tzinfo=ZoneInfo("America/New_York")) +AWARE_DATE_UTC = datetime.datetime(2016,8,11,0,0,0,0,tzinfo=ZoneInfo("UTC")) +NAIVE_DATE = datetime.datetime(2016,8,11,0,0,0,0) FIXT_FEED = dict( title="Poynter E-Media Tidbits", @@ -21,7 +24,7 @@ link="http://www.holovaty.com/täst/", description="Testing.", content="Full content of our testing entry.", - pubdate=datetime.datetime(2016,8,11,0,0,0,0,tzinfo=ZoneInfo("America/New_York")), + pubdate=NAIVE_DATE, ) @@ -30,7 +33,7 @@ Umlauts: äöüßÄÖÜ Chinese: 老师是四十四,是不是? Finnish: Mustan kissan paksut posket. (ah, no special chars) Kärpänen sanoi kärpäselle: tuu kattoon kattoon ku kaveri tapettiin tapettiin. - en%DATE%Hellohttp://www.holovaty.com/t%C3%A4st/Testing.Thu, 11 Aug 2016 00:00:00 -0400""" + en%DATE%Hellohttp://www.holovaty.com/t%C3%A4st/Testing.Thu, 11 Aug 2016 00:00:00 -0000""" EXPECTED_RESULT_ATOM = """ Poynter E-Media Tidbitshttp://www.poynter.org/column.asp?id=31%DATE%A group Weblog by the sharpest minds in online media/journalism/publishing. @@ -136,3 +139,26 @@ def test_subtitle(description, subtitle, fragment, nonfragment): assert fragment in result if nonfragment: assert nonfragment not in result + +@pytest.mark.parametrize("generator, date, expected_date_string", [ + (feedgenerator.Atom1Feed, AWARE_DATE, "2016-08-11T00:00:00-04:00"), + (feedgenerator.Atom1Feed, AWARE_DATE_UTC, "2016-08-11T00:00:00+00:00"), + (feedgenerator.Atom1Feed, NAIVE_DATE, "2016-08-11T00:00:00Z"), + (feedgenerator.Rss201rev2Feed, AWARE_DATE, "Thu, 11 Aug 2016 00:00:00 -0400"), + (feedgenerator.Rss201rev2Feed, AWARE_DATE_UTC, "Thu, 11 Aug 2016 00:00:00 +0000"), + (feedgenerator.Rss201rev2Feed, NAIVE_DATE, "Thu, 11 Aug 2016 00:00:00 -0000"), + (feedgenerator.RssUserland091Feed, AWARE_DATE, "Thu, 11 Aug 2016 00:00:00 -0400"), + (feedgenerator.RssUserland091Feed, AWARE_DATE_UTC, "Thu, 11 Aug 2016 00:00:00 +0000"), + (feedgenerator.RssUserland091Feed, NAIVE_DATE, "Thu, 11 Aug 2016 00:00:00 -0000"), + ]) +def test_timezone_handling(generator, date, expected_date_string): + """ + Test that dates are handled correctly in all Feed generators. + Also test special cases of no timezone given, vs timezone without offset + """ + + feed = generator(**FIXT_FEED) + feed.add_item(**(FIXT_ITEM | {'pubdate': date})) + result = feed.writeString(ENCODING) + + assert expected_date_string in result From 9badfffadf17230163dede4d3bafe0f793aa6a34 Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Mon, 14 Jul 2025 02:21:41 +0200 Subject: [PATCH 5/7] build: Add requires setting as set on main --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c962b91..c6e45bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", ] -requires-python = ">=3.9" +requires-python = "~=3.9" dependencies = [ "tzdata; sys_platform == 'win32'", ] From 3a8b307d21e56c6d9b1f0e15476f71137c8a831d Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Mon, 14 Jul 2025 13:01:53 +0200 Subject: [PATCH 6/7] style: Fix the wrong indentation --- .pre-commit-config.yaml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b202f20..534aee6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,21 @@ --- repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 - hooks: - - id: check-added-large-files - - id: check-ast - - id: check-case-conflict - - id: check-merge-conflict - - id: check-toml - - id: debug-statements - - id: detect-private-key - - id: end-of-file-fixer - - id: forbid-new-submodules - - id: trailing-whitespace + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: check-ast + - id: check-case-conflict + - id: check-merge-conflict + - id: check-toml + - id: debug-statements + - id: detect-private-key + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: trailing-whitespace - - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 - hooks: - - id: pyupgrade - args: [--py39-plus] + - repo: https://github.com/asottile/pyupgrade + rev: v3.20.0 + hooks: + - id: pyupgrade + args: [--py39-plus] From c64f489e252dd3eebebbe07281fd817cccc2df60 Mon Sep 17 00:00:00 2001 From: Patrick Gerken Date: Mon, 14 Jul 2025 13:04:27 +0200 Subject: [PATCH 7/7] fix: Recover improvements that got lost during rebase --- .github/workflows/main.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0262d6b..66cf62d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,16 +11,11 @@ permissions: jobs: test: - name: Test - Python ${{ matrix.python-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: ["3.9", "3.13"] - include: - - { os: "ubuntu-latest", python-version: "3.10" } - - { os: "ubuntu-latest", python-version: "3.11" } - - { os: "ubuntu-latest", python-version: "3.12" } + python-version: ["pypy3.11", "3.9", "3.10", "3.11", "3.12", "3.13"] env: UV_PYTHON: ${{ matrix.python-version }} steps: