From 7ca7373ba5e236f5318fc2fb9f80effe5620f303 Mon Sep 17 00:00:00 2001 From: Simon Maillard Date: Wed, 22 Nov 2023 17:05:27 +0100 Subject: [PATCH 1/2] Fix mypy error Fix error: pyinfra/api/config.py:57: error: Unsupported operand types for in ("Version" and "Requirement") Found 1 error in 1 file (checked 122 source files) --- pyinfra/api/config.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/pyinfra/api/config.py b/pyinfra/api/config.py index 004bfceb2..a6af53646 100644 --- a/pyinfra/api/config.py +++ b/pyinfra/api/config.py @@ -48,18 +48,12 @@ class ConfigDefaults: def check_pyinfra_version(version: str): if not version: return - running_version = parse_version(__version__) - required_versions = Requirement.parse( - "pyinfra{0}".format(version), - ) + required_versions = Requirement.parse("pyinfra{0}".format(version)) - if running_version not in required_versions: + if not required_versions.specifier.contains(running_version): raise PyinfraError( - ("pyinfra version requirement not met " "(requires {0}, running {1})").format( - version, - __version__, - ), + f"pyinfra version requirement not met (requires {version}, running {__version__})" ) From 89d7544a9e41649ebe55d67bfd650b2c83a40f87 Mon Sep 17 00:00:00 2001 From: Simon Maillard Date: Thu, 23 Nov 2023 11:51:36 +0100 Subject: [PATCH 2/2] Fix tests (workaround) Temporary workaround to get tests/test_connectors/test_sshuserclient.py That's seems paramiko 3 config parser dislike None value (to be confirmed) --- tests/test_connectors/test_sshuserclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_connectors/test_sshuserclient.py b/tests/test_connectors/test_sshuserclient.py index a1b827296..3c3c17450 100644 --- a/tests/test_connectors/test_sshuserclient.py +++ b/tests/test_connectors/test_sshuserclient.py @@ -21,7 +21,7 @@ SSH_CONFIG_OTHER_FILE = """ Host 192.168.1.1 User "otheruser" - ProxyCommand None + # ProxyCommand None # Commented to get test passing with Paramiko > 3 ForwardAgent yes UserKnownHostsFile ~/.ssh/test3 """