-
Notifications
You must be signed in to change notification settings - Fork 24
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
Set precedence of individual types #140
Comments
Hey @sylvorg, absolutely not a problem! I massively appreciate your issues. Please feel free to keep opening them!! I'll do my best to respond as quickly as possible, though sometimes I won't have the capacity to get back to you quickly. Currently, there is no way to set the precedence of individual types. Ideally, you would create this precedence by making the one type a subtype of another. In your case, I think your problem would be solved by making |
No worries, take all the time you need! Greatness can't be rushed, after all! The problem with making |
Also, I'd like |
@sylvorg would you be able to give a full MWE of what you'd like to achieve, the one with |
Basically, Would you happen to know how I can turn these into full-fledged classes that I can subscript as well? Because I don't know how to use |
Hey @sylvorg! Apologies for the delay. It's a busy and hectic time. Plum relies on a so-called partial order between types (basically, a What you seem to want to achieve is to slightly modify the partial order currently defined by However, what has come up before, and what would be feasible, is to make the "type system" configurable for every dispatcher. You would be able to do something like this: def partial_order(type1, type2):
return TypeHint(type1) <= TypeHint(type2)
dispatch = Dispatcher(type_system=partial_order) You could then base your How would something like that sound? |
Hello, and sorry for bothering you so many times! 😅
As in the title; is there any way to set the precedence of individual types? For example, using
beartype.vale.Is
, I have cobbled together an annotationExactOrigin
which should be tested beforeCallable
, for example. But when I use those two annotations in aplum
function, I get anAmbiguousLookupError
. Is there any way to set the precedence ofExactOrigin
overCallable
?Thank you kindly for the help!
The text was updated successfully, but these errors were encountered: