Skip to content

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented Nov 25, 2024

Fixes #10971.

For Python < 3.10, we define EllipsisType = type(Ellipsis) in _typing_extra. EllipsisType is then used in a type expression but pyright raises an error because EllipsisType is defined as variable.

Instead, we make use of the ellipsis builtin, only available for type checkers (defined in typeshed) as a compatibility hack.

Change Summary

Related issue number

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 Nov 25, 2024
Copy link

cloudflare-workers-and-pages bot commented Nov 25, 2024

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1fb04ac
Status: ✅  Deploy successful!
Preview URL: https://73a3bb43.pydantic-docs.pages.dev
Branch Preview URL: https://ellipsis-compat.pydantic-docs.pages.dev

View logs

@Viicos Viicos enabled auto-merge (squash) November 25, 2024 17:21
Copy link

codspeed-hq bot commented Nov 25, 2024

CodSpeed Performance Report

Merging #10972 will improve performances by 5.55%

Comparing ellipsis-compat (1fb04ac) with main (1667c84)

Summary

⚡ 1 improvements
✅ 45 untouched benchmarks

Benchmarks breakdown

Benchmark main ellipsis-compat Change
test_getattr 57.3 µs 54.3 µs +5.55%

Copy link
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

… 3.9

For Python < 3.10, we define `EllipsisType = type(Ellipsis)` in
`_typing_extra`. `EllipsisType` is then used in a type expression
but pyright raises an error because `EllipsisType` is defined as
variable.

Instead, we make use of the `ellipsis` builtin, only available
for type checkers (defined in typeshed) as a compatibility hack.
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.

Nice work, thanks

@Viicos Viicos merged commit a67002a into main Nov 25, 2024
54 checks passed
@Viicos Viicos deleted the ellipsis-compat branch November 25, 2024 18:18
sydney-runkle pushed a commit that referenced this pull request Nov 26, 2024
… 3.9 (#10972)

For Python < 3.10, we define `EllipsisType = type(Ellipsis)` in
`_typing_extra`. `EllipsisType` is then used in a type expression
but pyright raises an error because `EllipsisType` is defined as
variable.

Instead, we make use of the `ellipsis` builtin, only available
for type checkers (defined in typeshed) as a compatibility hack.
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 of "Field" is partially unknown after v2.10
2 participants