Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Python 3.11 pydantic's use of dataclass_transform is incorrect #4500

Closed
6 of 16 tasks
erictraut opened this issue Sep 7, 2022 · 13 comments
Closed
6 of 16 tasks

On Python 3.11 pydantic's use of dataclass_transform is incorrect #4500

erictraut opened this issue Sep 7, 2022 · 13 comments
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@erictraut
Copy link

Initial Checks

  • I have searched GitHub for a duplicate issue and I'm sure this is something new
  • I have searched Google & StackOverflow for a solution and couldn't find anything
  • I have read and followed the docs and still think this is a bug
  • I am confident that the issue is with pydantic (not my code, or another library in the ecosystem like FastAPI or mypy)

Description

Pydantic uses PEP 681's dataclass_transform for compatibility with static type checkers. One of the features described in PEP 681 is the ability to describe a set of custom "field specifier" classes. In an early version of PEP 681, these were specified using a parameter named field_descriptors, but based on feedback the parameter name was changed to field_specifiers for the final version of the PEP. Pydantic is still using the (now obsolete) parameter name.

See microsoft/pyright#3912 for details.

Example Code

No response

Python, Pydantic & OS Version

Python 3.11
Pydantic 1.10.2

Affected Components

@erictraut erictraut added bug V1 Bug related to Pydantic V1.X unconfirmed Bug not yet confirmed as valid/applicable labels Sep 7, 2022
@samuelcolvin
Copy link
Member

Thanks so much, will fix.

@samuelcolvin samuelcolvin removed the unconfirmed Bug not yet confirmed as valid/applicable label Sep 7, 2022
samuelcolvin added a commit that referenced this issue Sep 7, 2022
samuelcolvin added a commit that referenced this issue Sep 7, 2022
@samuelcolvin
Copy link
Member

will be fixed in #4501.

@samuelcolvin
Copy link
Member

ops, cherry-picking to main closed this.

@samuelcolvin samuelcolvin reopened this Sep 7, 2022
@erictraut
Copy link
Author

@samuelcolvin, thanks for the quick fix!

Currently there are relatively few pydantic + pyright users who are on Python 3.11, but that number will increase as 3.11 approaches release. I could put some temporary special-case hackery in place within pyright to work around this issue, but I'd prefer not to do this if it can be helped. It looks like you release new versions of pydantic pretty frequently (ever week or so). I think it's therefore safe to just wait for your next release and tell developers to upgrade to it. Let me know if you have concerns with that plan.

@samuelcolvin
Copy link
Member

A patch release for v1.10 (the first pydantic version which supports 3.11) will be out in the next few days I would guess, so no need.

I've also fixed it on main, so it'll be correct in v2.

@samuelcolvin
Copy link
Member

thanks for letting me know about this, on this occasion the fix was very simple.

@samuelcolvin
Copy link
Member

closed via #4501

@kkom
Copy link

kkom commented Dec 6, 2022

hey @samuelcolvin – as far as I can see v1.10.2 was released on September 5 without #4501 (which was merged on September 7)

do you think it would be possible to release a new patch release with this fix? it's been a few months now, and I'm hitting this error when working on https://github.com/RobertCraigie/prisma-client-py/

it's not the end of the world, as in this particular case the need for # type: ignore in my code is not too widespread, but it would still make things much cleaner!

@samuelcolvin
Copy link
Member

Thanks for asking, best to comment on #4552, I'll try to get something out next week.

@kkom
Copy link

kkom commented Dec 6, 2022

thank you so much @samuelcolvin :) (also for the original fix!)

@WilliamDEdwards
Copy link

I'll try to get something out next week.

Would that include #4568?

@samuelcolvin
Copy link
Member

Yes, but "next week" has become a whirl wind.

This is very much on my conscience, but we're probably looking at next week (again). So sorry.

@WilliamDEdwards
Copy link

Yes, but "next week" has become a whirl wind.

This is very much on my conscience, but we're probably looking at next week (again). So sorry.

Your efforts are highly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

No branches or pull requests

4 participants