Skip to content

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented Sep 6, 2024

Change Summary

Fixes #10333
Requires pydantic/pydantic-core#1443

Ideally we would import _IncEx from pydantic-core, but some external tools requires these annotations to be available at runtime :/

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Sep 6, 2024
Copy link

cloudflare-workers-and-pages bot commented Sep 6, 2024

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5ab7f38
Status: ✅  Deploy successful!
Preview URL: https://fa7af8a1.pydantic-docs.pages.dev
Branch Preview URL: https://inc-ex-ann.pydantic-docs.pages.dev

View logs

pydantic/main.py Outdated
# Keep these type aliases available at runtime:
TupleGenerator: TypeAlias = Generator[Tuple[str, Any], None, None]
# Keep this type alias in sync with the stub definition in `pydantic-core`:
IncEx: TypeAlias = 'set[int] | set[str] | dict[int, IncEx | bool] | dict[str, IncEx | bool]'
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the | None and added it in the relevant method signatures, as it makes more sense imo to keep the type alias scoped to what it represents, and then have consumers of this type alias make it optional or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call.

Copy link

codspeed-hq bot commented Sep 6, 2024

CodSpeed Performance Report

Merging #10339 will not alter performance

Comparing inc-ex-ann (5ab7f38) with main (e060425)

Summary

✅ 49 untouched benchmarks

Copy link
Contributor

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

Looks good. What happened to ModelT?

pydantic/main.py Outdated
# Keep these type aliases available at runtime:
TupleGenerator: TypeAlias = Generator[Tuple[str, Any], None, None]
# Keep this type alias in sync with the stub definition in `pydantic-core`:
IncEx: TypeAlias = 'set[int] | set[str] | dict[int, IncEx | bool] | dict[str, IncEx | bool]'
Copy link
Contributor

Choose a reason for hiding this comment

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

Good call.

@Viicos
Copy link
Member Author

Viicos commented Sep 6, 2024

Looks good. What happened to ModelT?

I moved it just above the create_model definition, where it is used (so that it is more clear what it is for)

@sydney-runkle sydney-runkle enabled auto-merge (squash) September 7, 2024 15:26
@sydney-runkle sydney-runkle merged commit cdca7ae into main Sep 7, 2024
60 checks passed
@sydney-runkle sydney-runkle deleted the inc-ex-ann branch September 7, 2024 16:02
Copy link
Contributor

github-actions bot commented Sep 7, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic/_internal
  _model_construction.py
Project Total  

This report was generated by python-coverage-comment-action

sydney-runkle added a commit that referenced this pull request Sep 9, 2024
Co-authored-by: sydney-runkle <sydneymarierunkle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-fix Used for bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type alias for model_dump include/exclude is broken
2 participants