Add return type hints to all functions in main source code#1363
Open
xxiaoxiong wants to merge 3 commits into
Open
Add return type hints to all functions in main source code#1363xxiaoxiong wants to merge 3 commits into
xxiaoxiong wants to merge 3 commits into
Conversation
- 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)
Documentation build overview
14 files changed ·
|
- 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)
Member
|
@xxiaoxiong would you please:
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! |
angatha
requested changes
May 14, 2026
|
|
||
|
|
||
| def pickle_rrule_with_cache(self: rrule): | ||
| def pickle_rrule_with_cache(self: rrule) -> tuple[functools.partial, tuple]: |
Collaborator
There was a problem hiding this comment.
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]: |
Collaborator
There was a problem hiding this comment.
Please use a more usefull type than tuple.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()→Noneproperty_del_duration()→NoneCommit 2: Timezone and CLI functions (5 functions)
use_pytz()→Noneuse_zoneinfo()→Nonemain()(cli.py) →Nonerfc_7953_end_propertysetter →Nonerfc_7953_end_propertydeleter →NoneCommit 3: Property factories, parsers, and pickle functions (9 functions)
timezone_datetime_property()→propertymulti_string_property()→propertyunescape_backslash()→strsingle_string_parameter()→Callable | propertypickle_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()→rrulesetmain()(fuzzing) →NoneTesting
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)