Repository: scikit-learn/scikit-learn
File: sklearn/tests/test_min_dependencies_readme.py (Python)

Code before:
import pytest

import sklearn
from sklearn._min_dependencies import dependent_packages
from sklearn.utils.fixes import parse_version

# minimal dependencies and pyproject definitions for testing the pyproject tests

EXAMPLE_MIN_DEPENDENT_PACKAGES = {
    "joblib": ("1.3.0", "install"),
    "scipy": ("1.10.0", "build, install"),
}

EXAMPLE_MATCHING_PYPROJECT_SECTIONS = """
[project]
dependencies = ["joblib>=1.3.0", "scipy==1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["joblib>=1.3.0", "scipy==1.10.0"]
[build-system]
requires = ["scipy>=1.10.0"]
"""

EXAMPLE_MATCHING_PYPROJECT_SECTIONS_WITH_UPPER_BOUND = """
[project]
dependencies = ["joblib>=1.3.0,<2.0", "scipy==1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0,<1.19.0"]
install = ["joblib>=1.3.0,<2.0", "scipy==1.10.0"]
[build-system]
requires = ["scipy>=1.10.0,<1.19.0"]
"""

EXAMPLE_WRONG_SYMBOL_PYPROJECT_SECTIONS = """
[project]
dependencies = ["scipy<1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["scipy>=1.10.0"]
[build-system]
requires = ["scipy>=1.10.0"]
"""

EXAMPLE_MISSING_PACKAGE_PYPROJECT_SECTIONS = """
[project]
dependencies = ["scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["scipy>=1.10.0"]
[build-system]
requires = ["scipy>=1.10.0"]

Review comment (suggestion):
I think it doesn't make too much sense to have `scipy==1.10.0` in some sections and `scipy>=1.10.0` in others.

I am trying to think hard to find a use case for mixing `>=` and `==` but I can not find one.

I think the only use case for `==` is for `conda-lock`. Here is what I would recommend as good/realistic enough:
- use scipy>=1.10.0 in all the `EXAMPLE_` variables
- add conda-lock==3.0.1 in all the `EXAMPLE_` variables

In an ideal world you would also check that `>=` and `==` is used consistently in all the sections for a given package. Right now I think this is not worth spending too much time on this. 



Code after:
import pytest

import sklearn
from sklearn._min_dependencies import dependent_packages
from sklearn.utils.fixes import parse_version

# minimal dependencies and pyproject definitions for testing the pyproject tests

TOY_MIN_DEPENDENCIES_PY_INFO = {
    "joblib": ("1.3.0", "install"),
    "scipy": ("1.10.0", "build, install"),
    "conda-lock": ("3.0.1", "maintenance"),
}

TOY_MATCHING_PYPROJECT_SECTIONS = """
[project]
dependencies = ["joblib>=1.3.0", "scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["joblib>=1.3.0", "scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0"]
"""

TOY_MATCHING_PYPROJECT_SECTIONS_WITH_UPPER_BOUND = """
[project]
dependencies = ["joblib>=1.3.0,<2.0", "scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0,<1.19.0"]
install = ["joblib>=1.3.0,<2.0", "scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0,<1.19.0"]
"""

TOY_WRONG_SYMBOL_PYPROJECT_SECTIONS = """
[project]
dependencies = ["scipy<1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0"]
"""

TOY_MISSING_PACKAGE_PYPROJECT_SECTIONS = """
[project]
dependencies = ["scipy>=1.10.0"]
[project.optional-dependencies]