diff --git a/grayskull/strategy/py_toml.py b/grayskull/strategy/py_toml.py index 6d1308537..a27deb6d0 100644 --- a/grayskull/strategy/py_toml.py +++ b/grayskull/strategy/py_toml.py @@ -163,8 +163,8 @@ def get_constrained_dep(dep_spec, dep_name): @get_constrained_dep.register def __get_constrained_dep_dict(dep_spec: dict, dep_name: str): - conda_version = encode_poetry_version(dep_spec["version"]) - return f"{dep_name} {conda_version}" + conda_version = encode_poetry_version(dep_spec.get("version", "")) + return f"{dep_name} {conda_version}".strip() @get_constrained_dep.register diff --git a/tests/test_poetry.py b/tests/test_poetry.py index 163945a9c..8644c3443 100644 --- a/tests/test_poetry.py +++ b/tests/test_poetry.py @@ -12,6 +12,7 @@ encode_poetry_version, get_all_toml_info, get_caret_ceiling, + get_constrained_dep, get_tilde_ceiling, parse_version, ) @@ -155,3 +156,12 @@ def test_poetry_langchain_snapshot(tmpdir): generate_recipes_from_list(args.pypi_packages, args) assert filecmp.cmp(snapshot_path, output_path, shallow=False) + + +def test_get_constrained_dep_version_not_present(): + assert ( + get_constrained_dep( + {"git": "https://codeberg.org/hjacobs/pytest-kind.git"}, "pytest-kind" + ) + == "pytest-kind" + )