Repository: conda/grayskull (language: python)

Issue:
[BUG] KeyError: 'version' for library that uses poetry
**Describe the bug**
I'm getting a `KeyError: 'version' ` error when trying to run `grayskull pypi kr8s`.

It's very likely that I've done something wrong when packaging `kr8s` for PyPI, this is my first time using Poetry for publishing to PyPI. However the error I'm seeing in `grayskull` isn't very helpful.

**To Reproduce**

```console
$ conda install -c conda-forge grayskull
$ grayskull pypi kr8s
```

```pytb
#### Initializing recipe for kr8s (pypi) ####

Recovering metadata from pypi...
Starting the download of the sdist package kr8s
kr8s 100% Time:  0:00:00   9.2 MiB/s|#######################################################################################################################################################################################################|
Checking for pyproject.toml
pyproject.toml found in /tmp/grayskull-kr8s-iyvebryq/kr8s-0.4.0/pyproject.toml
Traceback (most recent call last):
  File "/home/jacob/miniconda3/envs/kr8s/bin/grayskull", line 10, in <module>
    sys.exit(main())
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/__main__.py", line 276, in main
    generate_recipes_from_list(args.pypi_packages, args)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/__main__.py", line 299, in generate_recipes_from_list
    recipe, config = create_python_recipe(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/__main__.py", line 334, in create_python_recipe
    GrayskullFactory.create_recipe(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/base/factory.py", line 46, in create_recipe
    GrayskullFactory.REGISTERED_STRATEGY[repo_type.lower()].fetch_data(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 60, in fetch_data
    update_recipe(recipe, config, sections or ALL_SECTIONS)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 485, in update_recipe
    metadata = get_metadata(recipe, config)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 347, in get_metadata
    sdist_metadata, pypi_metadata = get_origin_wise_metadata(config)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 232, in get_origin_wise_metadata
    sdist_metadata = get_sdist_metadata(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_base.py", line 771, in get_sdist_metadata
    pyproject_metadata = get_all_toml_info(pyproject_toml)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 263, in get_all_toml_info
    add_poetry_metadata(metadata, toml_metadata)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 215, in add_poetry_metadata
    test_reqs, _ = encode_poetry_deps(poetry_test_deps)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 180, in encode_poetry_deps
    constrained_dep = get_constrained_dep(dep_spec, dep_name)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 166, in __get_constrained_dep_dict
    conda_version = encode_poetry_version(dep_spec["version"])
KeyError: 'version'
```

**Expected behavior**
It generates the recipe.

**Environment:**
 - grayskull 2.3.0



Discussion / hints:
I will put this on my todo, It seems it needs a couple adjustments for poetry
Thanks for reporting it!

Fix patch:
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


Test patch:
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"
+    )