Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

VersionRange.invert() returns a complement that excludes versions outside an enumerated range

オープン
#214 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@akashrajeev がすでに取り組んでいます。

2026年10月17日 から。

  • #215 @akashrajeev による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
tooling

調査の方向性

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

univers-reproduction.zip

主要言語
Python
スター
50
フォーク
31
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aboutcode-org/univers のほかの issue

aboutcode-org/univers の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。