Skip to content

Add return type hints to all functions in main source code#1363

Open
xxiaoxiong wants to merge 3 commits into
collective:mainfrom
xxiaoxiong:add-type-hints-duration-properties
Open

Add return type hints to all functions in main source code#1363
xxiaoxiong wants to merge 3 commits into
collective:mainfrom
xxiaoxiong:add-type-hints-duration-properties

Conversation

@xxiaoxiong
Copy link
Copy Markdown

@xxiaoxiong xxiaoxiong commented May 7, 2026

This PR adds return type hints to all 16 functions that were missing them in the main source code (excluding tests).

Changes

Commit 1: Duration property functions (2 functions)

  • property_set_duration()None
  • property_del_duration()None

Commit 2: Timezone and CLI functions (5 functions)

  • use_pytz()None
  • use_zoneinfo()None
  • main() (cli.py) → None
  • rfc_7953_end_property setter → None
  • rfc_7953_end_property deleter → None

Commit 3: Property factories, parsers, and pickle functions (9 functions)

  • timezone_datetime_property()property
  • multi_string_property()property
  • unescape_backslash()str
  • single_string_parameter()Callable | property
  • pickle_tzicalvtz()tuple[type[_tzicalvtz], tuple]
  • pickle_rrule_with_cache()tuple[functools.partial, tuple]
  • pickle_rruleset_with_cache()tuple[type[unpickle_rruleset_with_cache], tuple]
  • unpickle_rruleset_with_cache()rruleset
  • main() (fuzzing) → None

Testing

  • ✅ All 9,441 tests pass
  • ✅ No breaking changes
  • ✅ All non-private functions in main source code now have return type hints

Impact

This completes the type hint coverage for all public functions in the main source code, making the codebase more maintainable and IDE-friendly.

Contributes to #938 (Add type hints)

- Added -> None return type hint to property_set_duration function
- Added -> None return type hint to property_del_duration function

Contributes to collective#938 (Add type hints)
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 7, 2026

xxiaoxiong added 2 commits May 7, 2026 08:24
- Added -> None to use_pytz() in timezone/__init__.py
- Added -> None to use_zoneinfo() in timezone/__init__.py
- Added -> None to main() in cli.py
- Added -> None to rfc_7953_end_property setter in attr.py
- Added -> None to rfc_7953_end_property deleter in attr.py

All functions have no return statements, so return type is None.

Contributes to collective#938 (Add type hints)
- Added -> property to timezone_datetime_property() in attr.py
- Added -> property to multi_string_property() in attr.py
- Added -> str to unescape_backslash() in parser/property.py
- Added -> Callable | property to single_string_parameter() in parser/parameter.py
- Added -> tuple[type[_tzicalvtz], tuple] to pickle_tzicalvtz() in timezone/zoneinfo.py
- Added -> tuple[functools.partial, tuple] to pickle_rrule_with_cache() in timezone/zoneinfo.py
- Added -> tuple[type[unpickle_rruleset_with_cache], tuple] to pickle_rruleset_with_cache() in timezone/zoneinfo.py
- Added -> rruleset to unpickle_rruleset_with_cache() in timezone/zoneinfo.py
- Added -> None to main() in fuzzing/ical_fuzzer.py

This completes all missing return type hints in the main source code.

Contributes to collective#938 (Add type hints)
@xxiaoxiong xxiaoxiong requested a review from ennamarie19 as a code owner May 7, 2026 00:33
@xxiaoxiong xxiaoxiong changed the title Add return type hints to duration property functions Add return type hints to all functions in main source code May 7, 2026
Copy link
Copy Markdown
Member

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Thank you!

@stevepiercy
Copy link
Copy Markdown
Member

@xxiaoxiong would you please:

  • Update your branch against main
  • Fix code style with ruff
  • Resolve any change conflicts
  • Add a change log entry

For details, see https://icalendar.readthedocs.io/en/stable/contribute/index.html and https://icalendar.readthedocs.io/en/stable/contribute/development.html. All of your other PRs might need the same treatment.

Thank you!



def pickle_rrule_with_cache(self: rrule):
def pickle_rrule_with_cache(self: rrule) -> tuple[functools.partial, tuple]:
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.

Please use a more usefull type than functools.partial and tuple.



def pickle_rruleset_with_cache(rs: rruleset):
def pickle_rruleset_with_cache(rs: rruleset) -> tuple[type[unpickle_rruleset_with_cache], tuple]:
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.

Please use a more usefull type than tuple.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants