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

Clarify documentation of strip_whitespace #9438

Closed
1 task done
johncarter-phntm opened this issue May 15, 2024 · 2 comments · Fixed by #9471
Closed
1 task done

Clarify documentation of strip_whitespace #9438

johncarter-phntm opened this issue May 15, 2024 · 2 comments · Fixed by #9471

Comments

@johncarter-phntm
Copy link

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

The doc for StringConstraints strip_whitespace says "Whether to strip whitespace from the string." - to me that's unclear if it's stripping all whitespace or only leading/trailing (it's the latter I think).

I think it'd be clearer if it said "Whether to remove leading and trailing whitespace." which I think is the actual behaviour, and aligns with the doc for constr - https://docs.pydantic.dev/latest/api/types/#pydantic.types.constr

https://docs.pydantic.dev/latest/api/types/#pydantic.types.StringConstraints

Maybe this unit test should be updated to include a space inside of ABC to assert on that behaviour? 8bc104f#diff-bd467a363c9f155a2e6a7716aeca0c351089135a53d09a66138cea4f16506ebdR5574

Example Code

No response

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/johnc/.cache/pypoetry/virtualenvs/gweb-play-points-perks-apac-DXkUH1xo-py3.11/lib/python3.11/site-packages/pydantic
               python version: 3.11.4 (main, Feb 21 2024, 14:32:06) [GCC 11.4.0]
                     platform: Linux-6.5.0-28-generic-x86_64-with-glibc2.35
             related packages: typing_extensions-4.11.0
                       commit: unknown
@johncarter-phntm johncarter-phntm added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels May 15, 2024
@sydney-runkle
Copy link
Member

@johncarter-phntm,

Feel free to open a PR with these changes - that sounds great!

@sydney-runkle sydney-runkle added documentation and removed bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels May 16, 2024
@micheleAlberto
Copy link
Contributor

@sydney-runkle I'll be happy to take this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants