pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.78k stars 1.86k forks source link

Default to the `~=` opperator when adding entries to pipfile #6123

Open Kroppeb opened 4 months ago

Kroppeb commented 4 months ago

This might be quite opinionated, but tools like npm have similar behavior. Npm will check the latest version available (eg x.y.z) and will specify the version as ^x.y.z.

One important difference though is that ^x.y.z, is equivalent (in python) to == x.*, >= x.y.z (for non-zero x), while ~= x.y.z is equivalent to == x.y.*, >= x.y.z.

So either we

  1. Add our own non-official ^= operator that gets automatically translated (not a big fan),
  2. Use == x.*, >= x.y.z (assuming x is non-zero)
  3. Use ~= x.y (assuming x is non-zero)
  4. Use ~= x.y.z (assuming x is non-zero) not ideal because it doesn't allow minor increases

Additionally, it would be preferable if pipenv update would then also increase these specifiers.

matteius commented 4 months ago

I wouldn't want this to be the global default, but would support a Pipfile setting that triggered this behavior. I think there is some overlap with this and the issue report behind https://github.com/pypa/pipenv/pull/5963

Kroppeb commented 4 months ago

Ah oops, seems I've missed issue #5531. My bad.

Kroppeb commented 4 months ago

When you say a "pipfile setting" do you mean a command flag/environment flag, or do you mean a value in the pipfile?

Kroppeb commented 4 months ago

The reason I suggested to change the default btw, was to avoid issues like #6104.