Skip to content

Fix parameter type lookup during xCal serialization - #2038

Open
shekhar4704 wants to merge 6 commits into
PyCalendar:mainfrom
shekhar4704:fix/parameter-types
Open

shekhar4704 wants to merge 6 commits into
PyCalendar:mainfrom
shekhar4704:fix/parameter-types

Conversation

@shekhar4704

@shekhar4704 shekhar4704 commented Oct 27, 2026 •

Copy link
Copy Markdown

Linked issue

Description

Fixed xCal serialization of parameters whose names overlap with property names.

Parameters are now resolved using their own parameter type mapping instead of the property type mapping. Added tests covering parameter serialization and deserialization, including parameters whose names overlap with property names.

Checklist

Additional information

The relevant xCal parameter tests pass locally: 67 passed.

The full test suite was also run, but it currently reports failures/errors, so the full-test checklist item is intentionally left unchecked.

@github-actions

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
Contributor

One or more PR-quality checks did not pass. Review the PR Quality Checks summary in the workflow run for the failed checks and their details, then make any necessary updates.

Checklist items may remain unchecked while work is in progress. Please tick each item as you complete it.

If you used AI assistance, follow the project's Responsible AI use policy and provide the required disclosures.

@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

@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.

Thank you for the PR!

I left some comments...

The bug is important to fix.

If you would like to make a few OOP adjustments, now is also the time for that. We are prior to a major release, so we can split things up a bit.

Comment thread src/icalendar/prop/factory.py Resolved
Comment thread src/icalendar/prop/factory.py Resolved
Comment thread src/icalendar/prop/factory.py Resolved
@shekhar4704
shekhar4704 force-pushed the fix/parameter-types branch 2 times, most recently from c860bf4 to 85df3f8 Compare October 27, 2026 21:14
AI model: GPT-5.6 Luna
AI use: Used AI to help analyze the failing xCal parameter serialization tests,
 identify the parameter/property type-map lookup issue, and draft the test and changelog changes.
 I reviewed and validated the changes locally.

@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.

Thank you for the changes.

Let's keep this minimal and discard my idea about the for_name function.

I left some suggestions. Please have a look and let me know what you think! Thank you!

"sent-by": "cal-address",
"tzid": "text",
"value": "text",
# rfc 9253 parameters

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.

That comment is useful.

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.

Could you add it back?

Comment thread src/icalendar/prop/factory.py Resolved
@shekhar4704

Copy link
Copy Markdown
Author

Hi @niccokunzmann, I've addressed your suggestions and pushed the updates. The relevant tests are passing, and all CI checks are now successful. Could you please review the latest changes when you get a chance? 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.

Thank you! I left another review :)


def for_parameter(self, name: str) -> type[VPROPERTY]:
"""Returns the type class for a parameter."""
return self[self.parameter_types_map.get(name.upper(), "unknown")]

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.

This is really nice! So much smaller and cleaner than passing this through the other one.

Could you also add Parameters: and Returns: here according to our style guide?

if name in self.types_map:
type_class = self.for_property(name)
else:
type_class = self.for_parameter(name)

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.

This indicates that what I thought. I does the job but to make it clean, this function would also need splitting up. We can leave it here for now. Is this also used by the parameters?


def test_property_name_matching_parameter_uses_property_type():
"""A property named after a parameter uses the property type."""
event = Event.from_ical("BEGIN:VEVENT\r\nTZID:hello\r\nEND:VEVENT\r\n")

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.

tzid is in both using text.

If you use rsvp, then it should be text whereas before it was boolean.

Basically, this test needs to fail on main but work here and demonstrate that you solved the issue of them getting split up.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Parameters named like a property break to_xcal()

2 participants