You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After some research, pep673 rejects the case using Self when metaclasses are involved
Likewise, we reject Self in metaclasses. Self in this PEP consistently refers to the same type (that of self). But in metaclasses, it would have to refer to different types in different method signatures. For example, in mul, Self in the return type would refer to the implementing class Foo, not the enclosing class MyMetaclass. But, in new, Self in the return type would refer to the enclosing class MyMetaclass. To avoid confusion, we reject this edge case.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
unmodified relevant portions from
sqlmodel.main
Can see __new__ return type is
Any
Propose
__new__ return type Self
After some research, pep673 rejects the case using Self when metaclasses are involved
Operating System
Linux
Operating System Details
Void Linux LXDE
SQLModel Version
0.0.24
Python Version
3.9.16
Additional Context
pydantic 2.11.7
pydantic_core 2.33.2
SQLAlchemy 2.0.40
Beta Was this translation helpful? Give feedback.
All reactions