Skip to content

Default argument types #118

Open
Open
@srush

Description

@srush

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions