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
Currently the function/method signature hooks must return a CallableType. This precludes cases where a union of CallableTypes would be more appropriate.
For example, given
@attrs.defineclassC1:
foo: int@attrs.defineclassC2:
bar: intc: C1|C2
then the signature of attrs.evolve for c could be returned by a function signature hook to be (c: C1, foo: int) -> C1 | (c: C2, bar: int) -> C2.
Today #14849 performs an ad-hoc "meet" operation which results in a single callable type, which could instead be left to the existing functionality that "meet"s a union's types.
p.s. that being said, the current behavior for a union of callables is not friendly, e.g.
in this playground, the given union of callables can accept a bytes arg, but if you give them the mutually incompatible int or str, it simply says that it must be the other one, instead of saying "it's compatible with item 1 of the union but incompatible with item 2", etc.
The text was updated successfully, but these errors were encountered:
Currently the function/method signature hooks must return a
CallableType
. This precludes cases where a union ofCallableType
s would be more appropriate.For example, given
then the signature of
attrs.evolve
forc
could be returned by a function signature hook to be(c: C1, foo: int) -> C1 | (c: C2, bar: int) -> C2
.Today #14849 performs an ad-hoc "meet" operation which results in a single callable type, which could instead be left to the existing functionality that "meet"s a union's types.
p.s. that being said, the current behavior for a union of callables is not friendly, e.g.
in this playground, the given union of callables can accept a
bytes
arg, but if you give them the mutually incompatibleint
orstr
, it simply says that it must be the other one, instead of saying "it's compatible with item 1 of the union but incompatible with item 2", etc.The text was updated successfully, but these errors were encountered: