From 13f63e9648e6116d17ce11e1c085ff312d2bd1de Mon Sep 17 00:00:00 2001 From: Anton Tayanovskyy Date: Wed, 21 Apr 2021 15:48:57 -0400 Subject: [PATCH] Fix bug in semver usage by enabling typechecking (#6833) * Fix bug in semver usage by enabling typechecking * Add CHANGELOG note --- CHANGELOG_PENDING.md | 5 ++++- sdk/python/lib/pulumi/runtime/rpc.py | 4 ++-- sdk/python/mypy.ini | 3 --- sdk/python/stubs/semver/__init__.pyi | 11 +++++++++++ 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 sdk/python/stubs/semver/__init__.pyi diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index afce69151..e182b3436 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -7,10 +7,13 @@ [#6795](https://github.com/pulumi/pulumi/pull/6795) - [automation/dotnet] Remove dependency on Gprc.Tools for F# / Paket compatibility - [#6793](https://github.com/pulumi/pulumi/pull/6793) + [#6793](https://github.com/pulumi/pulumi/pull/6793) ### Bug Fixes - [codegen] Fix codegen for types that are used by both resources and functions. [#6811](https://github.com/pulumi/pulumi/pull/6811) + +- [sdk/python] Fix bug in `get_resource_module` affecting resource hydration. + [#6833](https://github.com/pulumi/pulumi/pull/6833) diff --git a/sdk/python/lib/pulumi/runtime/rpc.py b/sdk/python/lib/pulumi/runtime/rpc.py index 4e4c3d5d3..4cbac5c28 100644 --- a/sdk/python/lib/pulumi/runtime/rpc.py +++ b/sdk/python/lib/pulumi/runtime/rpc.py @@ -24,7 +24,7 @@ from typing import List, Any, Callable, Dict, Mapping, Optional, Sequence, Set, from enum import Enum from google.protobuf import struct_pb2 -from semver import VersionInfo as Version # type:ignore +from semver import VersionInfo as Version import six from . import known_types, settings from .. import log @@ -777,7 +777,7 @@ def same_version(a: Optional[Version], b: Optional[Version]) -> bool: def check_version(want: Optional[Version], have: Optional[Version]) -> bool: if want is None or have is None: return True - return have.major == want.major() and have.minor() >= want.minor() and have.patch() >= want.patch() + return have.major == want.major and have.minor >= want.minor and have.patch >= want.patch class ResourcePackage(ABC): diff --git a/sdk/python/mypy.ini b/sdk/python/mypy.ini index c151dc1c5..ea75cb73c 100644 --- a/sdk/python/mypy.ini +++ b/sdk/python/mypy.ini @@ -10,9 +10,6 @@ ignore_missing_imports = True [mypy-google.protobuf.pyext._message] ignore_missing_imports = True -[mypy-semver] -ignore_missing_imports = True - # grpc generated [mypy-pulumi.runtime.proto.*] ignore_errors = True diff --git a/sdk/python/stubs/semver/__init__.pyi b/sdk/python/stubs/semver/__init__.pyi new file mode 100644 index 000000000..a77bc7412 --- /dev/null +++ b/sdk/python/stubs/semver/__init__.pyi @@ -0,0 +1,11 @@ +class VersionInfo: + major: int + minor: int + patch: int + + def compare(self, other: VersionInfo) -> int: + ... + + @staticmethod + def parse(version: str) -> VersionInfo: + ...