Skip to content

Add ical_value property to vMonth - #2107

Open
jakkoyang wants to merge 1 commit into
PyCalendar:mainfrom
jakkoyang:vmonth-ical-value
Open

jakkoyang wants to merge 1 commit into
PyCalendar:mainfrom
jakkoyang:vmonth-ical-value

Conversation

@jakkoyang

Copy link
Copy Markdown

Linked issue

Description

vMonth didn't have an ical_value property, so vMonth(5).ical_value raised AttributeError.

  • adds an ical_value property to vMonth that returns the month number as a plain int, the same way vInt.ical_value does
  • for RFC 7529 leap months like 5L, it returns 5, and the leap flag stays available on vMonth.leap
  • adds test_vMonth.py covering regular months, leap months, the plain int type, the leap flag, and a month parsed from an RRULE
  • adds a news entry

Purely additive: vMonth is still an int subclass and .leap is unchanged, so existing code isn't affected/backwards compatible.

AI disclosure: I used Claude Opus 5.5 to help pick the return type and draft the tests and docstring though I reviewed and edited them, wrote the news entry, and ran everything locally.

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

Before: vMonth(5).ical_value raised AttributeError
After: vMonth(5).ical_value == 5 and vMonth("5L").ical_value == 5

I went with returning a plain int to match vInt, since an int subclass returning int(self) is the existing pattern, but if you'd prefer the leap flag to be part of the value instead (for example a NamedTuple like vN/vAdr use), I'm happy to change it!

All tests pass locally (uv run pytest).

Part of PyCalendar#876.

AI: Claude Opus 5.5

Prompt (summary): help pick a return type for vMonth.ical_value and draft tests.

Output: Draft of the tests and docstring. I reviewed and edited them, wrote the news entry, and ran the full test suite locally.
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

Insufficient data

Not enough activity yet to make a reliable assessment.

View full analysis →

This is an automated analysis by AgentScan

@jakkoyang

Copy link
Copy Markdown
Author

For vMonth I'm going with int(self) to match vInt. The RFC 7529 leap flag stays on vMonth.leap... it's purely additive, so nothing existing changes... im happy to switch if you'd prefer something else

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant