diff --git a/src/poetry/core/packages/utils/utils.py b/src/poetry/core/packages/utils/utils.py index 74a119e84..c5d059946 100644 --- a/src/poetry/core/packages/utils/utils.py +++ b/src/poetry/core/packages/utils/utils.py @@ -320,7 +320,7 @@ def normalize_python_version_markers( # NOSONAR version = "~" + version op = "" - elif op == "!=" and "*" not in version: + elif op == "!=" and "*" not in version and version.count(".") < 2: version += ".*" elif op in ("<=", ">"): diff --git a/tests/packages/utils/test_utils.py b/tests/packages/utils/test_utils.py index 8be34affc..0d4e3e89e 100644 --- a/tests/packages/utils/test_utils.py +++ b/tests/packages/utils/test_utils.py @@ -129,6 +129,11 @@ def test_convert_markers( ('python_version >= "3.9" or sys_platform == "linux"', "*"), # relevant python_version ('python_version >= "3.9" and sys_platform == "linux"', ">=3.9"), + # exclude specific version + ( + 'python_version >= "3.5" and python_full_version !="3.7.6"', + ">=3.5,<3.7.6 || >3.7.6", + ), ], ) def test_get_python_constraint_from_marker(marker: str, constraint: str) -> None: