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

Running with mypyc ends up with placeholder types where there shouldnt be #936

Open
davfsa opened this issue Jun 23, 2022 · 1 comment
Open

Comments

@davfsa
Copy link

davfsa commented Jun 23, 2022

When running mypyc on my project, I ended up with some errors that dont occur when running mypy normally (it passes mypy strict with no errors/warnings). I havent been successful to extract the error in a different environment, so I have attached the relevant pieces of code with permanent links to them. If any more information is required or if someone could point me in the right direction to fix this, would be glad to :)

Mypy code: https://github.com/python/mypy/blob/5039c0fe44a7592b2fcb07cead49d921ecea211f/mypy/typeanal.py#L1037
My code: https://github.com/davfsa/hikari/blob/06271cfae9919b5256916120840359275e2848b2/hikari/messages.py#L510-L557

class ButtonStyle(enums.Enum):
    PRIMARY = 1

    SECONDARY = 2

    SUCCESS = 3

    DANGER = 4

    LINK = 5

InteractiveButtonTypesT = typing.Union[
    typing.Literal[ButtonStyle.PRIMARY],
    typing.Literal[1],
    typing.Literal[ButtonStyle.SECONDARY],
    typing.Literal[2],
    typing.Literal[ButtonStyle.SUCCESS],
    typing.Literal[3],
    typing.Literal[ButtonStyle.DANGER],
    typing.Literal[4],
]

The 4 logs on top are the output of printing arg in the before mentioned mypy code

<placeholder hikari.messages.ButtonStyle>
<placeholder hikari.messages.ButtonStyle>
<placeholder hikari.messages.ButtonStyle>
<placeholder hikari.messages.ButtonStyle>
hikari/messages.py:540:5: error: Parameter 1 of Literal[...] is invalid  [misc]
        typing.Literal[ButtonStyle.PRIMARY],
        ^
hikari/messages.py:542:5: error: Parameter 1 of Literal[...] is invalid  [misc]
        typing.Literal[ButtonStyle.SECONDARY],
        ^
hikari/messages.py:544:5: error: Parameter 1 of Literal[...] is invalid  [misc]
        typing.Literal[ButtonStyle.SUCCESS],
        ^
hikari/messages.py:546:5: error: Parameter 1 of Literal[...] is invalid  [misc]
        typing.Literal[ButtonStyle.DANGER],

This differences from standard mypy, where it completes without any problems.

@davfsa
Copy link
Author

davfsa commented Jun 27, 2022

Possibly related to python/mypy#12911

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

No branches or pull requests

1 participant