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

Code before:

    if skip_version_check_for is None:
        skip_version_check_for = []

    expected_packages = min_depencies_tag_to_packages_without_version[
        min_dependencies_tag
    ]

    root_directory = Path(sklearn.__file__).parent.parent
    pyproject_toml_path = root_directory / "pyproject.toml"

    if not pyproject_toml_path.exists():
        # Skip the test if the pyproject.toml file is not available.
        # For instance, when installing scikit-learn from wheels
        pytest.skip("pyproject.toml is not available.")

    with pyproject_toml_path.open("rb") as f:
        pyproject_toml = tomllib.load(f)

    pyproject_section_keys = pyproject_section.split(".")
    info = pyproject_toml
    for key in pyproject_section_keys:
        info = info[key]

    pyproject_build_min_versions = {}
    # Assuming pyproject.toml build section has something like my-package>=<min_version>
    # Warning: if you try to modify this regex, bear in mind that there can be upper
    # bounds in release branches so my-package>=<min_version>,<max_version>
    pattern = r"([\w-]+)\s*[>=]=\s*([\d\w.]+)"
    for requirement in info:
        match = re.search(pattern, requirement)
        if match is None:
            raise NotImplementedError(
                f"{requirement} does not match expected regex {pattern!r}. "
                "Only >= and == are supported for version requirements"
            )

        package, version = match.group(1), match.group(2)

        pyproject_build_min_versions[package] = version

    assert sorted(pyproject_build_min_versions) == sorted(expected_packages)

    for package, version in pyproject_build_min_versions.items():
        version = parse_version(version)
        expected_min_version = parse_version(dependent_packages[package][0])
        if package in skip_version_check_for:
            continue

        message = (
            f"{package} has inconsistent minimum versions in pyproject.toml and"

Review comment (suggestion):
```suggestion
    # Assuming pyproject.toml build section has something like "my-package>=<min_version>"
```
optional nit. The ">=<" is a little hard to read at first, and I was hoping the quotes would help.

Code after:

    if skip_version_check_for is None:
        skip_version_check_for = []

    expected_packages = min_depencies_tag_to_packages_without_version[
        min_dependencies_tag
    ]

    root_directory = Path(sklearn.__file__).parent.parent
    pyproject_toml_path = root_directory / "pyproject.toml"

    if not pyproject_toml_path.exists():
        # Skip the test if the pyproject.toml file is not available.
        # For instance, when installing scikit-learn from wheels
        pytest.skip("pyproject.toml is not available.")

    with pyproject_toml_path.open("rb") as f:
        pyproject_toml = tomllib.load(f)

    pyproject_section_keys = pyproject_section.split(".")
    info = pyproject_toml
    for key in pyproject_section_keys:
        info = info[key]

    pyproject_build_min_versions = {}
    # Assuming pyproject.toml build section has something like "my-package>=2.3.0"
    # Warning: if you try to modify this regex, bear in mind that there can be upper
    # bounds in release branches so "my-package>=2.3.0,<2.5.0"
    pattern = r"([\w-]+)\s*[>=]=\s*([\d\w.]+)"
    for requirement in info:
        match = re.search(pattern, requirement)
        if match is None:
            raise NotImplementedError(
                f"{requirement} does not match expected regex {pattern!r}. "
                "Only >= and == are supported for version requirements"
            )

        package, version = match.group(1), match.group(2)

        pyproject_build_min_versions[package] = version

    assert sorted(pyproject_build_min_versions) == sorted(expected_packages)

    for package, version in pyproject_build_min_versions.items():
        version = parse_version(version)
        expected_min_version = parse_version(dependent_packages[package][0])
        if package in skip_version_check_for:
            continue

        message = (
            f"{package} has inconsistent minimum versions in pyproject.toml and"