Skip to content
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

Make typing functions using protocols more ergonomic #709

Closed
evhub opened this issue Dec 27, 2022 · 2 comments
Closed

Make typing functions using protocols more ergonomic #709

evhub opened this issue Dec 27, 2022 · 2 comments

Comments

@evhub
Copy link
Owner

evhub commented Dec 27, 2022

Should compile

def func[T <: (+) & (*)](x: T, y: T) -> T = x + x * y

to the equivalent of

def func[T <: ProtocolIntersection[SupportsAdd, SupportsMul]](x: T, y: T) -> T = x + x * y

where SupportsAdd is some special Coconut typing.Protocol for supporting __add__ and ProtocolIntersection is from here.

@evhub evhub added the feature label Dec 27, 2022
@evhub evhub added this to the v3.0.0 milestone Dec 27, 2022
@evhub
Copy link
Owner Author

evhub commented Jan 15, 2023

Since & is valid Python, we'll probably need to use a custom operator for protocol intersection, which will probably be &:.

@evhub
Copy link
Owner Author

evhub commented Apr 23, 2023

Blocked on klausweiss/typing-protocol-intersection#4.

I'm just going to implement this with inheritance rather than ProtocolIntersection.

evhub added a commit that referenced this issue Apr 23, 2023
evhub added a commit that referenced this issue Apr 24, 2023
@evhub evhub added the resolved label Apr 24, 2023
@evhub evhub closed this as completed Apr 24, 2023
@evhub evhub mentioned this issue May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant