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

v2.7 validation error when integer starts with + #9259

Closed
1 task done
cknv opened this issue Apr 16, 2024 · 3 comments · Fixed by pydantic/pydantic-core#1272
Closed
1 task done

v2.7 validation error when integer starts with + #9259

cknv opened this issue Apr 16, 2024 · 3 comments · Fixed by pydantic/pydantic-core#1272
Labels
bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation
Milestone

Comments

@cknv
Copy link

cknv commented Apr 16, 2024

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

Parsing integers starting with unary plus (such as +1) fails to parse to an int using pydantic v2.7.0 - found it from a test that broke when trying to upgrade dependencies.
Unary minus, such as -1 works as expected.

Seems related to some int parsing changes mentioned in #9227

Example Code

from pydantic import BaseModel

class Message(BaseModel):
    recipient: int

Message(recipient="+1")

Python, Pydantic & OS Version

pydantic version: 2.7.0
        pydantic-core version: 2.18.1
          pydantic-core build: profile=release pgo=true
                 install path: /home/..../.venv/lib/python3.11/site-packages/pydantic
               python version: 3.11.8 (main, Feb 12 2024, 14:50:05) [GCC 13.2.1 20230801]
                     platform: Linux-6.8.5-arch1-1-x86_64-with-glibc2.39
             related packages: typing_extensions-4.11.0 fastapi-0.110.1 mypy-1.9.0
                       commit: unknown
@cknv cknv added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels Apr 16, 2024
@sydney-runkle
Copy link
Member

@cknv,

Thanks for the report. Looks like it should be an easy fix in pydantic-core, I'll work on that for our patch release!

@cknv
Copy link
Author

cknv commented Apr 18, 2024

Since it seemed easy @sydney-runkle I gave it a shot in pydantic/pydantic-core#1272.

@sydney-runkle
Copy link
Member

@cknv,

Amazing, great work. @davidhewitt left a small comment / suggestion - once you resolve that, we can merge :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants