Merge constructor docstrings into class docstrings - #1622
Conversation
AI disclosure: I used OpenAI Codex (GPT-5) to inventory all __init__ and __new__ docstrings, migrate and merge their content into class docstrings, add the AST regression test, update the Sphinx configuration and news entry, and review local test and documentation results. I reviewed and validated the changes.
|
This pull request did not pass quality checks and AI use is suspected. Please review Contribute and make any necessary amendments. |
|
Profile summary: Full profile |
Documentation build overview
45 files changed ·
|
|
@krrishapatel please dont paste AI generated output like this. Keep the important parts. Did you verify that the AI did its job correct? I prefer not to do the suggestion since an |
|
I'm in the middle of a thorough review while in transit. Please don't merge until I have the chance to complete it. |
stevepiercy
left a comment
There was a problem hiding this comment.
This is fantastic work. Thank you for your effort. Would you please review my suggestions, and take care? Thank you!
| Component is the base object for calendar, Event and the other | ||
| components defined in :rfc:`5545`. Normally you will not use this class |
There was a problem hiding this comment.
| Component is the base object for calendar, Event and the other | |
| components defined in :rfc:`5545`. Normally you will not use this class | |
| Component is the base object for calendar, Event, and the other | |
| components defined in :rfc:`5545`. Normally you won't use this class |
|
|
||
| All properties of the calendar component are parsed immediately. | ||
| Subcomponents and their properties are parsed lazily. | ||
| A new calendar starts with no subcomponents. |
There was a problem hiding this comment.
This is a strange statement, and I don't think it's true in this context. The lazy module is special, in that it lazily parses subcomponents upon initialization. Perhaps @SashankBhamidi or @niccokunzmann can provide a more accurate description of what initialization actually does? Or maybe just remove this statement, as I think the existing description is accurate enough? My Python vocabulary is less proficient than theirs.
There was a problem hiding this comment.
Yes, it's true, but it's equally true of a plain Calendar(). The __init__ sets InitialSubcomponentsStrategy, which transitions to LazySubcomponentsStrategy when super().__init__() sets subcomponents = []. The existing description already says what matters. I'd drop the sentence.
| component_factory: Required. The factory to use for creating components. | ||
| data: Required. The raw iCalendar data to parse, either as bytes or a | ||
| list of content lines. | ||
| types_factory: Required. The factory to use for creating property values. |
There was a problem hiding this comment.
Nice! Thanks for watching the latest update about sorting parameters and adding "Required."
One minor correction from the original.
| component_factory: Required. The factory to use for creating components. | |
| data: Required. The raw iCalendar data to parse, either as bytes or a | |
| list of content lines. | |
| types_factory: Required. The factory to use for creating property values. | |
| component_factory: Required. The factory to use for creating components. | |
| data: Required. The raw iCalendar data to parse, either as bytes, string, | |
| or a list of content lines. | |
| types_factory: Required. The factory to use for creating property values. |
| Parameters: | ||
| name: Required. The name of the subcomponent. | ||
| parser: Required. The parser that holds the raw subcomponent data. |
There was a problem hiding this comment.
Another good improvement. ❤️
| computation. | ||
|
|
||
| Examples: | ||
| This example uses RFC 9074. One alarm is 30 minutes before the event and |
There was a problem hiding this comment.
| This example uses RFC 9074. One alarm is 30 minutes before the event and | |
| This example uses :rfc:`9074`. One alarm is 30 minutes before the event and |
| >>> alarms.active[0].trigger # this alarm triggers 15 minutes before 10:30 | ||
| datetime.datetime(2021, 3, 2, 10, 15, tzinfo=ZoneInfo(key='America/New_York')) | ||
|
|
||
| RFC 9074 specifies that alarms can also be triggered by proximity. |
There was a problem hiding this comment.
| RFC 9074 specifies that alarms can also be triggered by proximity. | |
| :rfc:`9074` specifies that alarms can also be triggered by proximity. |
| component: An alarm, event, or to-do component with which to start the | ||
| computation. |
There was a problem hiding this comment.
Let's link these to the component class, and rewrap for ruff.
| component: An alarm, event, or to-do component with which to start the | |
| computation. | |
| component: An :class:`~icalendar.cal.alarm.Alarm`, :class:`~icalendar.cal.event.Event`, or :class:`~icalendar.cal.todo.Todo` component with which to start the computation. |
| **kwargs: Keyword arguments passed to :class:`~collections.OrderedDict`. | ||
|
|
||
| Example: | ||
| Examples: |
There was a problem hiding this comment.
I see only one example.
| Examples: | |
| Example: |
| path: The location in the jCal structure where the error occurred. | ||
| parser: The parser class or its name where the error occurred. |
There was a problem hiding this comment.
Sort. path doesn't look required to me.
| path: The location in the jCal structure where the error occurred. | |
| parser: The parser class or its name where the error occurred. | |
| parser: The parser class or its name where the error occurred. | |
| path: The location in the jCal structure where the error occurred. |
Solaris-star
left a comment
There was a problem hiding this comment.
Reviewed — this covers the same ground as my now-closed #1623, and does it more completely. A few observations:
-
autoclass_content = "class"indocs/conf.py— good catch, I missed this in my version. Without it Sphinx would still try to render__init__docstrings if any slipped through. -
Test placement: putting the AST check in the existing
test_docstrings.pyis better than a standalone file — keeps all docstring policy tests together. -
Required.prefix: consistent with the convention @stevepiercy established in #1603. Nice. -
One minor note: the test uses
Path(icalendar.__file__).parentwhich resolves correctly for installed packages, but if someone runs tests from a source checkout without installing, the path still works sinceicalendar.__file__points to the source tree. No issue, just confirming I checked. -
The news fragment is present — my #1623 was missing that. Lesson learned.
Happy to help with any follow-up on this if needed.
SashankBhamidi
left a comment
There was a problem hiding this comment.
Thanks Felix. I ran the new test against main and confirmed it fails there.
Steve's suggestions are all still open. One more thing inline.
Procedural note: if any part of this was AI-assisted, please follow the Responsible AI use policy. Standard reminder.
| parent: The parent component to which the alarm refers. | ||
| snoozed_until: A datetime in UTC until which the alarm has been snoozed. |
There was a problem hiding this comment.
The parameter order in the docstring doesn't match the signature. The __init__ signature (line 60) has snoozed_until before parent, but the docstring has them reversed. Parameters should follow signature order.
| parent: The parent component to which the alarm refers. | |
| snoozed_until: A datetime in UTC until which the alarm has been snoozed. | |
| snoozed_until: A datetime in UTC until which the alarm has been snoozed. | |
| parent: The parent component to which the alarm refers. |
There was a problem hiding this comment.
Actually, we changed this in https://icalendar.readthedocs.io/en/latest/contribute/documentation/style-guide.html#docstring-structure. Alphabetically sorted within each group of required and optional parameters is correct.
|
|
||
| All properties of the calendar component are parsed immediately. | ||
| Subcomponents and their properties are parsed lazily. | ||
| A new calendar starts with no subcomponents. |
There was a problem hiding this comment.
Yes, it's true, but it's equally true of a plain Calendar(). The __init__ sets InitialSubcomponentsStrategy, which transitions to LazySubcomponentsStrategy when super().__init__() sets subcomponents = []. The existing description already says what matters. I'd drop the sentence.
|
Hi @felix-windsor, could you take care of the conflicts please? Let us know if you need any support from our side. |
|
Uh. Yes, that is a problem when creating a big PR on an active repository. @felix-windsor Your contribution is welcome and I hope to see it go through. If you like, create smaller PRs for the changes and they have less merge work in them. |
Linked issue
__init__or__new__docstrings into their class's docstring #1620Description
Moves every
__init__and__new__docstring in the package into its containing class docstring so API documentation has a single source of class-level content.This also:
autoclass_content = "class";Responsible AI disclosure: I used OpenAI Codex (GPT-5) to inventory and migrate the docstrings, draft the AST regression test, update the Sphinx configuration and news entry, and review validation output. I reviewed the complete diff and validated the changes locally.
Checklist
Additional information
Local validation:
uv run pytest -q: 17,888 passed, 28 skipped, 529 xfailed.make test: CPython 3.10, 3.11, 3.12, 3.13, and 3.14 passed; thenopytzenvironment passed.CARGO_NET_GIT_FETCH_WITH_CLI=true uv run tox -e pypy3: passed with 97% coverage.make htmlSphinx build: passed with warnings treated as errors.uv run ruff format --check,uv run ruff check, andgit diff --check: passed.The combined docs tox run completed HTML, doctest, and Vale successfully; its link-check phase only reported two pre-existing external-site responses unrelated to this change: a 404 from the sphinx-reredirects documentation URL and a 403 from a Stack Overflow timezone link.