Repository navigation
fix: case-insensitive StrEnum value lookup per RFC 5545 - #2118
Mubashir78 wants to merge 2 commits into
Conversation
|
Thanks for the pull request, @Mubashir78! A maintainer will review it shortly. |
|
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. |
d4af97b to
8962c96
Compare
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.
8962c96 to
6d7414d
Compare
|
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. |
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.
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')raisesValueErroron main whilePARTSTAT.NEEDS_ACTIONworks.StrEnumnow implements_missing_, which looks up members by their casefolded value. The defined values keep their canonical spelling; only the lookup is relaxed. This also makesget()resolve any case variant through the regular constructor path.Checklist
Additional information
news/2118.bugfix, and it carries the brief AI disclosure and@Mubashir78attribution required by the policy.src/icalendar/tests/test_issue_1840.py(37 tests) covers case-insensitive lookups, exact lookups, unknown values, andstr()output for everyStrEnumsubclass. Locally I ran that file and theenumsdoctests 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_tzidzoneinfo 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.StrEnum.get()helper landed there; the conflict resolution keeps both mechanisms.