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

Unable to Import PhoneNumberValidator on Python v3.8 - v3.10 & v3.12 #214

Open
hassamsolanomorel opened this issue Sep 11, 2024 · 1 comment

Comments

@hassamsolanomorel
Copy link

Hey team! I've got kinda of a strange one for you.

When trying to use PhoneNumberValidator, as show in the Pydantic documentation example, I keep running into ImportError: cannot import name 'PhoneNumberValidator' from 'pydantic_extra_types.phone_numbers'.

Whats even stranger is I have no such issue importing pydantic_extra_types.phone_numbers.PhoneNumber. I've tried the import statement on several python versions, which I've listed below, and was only able to properly import on version 3.11.3.

My ultimate goal is to replicate NANumber as you have it in your tests almost exactly.

Hoping it's something I'm missing, but wanted to bring this to your attention.

Tested Versions

Python: 3.8.16, 3.9.19, 3.10.15, 3.11.3 (works on this version), 3.12.6
Pydantic: 2.9.1
phonenumbers: 8.13.45

@imperosol
Copy link

I ran into the same problem (though I didn't tested on Python 3.11 to see if that resolves the issue).
What I found is that PhoneNumberValidator didn't exist at all in the code that was in virtual environment.

So I searched in the real code, on the repo. PhoneNumberValidator does actually exist, but it has been added on August 18th, whereas the last release to PyPI was on July 3rd. The class is documented, but isn't released yet.

I fixed the problem, with poetry, by replacing pydantic-extra-types = "2.9.0" with pydantic-extra-types = { git = "https://github.com/pydantic/pydantic-extra-types.git", rev = "58db4b0" }. I will keep it this way until the release is done.

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