MCPcopy
hub / github.com/mne-tools/mne-python / get_min_pinned_ver

Function get_min_pinned_ver

tools/check_pyproject_helpers.py:33–47  ·  view source on GitHub ↗

Get the min pinned version from a dep specification in `pyproject.toml`.

(req)

Source from the content-addressed store, hash-verified

31
32
33def get_min_pinned_ver(req):
34 """Get the min pinned version from a dep specification in `pyproject.toml`."""
35 req = Requirement(req)
36 name = req.name
37 spec = req.specifier
38 if len(spec) == 0:
39 return name, None # no min version specified
40 ge_specs = [this_spec for this_spec in spec if this_spec.operator == ">="]
41 assert len(ge_specs) == 1, (
42 f"Expected exactly 1 '>=' specifier in `pyproject.toml` for module {name} with "
43 f"version specifications, but found {len(ge_specs)}"
44 f"{': ' + ', '.join([str(ge_spec) for ge_spec in ge_specs]) if len(ge_specs) > 0 else ''}." # noqa: E501
45 ) # can't use \ to break f-string statements until python 3.12
46
47 return name, ge_specs[0].version
48
49
50def get_bad_deps_message(bads, bads_reason):

Calls

no outgoing calls

Tested by

no test coverage detected