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

Default argument types #118

Open
srush opened this issue Oct 25, 2022 · 0 comments
Open

Default argument types #118

srush opened this issue Oct 25, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@srush
Copy link
Collaborator

srush commented Oct 25, 2022

Make a pass at:

#97

As a user it is pretty annoying that you need to wrap types for many common cases in Chalk. However, it is also really nice that the types act as documentation for what is expected at each call site.

Proposal: Follow the npt library for numpy by introducing wrapper types: ColorLike, P2Like, V2Like, NameLike, RotationLike? that represent types that can be coerced to the right type. Each with a function to_color(x: ColorLike) -> Color that is called on entrance to these functions. Another benefit of this is that we can throw better run time errors for users who don't run mypy.

Downside: This is a bit slow obviously. We could also try to do this with decorations or something fancy. However I think being explicit is better here.

@danoneata danoneata added the enhancement New feature or request label Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants