Skip to content

Conversation

@Viicos
Copy link
Member

@Viicos Viicos commented Jun 26, 2025

Change Summary

Related issue number

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@Viicos Viicos enabled auto-merge (squash) June 26, 2025 08:27
@Viicos Viicos merged commit 5e3bbb5 into main Jun 26, 2025
30 checks passed
@Viicos Viicos deleted the document-serialization-info branch June 26, 2025 08:32
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 26, 2025

CodSpeed Performance Report

Merging #1747 will not alter performance

Comparing document-serialization-info (9b239c1) with main (d9dacb0)

Summary

✅ 157 untouched benchmarks


@property
def mode(self) -> str: ...
def mode(self) -> Literal['python', 'json']:
Copy link
Contributor

@l00ptr l00ptr Jul 29, 2025

Choose a reason for hiding this comment

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

Hi @Viicos,

In another place, Pydantic is less restrictive and allows the use of mode: Literal['json', 'python'] | str = 'python', so using only a Literal with two possibilities won't cause any problems?

On our end, MyPy throws errors because we use a custom mode for some models. Perhaps the other mode definitions (in pydantic) will evolve, and we'll have to find another way to use the "custom" mode. However, I currently don't know how to do that.

Best regards,
J.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @l00ptr, could you please provide more details on how you managed to integrate a custom mode in your Pydantic code? We currently support only two hardcoded modes, and I'd like to avoid "advertising" than custom modes may be supported while it isn't the case.

The existing Literal['json', 'python'] | str annotations were introduced a long time ago in pydantic/pydantic#4978, my best guess being that it wasn't clear if only two modes were to be supported.

Viicos added a commit that referenced this pull request Sep 29, 2025
davidhewitt pushed a commit to pydantic/pydantic that referenced this pull request Oct 20, 2025
davidhewitt pushed a commit to pydantic/pydantic that referenced this pull request Oct 22, 2025
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.

2 participants