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

Why Pydantic? #221

Closed
nmrtv opened this issue Dec 11, 2021 · 11 comments
Closed

Why Pydantic? #221

nmrtv opened this issue Dec 11, 2021 · 11 comments

Comments

@nmrtv
Copy link

nmrtv commented Dec 11, 2021

Is there any reason why you use Pydantic internally? Compared to attrs+cattrs it's at least 5 times slower and doesn't provide any benefits.

https://stefan.sofa-rockers.org/2020/05/29/attrs-dataclasses-pydantic/
https://threeofwands.com/why-i-use-attrs-instead-of-pydantic/

@doronbehar
Copy link

I'd also like to know why setup.cfg requires pydantic's version to be earlier then 1.9.

@VergeDX
Copy link

VergeDX commented Jan 11, 2022

@doronbehar < 1.9 version add by this PR: #148

@doronbehar
Copy link

@doronbehar < 1.9 version add by this PR: #148

That PR is missing an explanation why the version was limited to < 1.9. Current upstream version is 1.9.

@VergeDX
Copy link

VergeDX commented Jan 13, 2022

There's quote of PR's description:

pydantic seems to make breaking changes at minor releases;
however 1.8 works just fine so I've allowed 1.7.x and 1.8.x

limited to < 1.9 broke our (NixOS packages) cmake-language-server too :/

@denisrosset
Copy link

This affects packages that use pygls, such as Esbonio.

There is no way to have VS Code autocomplete (Pydantic 1.9.0) and the Esbonio language server (for documentation using Sphinx) running at the same time.

kammoh added a commit to kammoh/pygls that referenced this issue Mar 29, 2022
update other dependencies, including dev depenedencies
@pschanely
Copy link
Contributor

Sort of vaguely related, I just added pygls to CrossHair. (really thankful for this package!)

But since CrossHair needs to run in the developer's Python environment, it's most likely to work when pygls has few dependencies and has few restrictions on dependency versions. (else they'll conflict with the developer's project)

Finally, this is an esoteric use case, so I don't think my vote should matter that much!

@tombh
Copy link
Collaborator

tombh commented Jul 4, 2022

Latest master now specifies pydantic>=1.9.1,<1.10 and we'll be releasing this on Pypi soon. Could this be a fix? But more generally, what is the best practice for this situation? For example, vendoring all dependencies in the package with something like https://github.com/pradyunsg/vendoring?

@dimbleby
Copy link
Contributor

what is the best practice for this situation

imo best practice is what I did in #148: set an upper bound at the point where it is reasonable to believe that breaking changes would be likely to happen. That's the way to protect your users from unexpected breakage if and when pydantic (or whatever) does release a breaking change.

However, I acknowledge that

  • this is not universally accepted as best practice, there's a significant body of opinion that thinks that upper bounds cause more harm than good

    • ie some folk would rather risk that breakage, the implicit ask for maintainers being that they will fix such things promptly if and when they happen
    • but the thinking is that actually breaking changes are rare, users can avoid taking those changes, and so holding back the ecosystem is worse
  • specifying upper bounds places an implicit burden on maintainers to keep an eye out for new releases of dependencies and update those upper bounds as appropriate

@tombh
Copy link
Collaborator

tombh commented Oct 18, 2022

Thanks for the reply @dimbleby

So it looks like we're going to be completely removing Pydantic in the upcoming #273 release. So I'm not sure how relevant this issue is now?

But there's 2 separate themes I'm still curious about.

  1. From what you've said I get the impression that neither vendoring nor isolating dependencies (a la Nix) is a standard practice in the Python ecosystem? It may not even be standard practice in any ecosystem apart from Nix? Hence why we just have to live with trying to support overlapping versions between mutual dependencies in disparate projects.
  2. Even in a Nix-like, per-project, isolated-dependency system, dependency version definition semantics such as the chevron, ^0.18.0, are also critical. But I think this is already a solved problem in Python with lock files? Which Pygls doesn't currently use.

No need to answer these unless anything obvious comes up. Just wondering out loud about the general expectations in the Python ecosystem.

Either way, the fact that Pydantic seems to make breaking changes on minor version bumps would be a faux pas in any ecosystem.

@dimbleby
Copy link
Contributor

pydantic is just an example of the general question: this project has other dependencies and will continue to have to decide whether or not to put upper bounds on those dependencies. There are pros and cons, which I tried to set out fairly above.

vendoring is typically an exceptional-circumstances-only choice in the python world.

@tombh
Copy link
Collaborator

tombh commented Dec 3, 2022

Pygls has now migrated to lsprotocol, so no longer depends on Pydantic. lsprotocol itseslf uses https://github.com/python-attrs/cattrs

@tombh tombh closed this as completed Dec 3, 2022
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

Successfully merging a pull request may close this issue.

7 participants