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

Poetry & PEP440 Disagree on an example in the PEP. #7050

Closed
4 tasks done
r-richmond opened this issue Nov 16, 2022 · 4 comments · Fixed by python-poetry/poetry-core#402
Closed
4 tasks done

Poetry & PEP440 Disagree on an example in the PEP. #7050

r-richmond opened this issue Nov 16, 2022 · 4 comments · Fixed by python-poetry/poetry-core#402
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@r-richmond
Copy link

r-richmond commented Nov 16, 2022

  • Poetry version: 1.2.2
  • Python version: 3.10.8
  • OS version and name: macOS 13.0.1
  • pyproject.toml: N/A
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

Discovered during the conversation in #7047.

Poetry does not return the same results as one of the examples in PEP 440.

#!/usr/bin/env python3

from poetry.core.constraints.version.version import Version
from poetry.core.constraints.version import parse_constraint

constraint = parse_constraint("==1.1.*")
version = Version.parse("1.1a1")
allowed = constraint.allows(version)
print(f"{allowed=}")

prints allowed=False which does not match the example here

cc: @dimbleby

@r-richmond r-richmond added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 16, 2022
@dimbleby
Copy link
Contributor

Currently ==1.1.* is parsed as >=1.1.0,<1.2

A possible approach for a fix would be to instead recognise this as >=1.1.0.dev0,<1.2.

@radoering
Copy link
Member

A possible approach for a fix would be to instead recognise this as >=1.1.0.dev0,<1.2.

Please be aware that this is probably not sufficient and will result in other issues. cf python-poetry/poetry-core#402 (review)

IMO we have to change our "implicitly allow pre-releases" logic because our "allow pre-releases" is more like "do not prefer stable releases".

@dimbleby
Copy link
Contributor

probably "allow-prereleases" on individual dependencies was a mistake.

  • It doesn't help at all to describe the desired behaviour for transitive dependencies
  • People quite often seem to be confused by it, expecting eg that { version = ">=1.3.0", allow-prereleases = true } should allow 1.3.0 pre-releases.
    • That's not poetry's behaviour (and my reading of PEP440 is that poetry is correct)

The default behaviour at https://peps.python.org/pep-0440/#handling-of-pre-releases requires no special flag and should be quite satisfactory.

Poetry currently fails to satisfy the "tools ... SHOULD" section which is about explicitly allowing or disallowing pre-releases for all distributions (eg including transitive dependencies)

Poetry is doing a half-assed job of the "tools ... MAY" section about doing the same on a per-distribution basis. (Because this is not configurable for transitive dependencies.)

Obvs removing this flag would require some consensus and deprecation period, but simplification is a noble goal...

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants