VersionRange.invert() returns a complement that excludes versions outside an enumerated range
評価
調査の方向性
VersionRange.invert() から開始し、repro.py を使って列挙範囲の動作を確認しながら、レポートに記載された containment path をたどってください。1.0.0、1.5.0、2.0.0 を対象とする回帰テストを追加し、その後、関連するテストスイートを実行して、各バージョンが範囲またはその補集合のいずれか一方にだけ属することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Summary
For vers:pypi/1.0.0|2.0.0, version 1.5.0 is outside both the original range and the result of invert(). This violates the documented inverse/complement purpose of the method and can leave versions unclassified when a caller partitions them using a range and its complement.
Reproduction
Save the following as repro.py.
from univers.version_range import VersionRange
from univers.versions import PypiVersion
r = VersionRange.from_string("vers:pypi/1.0.0|2.0.0")
inverse = r.invert()
print("range:", r)
print("inverse:", inverse)
for text in ("1.0.0", "1.5.0", "2.0.0"):
v = PypiVersion(text)
print(text, "in range:", v in r, "in inverse:", v in inverse)
Run:
python -m pip install univers==32.0.1
python repro.py
Actual result
range: vers:pypi/1.0.0|2.0.0
inverse: vers:pypi/!=1.0.0|!=2.0.0
1.0.0 in range: True in inverse: False
1.5.0 in range: False in inverse: False
2.0.0 in range: True in inverse: False
Expected result and contract
For each version, membership in a range and its complement should be opposite. In particular, 1.5.0 should be in the inverse because it is not in the original enumerated range; the two enumerated versions should remain outside the inverse.
The API's complement purpose is described in issue #91 and the implementing PR #92:
https://github.com/aboutcode-org/univers/issues/91
https://github.com/aboutcode-org/univers/pull/92
Code-level observation
invert() produces an all-!= constraint list. In the containment path, after testing the explicitly excluded versions, the =/!= constraints are filtered out and the empty remainder returns false. As a result, a version that matches none of the exclusions is still rejected. The report concerns the semantics of the returned complement, irrespective of how the constraint list's connective is represented internally.
I also reviewed the related containment issue #137; I could not establish that it covers this enumerated-inverse case:
https://github.com/aboutcode-org/univers/issues/137
Environment
- Package: univers 32.0.1
- Runtime: CPython 3.13.3
- OS: macOS 26.6.2, Apple Silicon / arm64
- Reproduced: 2026-09-11
- 主要言語
- Python
- スター
- 50
- フォーク
- 31
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aboutcode-org/univers のほかの issue
-
Do not allow creation of `VersionRange` with empty constraint対応中かも @MGpromax が 66 日前に担当しました。 オープンbug High-Priority
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
aboutcode-org/univers#203 ·
-
maven.py: "release" qualifier not treated as release alias対応中かも @selsky が 72 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
aboutcode-org/univers#188 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 15/100
aboutcode-org/univers#206 · コメント 3 件 · リアクション 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 18/100
aboutcode-org/univers#205 ·
-
Empty string accepted as a valid version in Maven/NuGet/RubyGems, and sorts as minimum対応中かも @MGpromax が 66 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
aboutcode-org/univers#204 ·
aboutcode-org/univers の issue をすべて見る
似ている issue
-
[oblt-aw][autodoc] Document new required `shared-org-key` input for `obs-aw-dependency-review`対応中かも @github-actions が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
getchaintips leaves out the active tip once a header is staged on it, where Core always lists itオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
btclib-org/btclib-node#2158 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
dbt-msft/dbt-sqlserver#897 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Gathin23/cleanyourtv#2770 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Dao-AILab/flash-attention#3097 ·
メンテナーはふだん 3 日以内に返信