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

pydantic-extra package? #5012

Closed
samuelcolvin opened this issue Feb 6, 2023 · 14 comments
Closed

pydantic-extra package? #5012

samuelcolvin opened this issue Feb 6, 2023 · 14 comments
Assignees
Labels
Feedback Wanted help wanted Pull Request welcome

Comments

@samuelcolvin
Copy link
Member

samuelcolvin commented Feb 6, 2023

For types which shouldn't be included with pydantic but which people understandably want to reuse.

See #5011 - I don't think we should not add a one time password type to pydantic. The surface -area/problem-space of pydantic is already too large. I also strongly want to avoid more dependencies, even if they're optional.

However I would advocate for creating a package, perhaps pydantic-extra which includes:

PaymentCardNumber and Color will need to remain in pydantic (potentially with a dep warning) for now.

Before anyone asks, no, I do not want to move email types to pydantic-extra - they're used too much, also I want to move the implementation into rust pydantic/pydantic-core#385.

I'd be happy to:

  • host this in the pydantic GitHub org
  • include the docs in docs.pydantic.dev (this is the plan for pydantic-core and pydantic-settings already)
  • release it using my pypi account
  • add more maintainers than pydantic has
  • be more liberal about dependencies

The other advantage would be that we could make new releases of pydantic-extra more easily as they couldn't break any other bits of pydantic.

@pydantic/pydantic-maintainers WDYT?

If we decide to go ahead with this, @yezz123 would you be willing to be a maintainer of this???

@samuelcolvin samuelcolvin pinned this issue Feb 6, 2023
@samuelcolvin samuelcolvin changed the title pydantic-extra package pydantic-extra package? Feb 6, 2023
@yezz123
Copy link
Contributor

yezz123 commented Feb 6, 2023

This looks impressive, as I worked before on several types regarding Pydantic in my work, I would be happy to elaborate on this and maintain Pydantic extra, it's going to be more helpful and contain several utilities that may open-source developers propose in discussions or issues.

  • Same as the OTP Idea, you propose phone numbers, payment cards(already), integration such as colors, and money types or in general default currencies.
  • My sense, here is we can create this as an integration that will be helpful in the future.

I would be happy if I maintain this! we can do it in Pydantic org while it will be an extra addon on the top of the package itself.

@samuelcolvin
Copy link
Member Author

This seems to have started without waiting for more feedback, sorry, but still very open to any feedback.

In terms of timeline, I guess if we can get this ready to be released with V2, we can mark Color and PaymentCardNumber deprecated in V2.

@yezz123
Copy link
Contributor

yezz123 commented Feb 6, 2023

This seems to have started without waiting for more feedback, sorry, but still very open to any feedback.

In terms of timeline, I guess if we can get this ready to be released with V2, we can mark Color and PaymentCardNumber deprecated in V2.

Amazing 🚀

@hramezani
Copy link
Member

Good idea. Yeah that make sense.
I would suggest to name it pydantic-extra-types because pydantic-extra is too generic. We may have some other packages in future around Pydantic like packages in Django ecosystem

@lewoudar
Copy link

lewoudar commented Feb 6, 2023

Hi everyone, I also think it is a good idea and I agreed with @hramezani for the naming, something like pydantic-types or pydantic-extra-types seems more correct in my humble opinion.

@samuelcolvin
Copy link
Member Author

I agree with @hramezani, I'll rename the repo, upload a new stub package and delete the old one.

Bring on namespaces in pypi and all this holding names would die away!

@tomy0000000
Copy link

Sound like a great idea. My project could make use of these handful types heavily.
I saw @samuelcolvin left a helps-wanted tag. Please write down which part needs help so that I might contribute to the projects.

@samuelcolvin
Copy link
Member Author

Thanks @tomy0000000, hopefully @yezz123 can do some of the initial work setting up the repo - copying Color and PaymentCardNumber and their tests, setting up CI etc.

Once that's done, we can migrate the above bullet point to issues on the repo and start creating PRs.

pydantic-extra-types will never be released for V1, only with compatibility for V2, so types need to use the new protocol for custom types, which is mostly formalised but needs to be documented.

@tomy0000000
Copy link

Once that's done, we can migrate the above bullet point to issues on the repo and start creating PRs.

Great, I'll stayed tuned

@ghandic
Copy link

ghandic commented Feb 28, 2023

Is there a possibility of this hooking into rust too? Or would it need to be compiled together with pydantic then?

@samuelcolvin
Copy link
Member Author

This (or any code) can use the rust core-schema types, as is already done here.

That's the same thing pydantic itself does.

@ghandic
Copy link

ghandic commented Feb 28, 2023

So it be possible to write the color validation/parsing in rust within pydantic-extra? Perhaps something we could showcase for others trying to expand on the plugins

@samuelcolvin
Copy link
Member Author

No, not writing rust, that would require the entire build process we have for pydantic-core, I mean we can use validators written in rust.

I very much doubt there's going to be the need to write validators in rust here or anywhere else.

@Kludex
Copy link
Member

Kludex commented Aug 25, 2023

Since we've created https://github.com/pydantic/pydantic-extra-types, I'll be closing this issue. FYI @samuelcolvin

@Kludex Kludex closed this as completed Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feedback Wanted help wanted Pull Request welcome
Projects
None yet
Development

No branches or pull requests

8 participants