Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Raise a better error when a generic alias is used insidetype[]#11088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Viicos merged 1 commit intomainfromtype-gen-alias-error
Dec 13, 2024

Conversation

Viicos
Copy link
Member

As per#11000 (comment).

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-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelDec 11, 2024
if _typing_extra.is_generic_alias(type_param):
raise PydanticUserError(
'Subscripting `type[]` with an already parametrized type is not supported. '
f'Instead of using type[{type_param!r}], use type[{_repr.display_as_type(get_origin(type_param))}].',
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Becausetype_param is a generic alias, we can rely on its__repr__ implementation, which usestyping._type_repr to do a pretty representation already.

However, we still use our_repr.display_as_type (inspired bytyping._type_repr) for the origin, which isnot a generic alias anymore but a proper class.

This should cover most use cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good.@dmontagu mentioned that we might want to support this eventually, so can we say "not yet supported", and link to the issue?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Imo trying to support this is going to introduce lots of maintenance burden for the reason I mentioned in#11000 (comment), and maybe not possible at all as mentioned in#10462 (comment).

sydney-runkle reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, should we close#11000 then?

@codspeed-hqCodSpeed HQ
Copy link

CodSpeed Performance Report

Merging#11088 willnot alter performance

Comparingtype-gen-alias-error (de4bbea) withmain (cc01258)

Summary

✅ 46 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

Coverage report

Click to see where and how coverage changed

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

This report was generated bypython-coverage-comment-action

@ViicosViicos added relnotes-feature and removed relnotes-fixUsed for bugfixes. labelsDec 11, 2024
Copy link
Contributor

@sydney-runklesydney-runkle left a comment

Choose a reason for hiding this comment

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

Thanks!

@ViicosViicos merged commitc393317 intomainDec 13, 2024
55 checks passed
@ViicosViicos deleted the type-gen-alias-error branchDecember 13, 2024 10:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp