Skip to content

Navigation Menu

Sign in
Sign up

typing: add type hints to parser helper functions (#938) - #1743

Open
DaBestCode wants to merge 1 commit into
collective:main from
DaBestCode:type-hints-parser
Open

typing: add type hints to parser helper functions (#938) #1743
DaBestCode wants to merge 1 commit into
collective:main from
DaBestCode:type-hints-parser

Conversation

@DaBestCode

@DaBestCode DaBestCode commented Aug 31, 2026

Copy link
Copy Markdown

Linked issue

Description

This pull request adds comprehensive type hints to parser helper functions in the icalendar library, contributing to issue #938's goal of adding type hints throughout the codebase.

Changes Made

  1. src/icalendar/parser_tools.py:

    • Enhanced to_unicode() docstring with a "Returns" section to better document the function's return behavior
  2. src/icalendar/parser/parameter.py:

    • Added return type annotation -> Callable to the single_string_parameter() decorator function
    • Added parameter type annotation upper: bool = False to clarify the upper parameter's type
    • Added return type hints to inner functions:
      • decorator(): -> property
      • fget(): -> str | None (getter returns optional string)
      • fset(): -> None (setter returns None)
      • fdel(): -> None (deleter returns None)
  3. news/938.chore.2:

    • Added changelog entry documenting the type hint improvements

Benefits

  • Improved IDE autocompletion and type checking support
  • Better documentation through explicit type hints
  • Compatibility with static type checkers (mypy, pyright, etc.)
  • No changes to runtime behavior or logic

Checklist

Additional information

  • All existing tests pass (pytest src/icalendar/tests/test_unit_parser_tools.py and parameter-related tests)
  • Type hints follow PEP 484 conventions using Python 3.10+ union syntax (|)
  • Changes are backward compatible and contain no breaking changes

Copy link
Copy Markdown
Contributor

This pull request did not pass quality checks and AI use is suspected. Please review Contribute and make any necessary amendments.

@github-actions github-actions Bot added the ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding. label Aug 31, 2026

Copy link
Copy Markdown
Contributor

Profile summary:

GitHub user: DaBestCode
🟢 No concerns found with user's profile.
🟢 No concerns found with recent PR activity.
🟢 No concerns found with recent issue activity.
For a more detailed report, run `gh-profiler DaBestCode`.
Full profile
GitHub user: DaBestCode
🟢 No concerns found with user's profile.
 🟢 Account age: 2 years
 🟢 Profile information:
 name: Pruthvi Nandan Janga
 blog: https://myportfolio-phi-ebon.vercel.app/
 email: pjanga@asu.edu
 bio: LeetCode Freak
 linkedin: https://www.linkedin.com/in/pruthvi-janga-9609a3238
 Empty fields: company, location
🟢 No concerns found with recent PR activity.
 1 PR opened in the last 21 days.
 0 opened against repos the user owns.
 0 opened against repos in publicly associated orgs.
 1 opened against external repos.
 🟢 0 of 1 external PRs merged in the last 21 days.
 🟢 0 of 1 external PRs closed without merging in the last 21 days.
🟢 No concerns found with recent issue activity.
 🟢 No new issues opened in the last 21 days.

Copy link
Copy Markdown

Copy link
Copy Markdown
Member

CI fails == no review

@DaBestCode please follow our contributing guidelines. Thank you!

@niccokunzmann niccokunzmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! The change looks technically valid!

Could you give more detail about the AI use, please?

Comment thread news/938.chore.2
@@ -0,0 +1 @@
Added type annotations to :func:`~icalendar.parser.parameter.single_string_parameter` and expanded docstrings in :mod:`icalendar.parser_tools`. I used AI to assist me with this change. (Issue #938)

@niccokunzmann niccokunzmann Sep 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, please mention the model that you used.

Copy link
Copy Markdown
Member

@stevepiercy over to you: Have a look at the small docs change or just merge it when the changelog entry is ok for you.

Copy link
Copy Markdown
Member

@DaBestCode Welcome to icalendar! Nice to review your PR :)

Could you please format the code? We use a code formatter so that it always looks reliably the same. Please see here. https://github.com/collective/icalendar/actions/runs/33359907834/job/99389117324?pr=1743

Comment thread news/938.chore.2
@@ -0,0 +1 @@
Added type annotations to :func:`~icalendar.parser.parameter.single_string_parameter` and expanded docstrings in :mod:`icalendar.parser_tools`. I used AI to assist me with this change. (Issue #938)

@stevepiercy stevepiercy Sep 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't include the issue number, as it's included in the filename. Also give yourself credit.

Suggested change
Added type annotations to :func:`~icalendar.parser.parameter.single_string_parameter` and expanded docstrings in :mod:`icalendar.parser_tools`. I used AI to assist me with this change. (Issue #938)
Added type annotations to :func:`~icalendar.parser.parameter.single_string_parameter` and expanded docstrings in :mod:`icalendar.parser_tools`. I used AI to assist me with this change. @DaBestCode

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

Reviewers

@stevepiercy stevepiercy stevepiercy requested changes
@SashankBhamidi SashankBhamidi Awaiting requested review from SashankBhamidi
@angatha angatha Awaiting requested review from angatha angatha is a code owner
@niccokunzmann niccokunzmann Awaiting requested review from niccokunzmann niccokunzmann is a code owner

Requested changes must be addressed to merge this pull request.

Labels

ai-suspicion This contribution is possibly created with lots of AI help without enough human understanding.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /