Skip to content

fix: case-insensitive StrEnum value lookup per RFC 5545 - #2118

Open
Mubashir78 wants to merge 2 commits into
PyCalendar:mainfrom
Mubashir78:fix/1840-enum-case-insensitive-lookup
Open

Mubashir78 wants to merge 2 commits into
PyCalendar:mainfrom
Mubashir78:fix/1840-enum-case-insensitive-lookup

Conversation

@Mubashir78

@Mubashir78 Mubashir78 commented Nov 15, 2026 •

Copy link
Copy Markdown

Linked issue

Description

Parameter values defined as enums (PARTSTAT, STATUS, TRANSP, VALUE, etc.) are not enclosed in double quotes, so RFC 5545 section 3.1 makes them case-insensitive. The StrEnum.get() helper already handles case-insensitive lookup with a default, but calling the enum directly still fails: PARTSTAT('needs-action') raises ValueError on main while PARTSTAT.NEEDS_ACTION works.

StrEnum now implements _missing_, which looks up members by their casefolded value. The defined values keep their canonical spelling; only the lookup is relaxed. This also makes get() resolve any case variant through the regular constructor path.

Checklist

  • I added a change log entry, following the instructions in all subsections under Change log requirements.
  • I followed icalendar's Artificial intelligence policy and disclosed my Responsible AI use in my commit messages, if applicable.
  • I added or updated tests, if applicable.
  • I ran and ensured all tests pass locally by following Run tests.
  • I added or edited documentation as necessary, both as docstrings to be rendered in the API documentation and narrative documentation, following the Style guide.

Additional information

  • The change log entry is news/2118.bugfix, and it carries the brief AI disclosure and @Mubashir78 attribution required by the policy.
  • The AI disclosure is in the commit message of this PR, per the policy's required format.
  • Tests: src/icalendar/tests/test_issue_1840.py (37 tests) covers case-insensitive lookups, exact lookups, unknown values, and str() output for every StrEnum subclass. Locally I ran that file and the enums doctests on the current base; both pass. On the base of an earlier iteration of this branch I ran the full suite once: 3 failures, all of them reproducible on unmodified main (test_issue_313_globally_unique_tzid zoneinfo cases and one doctest), unrelated to this change. The full suite across Python 3.10 to 3.14 is covered by the CI runs on this PR.
  • This PR was rebased onto current main after the StrEnum.get() helper landed there; the conflict resolution keeps both mechanisms.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request, @Mubashir78! A maintainer will review it shortly.

@github-actions github-actions Bot added the ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding. label Nov 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

One or more PR-quality checks did not pass. Review the PR Quality Checks summary in the workflow run for the failed checks and their details, then make any necessary updates.

Checklist items may remain unchecked while work is in progress. Please tick each item as you complete it.

If you used AI assistance, follow the project's Responsible AI use policy and provide the required disclosures.

@Mubashir78
Mubashir78 force-pushed the fix/1840-enum-case-insensitive-lookup branch from d4af97b to 8962c96 Compare November 15, 2026 02:38
Issue PyCalendar#1840. Parameter values defined as enums (PARTSTAT, STATUS, TRANSP,
VALUE, etc.) are not enclosed in double quotes, so RFC 5545 section 3.1
makes them case-insensitive. The StrEnum.get() helper already handles
case-insensitive lookup with a default, but calling the enum directly
still fails: PARTSTAT('needs-action') raises ValueError on main while
PARTSTAT.NEEDS_ACTION works.

Add StrEnum._missing_ to look up members by their casefolded value. The
defined values keep their canonical spelling; only the lookup is
relaxed. This also makes get() resolve any case variant through the
regular constructor path.

Tests cover case-insensitive lookups, exact lookups, unknown values,
and str() output for every StrEnum subclass.

AI assistance disclosure: This commit was drafted with AI assistance
(GLM-5.3-Flash, Z.ai). I used it to compare RFC 5545 section 3.1 with
the enums module, to draft the _missing_ implementation and the test
file in this commit, and to run and interpret the local test results.
I reviewed all of it before committing.
@Mubashir78
Mubashir78 force-pushed the fix/1840-enum-case-insensitive-lookup branch from 8962c96 to 6d7414d Compare November 15, 2026 02:41
@Mubashir78

Copy link
Copy Markdown
Author

Small housekeeping note: the ai-suspicion label on this PR is stale. It was added by the PR Quality workflow when the PR was first opened, because the Read the Docs build and the news-fragment check had not passed yet at that moment. Both issues were fixed in commit 6d7414d (a news/2118.bugfix fragment was added, and the branch was rebased onto current main), and all 23 checks are green now, including Read the Docs: https://icalendar.readthedocs.org/en/2118/

The PR Quality workflow only runs on opened and reopened, so it could not update the label itself. Could a maintainer please remove the ai-suspicion label? The PR is ready for review.

@angatha angatha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes itself LGTM

Comment thread news/2118.bugfix Resolved
The change log checker needs the AI disclosure and an @github_username
attribution in the entry itself, not only in the commit messages.

AI assistance disclosure: drafted with DeepSeek V4.1 Flash, used to add
the disclosure and attribution to news/2118.bugfix. I reviewed the result.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PARTSTAT and other enums should accept case-insensitive values

2 participants