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

add initial type for core #429

Merged
merged 5 commits into from
May 16, 2023
Merged

Conversation

asukaminato0721
Copy link
Contributor

No description provided.

@asukaminato0721
Copy link
Contributor Author

I meet one question:

how many types does parse_color have? According to the docstring, I think there are too many of it.

since *args and **kwargs can both take parameters.

from typing import overload
@overload
def parse_color(gray: float) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(gray: float, alpha: float) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(
    r: float,
    g: float,
    b: float,
    color_mode: str = "RGB",
    normed: bool = False,
    **kwargs,
) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(
    red: float,
    green: float,
    blue: float,
    color_mode: str = "RGB",
    normed: bool = False,
    **kwargs,
) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(
    h: float,
    s: float,
    b: float,
    color_mode: str = "HSB",
    normed: bool = False,
    **kwargs,
) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(
    r: float,
    g: float,
    b: float,
    a: float,
    color_mode: str = "RGB",
    normed: bool = False,
    **kwargs,
) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(
    h: float,
    s: float,
    b: float,
    a: float,
    color_mode: str = "HSB",
    normed: bool = False,
    **kwargs,
) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(hex: str) -> Tuple[float, float, float, float]:
    ...


@overload
def parse_color(color_name: str) -> Tuple[float, float, float, float]:
    ...

# and then put the color at kwargs.

@tushar5526
Copy link
Member

I think we can skip adding very specific types to parse_color. Our main focus is to annotate user facing APIs properly, followed by internal APIs

@tushar5526 tushar5526 merged commit bdafbb9 into p5py:master May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants