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

Literals trigger hard to understand errors #115

Closed
msehnout opened this issue Aug 10, 2023 · 1 comment
Closed

Literals trigger hard to understand errors #115

msehnout opened this issue Aug 10, 2023 · 1 comment

Comments

@msehnout
Copy link

Hi,

I found 2 literals that trigger an error: in and On Hold. I saw a closed issue for "in", but I'm not sure it was fixed or just dismissed.

Anyway this is the error message:

    return parse(source_str)
           ^^^^^^^^^^^^^^^^^
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
parser error: error at 1:2: expected one of (, *, +, -, ..., AWAIT, EOF, False, NUMBER, None, True, [, break, continue, lambda, match, not, pass, ~

in
^

Could bump-pydantic produce more helpful error message, e.g. with the whole line and line number? I took me a while to understand which "in" is the problem, because running grep in produced a lot of output :)

These are the reproducers:
1.

from typing import Literal

from pydantic import BaseModel


class MySuperPhoneObject(BaseModel):

    state: Literal["Closed", "On Hold", "Speaking", "Ringing"]

from typing import Literal

from pydantic import BaseModel


class MySuperPBXQueueObject(BaseModel):

    state: Literal["in", "out"]
@Kludex
Copy link
Member

Kludex commented Sep 18, 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

No branches or pull requests

2 participants