Repository: conda-incubator/grayskull
Pull request #400 (2022-10-11 05:23:17)

Fix dropping upper bound constrain for requires python

codecov-commenter: # [Codecov](https://codecov.io/gh/conda-incubator/grayskull/pull/400?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator) Report
> Merging [#400](https://codecov.io/gh/conda-incubator/grayskull/pull/400?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator) (91b2be7) into [main](https://codecov.io/gh/conda-incubator/grayskull/commit/9c3242e1667135f34875a6d9e44d53b83ab3d9ba?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator) (9c3242e) will **increase** coverage by `0.75%`.
> The diff coverage is `92.90%`.

```diff
@@            Coverage Diff             @@
##             main     #400      +/-   ##
==========================================
+ Coverage   91.30%   92.06%   +0.75%     
==========================================
  Files          17       16       -1     
  Lines        1576     1701     +125     
==========================================
+ Hits         1439     1566     +127     
+ Misses        137      135       -2     
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `92.06% <92.90%> (+0.75%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/conda-incubator/grayskull/pull/400?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator) | Coverage Δ | |
|---|---|---|
| [setup.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-c2V0dXAucHk=) | `0.00% <0.00%> (ø)` | |
| [grayskull/base/github.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL2Jhc2UvZ2l0aHViLnB5) | `72.83% <72.83%> (ø)` | |
| [grayskull/license/discovery.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL2xpY2Vuc2UvZGlzY292ZXJ5LnB5) | `94.81% <78.12%> (-2.33%)` | :arrow_down: |
| [grayskull/strategy/abstract\_strategy.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL3N0cmF0ZWd5L2Fic3RyYWN0X3N0cmF0ZWd5LnB5) | `83.33% <83.33%> (ø)` | |
| [grayskull/\_\_main\_\_.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL19fbWFpbl9fLnB5) | `95.60% <93.18%> (-2.55%)` | :arrow_down: |
| [grayskull/base/factory.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL2Jhc2UvZmFjdG9yeS5weQ==) | `91.17% <93.33%> (+1.17%)` | :arrow_up: |
| [grayskull/strategy/py\_base.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL3N0cmF0ZWd5L3B5X2Jhc2UucHk=) | `95.00% <95.00%> (ø)` | |
| [grayskull/utils.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL3V0aWxzLnB5) | `98.12% <97.58%> (-1.88%)` | :arrow_down: |
| [grayskull/strategy/pypi.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL3N0cmF0ZWd5L3B5cGkucHk=) | `97.68% <97.68%> (ø)` | |
| [grayskull/config.py](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator#diff-Z3JheXNrdWxsL2NvbmZpZy5weQ==) | `98.48% <98.48%> (ø)` | |
| ... and [7 more](https://codecov.io/gh/conda-incubator/grayskull/pull/400/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator) | |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=conda-incubator)


Patch:
diff --git a/grayskull/config.py b/grayskull/config.py
index 0c35764..1d80625 100644
--- a/grayskull/config.py
+++ b/grayskull/config.py
@@ -18,6 +18,7 @@ class Configuration:
             PyVer(3, 8),
             PyVer(3, 9),
             PyVer(3, 10),
+            PyVer(3, 11),
         ]
     )
     py_cf_supported: List[PyVer] = field(
@@ -27,6 +28,7 @@ class Configuration:
             PyVer(3, 8),
             PyVer(3, 9),
             PyVer(3, 10),
+            PyVer(3, 11),
         ]
     )
     is_strict_cf: bool = False
diff --git a/grayskull/strategy/py_base.py b/grayskull/strategy/py_base.py
index 33fd6dc..762da74 100644
--- a/grayskull/strategy/py_base.py
+++ b/grayskull/strategy/py_base.py
@@ -143,11 +143,12 @@ def get_name_version_from_requires_dist(string_parse: str) -> Tuple[str, str]:
 
 
 def generic_py_ver_to(
-    metadata: dict, config, is_selector: bool = False
+    metadata: dict, config: Configuration, is_selector: bool = False
 ) -> Optional[str]:  # sourcery no-metrics
     """Generic function which abstract the parse of the requires_python
     present in the PyPi metadata. Basically it can generate the selectors
     for Python or the constrained version if it is a `noarch: python` python package"""
+    # TODO: Refactor the entire function to use LooseVersion instead of custom PyVer
     if not metadata.get("requires_python"):
         return None
     req_python = re.findall(
@@ -158,7 +159,9 @@ def generic_py_ver_to(
         return None
 
     py_ver_enabled = config.get_py_version_available(req_python)
-    small_py3_version = config.get_oldest_py3_version(list(py_ver_enabled.keys()))
+    small_py3_version = config.get_oldest_py3_version(
+        [k for k, v in py_ver_enabled.items() if v]
+    )
     all_py = list(py_ver_enabled.values())
     if all(all_py):
         return None


Test patch:
diff --git a/tests/test_py_base.py b/tests/test_py_base.py
index 57baf36..d8a7e4e 100644
--- a/tests/test_py_base.py
+++ b/tests/test_py_base.py
@@ -1,7 +1,9 @@
 from grayskull.__main__ import create_python_recipe
+from grayskull.config import Configuration
 from grayskull.strategy.py_base import (
     clean_deps_for_conda_forge,
     ensure_pep440,
+    generic_py_ver_to,
     update_requirements_with_pin,
 )
 from grayskull.utils import PyVer
@@ -42,3 +44,11 @@ def test_clean_deps_for_conda_forge_remove_py_selector():
     assert clean_deps_for_conda_forge(
         ["dulwich >=0.19.3  # [py>=35]"], PyVer(3, 6)
     ) == ["dulwich >=0.19.3"]
+
+
+def test_python_requires_upper_bound():
+    py_ver = generic_py_ver_to(
+        {"requires_python": ">=3.7,<=3.10"},
+        Configuration(name="algviz", is_strict_cf=False),
+    )
+    assert py_ver == ">=3.7,<3.11"