Skip to content

Add Cls and PropName so fields can be specialized by derived types#64

Closed
dnwpark wants to merge 8 commits intomainfrom
type-self
Closed

Add Cls and PropName so fields can be specialized by derived types#64
dnwpark wants to merge 8 commits intomainfrom
type-self

Conversation

@dnwpark
Copy link
Contributor

@dnwpark dnwpark commented Jan 30, 2026

Replace type(typing.Self) with the class that is evaluating the annotation.

For example:

class NodeA:
    child: type(Self) | None

class NodeB(NodeA):
    pass

would be equivalent to:

class NodeA:
    child: NodeA | None

class NodeB(NodeA):
    child: NodeB | None

@dnwpark dnwpark requested a review from msullivan January 30, 2026 01:36
@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
python-typemap Ready Ready Preview, Comment Feb 2, 2026 6:22pm

@msullivan
Copy link
Collaborator

Why not just Self? And do we need this?

@dnwpark
Copy link
Contributor Author

dnwpark commented Feb 2, 2026

@msullivan I've added an rough implementation for PropName and qblike_3 example to show why I want both of these.

Given a table User, I want to be able to join the table on itself, so I create a UserAlias class. This alias's attributes need to have their FieldTable values different from the base User type. Otherwise, the select will combine them and only select from User.

This is based on an example from the sql alchemy docs: https://docs.sqlalchemy.org/en/20/tutorial/data_select.html#tutorial-using-aliases

Copy link

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

GetMember operator doesn't set current_cls context, causing Cls type references to remain unresolved when accessing member types

Fix on Vercel

@dnwpark dnwpark changed the title Evaluate type(typing.Self). Add Cls and PropName so fields can be specialized by derived types Feb 4, 2026
@dnwpark dnwpark closed this Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants