Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#214 1 comentario 0 reacciones 0 asignados Ver en GitHub

@akashrajeev ya está trabajando en esto.

Desde el 17/10/2026.

  • #215 de @akashrajeev — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
tooling

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

univers-reproduction.zip

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de aboutcode-org/univers

Todos los issues de aboutcode-org/univers

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.