VersionRange.invert() returns a complement that excludes versions outside an enumerated range
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
Línea de trabajo
Comienza en VersionRange.invert() y sigue la ruta de contención descrita en el informe, usando repro.py para confirmar el comportamiento del rango enumerado. Añade una prueba de regresión que cubra 1.0.0, 1.5.0 y 2.0.0; después, ejecuta la suite de pruebas relevante y verifica que cada versión pertenezca exactamente a uno de los rangos o a su complemento.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 50
- Forks
- 31
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aboutcode-org/univers
-
Do not allow creation of `VersionRange` with empty constraintPosiblemente ocupada @MGpromax la tomó hace 67 días. Abiertobug High-Priority
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
aboutcode-org/univers#203 ·
-
maven.py: "release" qualifier not treated as release aliasPosiblemente ocupada @selsky la tomó hace 72 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
aboutcode-org/univers#188 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 15/100
aboutcode-org/univers#206 · 3 comentarios · 2 reacciones ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 18/100
aboutcode-org/univers#205 ·
-
Empty string accepted as a valid version in Maven/NuGet/RubyGems, and sorts as minimumPosiblemente ocupada @MGpromax la tomó hace 67 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
aboutcode-org/univers#204 ·
Todos los issues de aboutcode-org/univers
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Claiming namespace `thejakia1`Abiertonamespace operations
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
EclipseFdn/open-vsx.org#15057 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
FinanceFlash/unvibecode#349 ·
-
Mission statement: why this is free, in the README, Why This Exists and the wiki HomePosiblemente ocupada @ChiefGyk3D la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ChiefGyk3D/Clouds-Against-Humanity#348 ·
Los mantenedores suelen responder en 1 día
-
[Perf] Default --vllm-watermark 0.05 for rollouts (hybrid models re-preempt under KV pressure)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
vllm-project/vime#508 ·
Los mantenedores suelen responder en 4 días