Get the min pinned version from a dep specification in `pyproject.toml`.
(req)
| 31 | |
| 32 | |
| 33 | def 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 | |
| 50 | def get_bad_deps_message(bads, bads_reason): |
no outgoing calls
no test coverage detected