-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Use 'unknown' specialization for upper bound on Self #20325
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5708,9 +5708,7 @@ impl<'db> Type<'db> { | |
], | ||
}); | ||
}; | ||
let instance = Type::ClassLiteral(class).to_instance(db).expect( | ||
"nearest_enclosing_class must return type that can be instantiated", | ||
); | ||
Comment on lines
-5711
to
-5713
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would previously use the "default" specialization, and so we would end up with an upper bound of |
||
let instance = Type::instance(db, class.unknown_specialization(db)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wondered if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think you're right — it should translate typevars into the bound/constraints in covariant position, and to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opened astral-sh/ty#1164 |
||
let class_definition = class.definition(db); | ||
let typevar = TypeVarInstance::new( | ||
db, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default values for type parameters have only been introduced recently (https://peps.python.org/pep-0696/)