KEMBAR78
v2.7 validation error when integer starts with `+` · Issue #9259 · pydantic/pydantic · GitHub
Skip to content

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

@cknv

Description

@cknv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V2Bug related to Pydantic V2pendingIs unconfirmed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions