diff --git a/packages/@jsii/python-runtime/build-tools/gen.ts b/packages/@jsii/python-runtime/build-tools/gen.ts index e375f61a0a..7cf813848d 100644 --- a/packages/@jsii/python-runtime/build-tools/gen.ts +++ b/packages/@jsii/python-runtime/build-tools/gen.ts @@ -2,6 +2,8 @@ import { copyFileSync, readdirSync, statSync, writeFileSync } from 'fs'; import { resolve } from 'path'; +import { TargetName } from 'jsii-pacmak'; +import { toReleaseVersion } from 'jsii-pacmak/lib/targets/version-utils'; const EMBEDDED_SOURCE = resolve(__dirname, '..', '..', 'runtime', 'webpack'); const EMBEDDED_INFO = resolve(__dirname, '..', '..', 'runtime', 'package.json'); @@ -13,7 +15,7 @@ writeFileSync( resolve(__dirname, '..', 'src', 'jsii', '_metadata.json'), JSON.stringify( { - version: data.version, + version: toReleaseVersion(data.version, TargetName.PYTHON), description: data.description, license: data.license, author: data.author.name, diff --git a/packages/@jsii/python-runtime/requirements.txt b/packages/@jsii/python-runtime/requirements.txt index 7fa5a907fd..00860b94b0 100644 --- a/packages/@jsii/python-runtime/requirements.txt +++ b/packages/@jsii/python-runtime/requirements.txt @@ -1,9 +1,10 @@ -black~=22.12 -mypy==0.812 +black~=23.1 +mypy==1.0.0 pip~=23.0 pytest~=7.2 pytest-mypy~=0.10 -setuptools~=65.5.1 +setuptools~=67.3.2 +types-python-dateutil~=2.8 wheel~=0.38 -e . diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py b/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py index 2a90af0f41..bb5ec44079 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py @@ -276,12 +276,10 @@ def _callback_till_result( @attr.s(auto_attribs=True, frozen=True, slots=True) class Statistics: - object_count: int class Kernel(metaclass=Singleton): - # This class translates between the Pythonic interface for the kernel, and the # Kernel Provider interface that maps more directly to the JSII Kernel interface. # It currently only supports the idea of a process kernel provider, however it diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/base.py b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/base.py index 077739ace6..4e9180b231 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/base.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/base.py @@ -39,7 +39,6 @@ class BaseProvider(metaclass=abc.ABCMeta): - # The API provided by this Provider is not very pythonic, however it is done to map # this API as closely to the JSII runtime as possible. Higher level abstractions # that layer ontop of the Provider will provide a translation layer that make this diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py index 8932bbd94d..7ae62a11d5 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py @@ -69,13 +69,11 @@ @attr.s(auto_attribs=True, frozen=True, slots=True) class _HelloResponse: - hello: str @attr.s(auto_attribs=True, frozen=True, slots=True) class _OkayResponse: - # We could technically mark this as KernelResponse, because we know that # it is going to be one of those. However, we can't disambiguate the different # types because some of them have the same keys as each other, so the only way @@ -86,7 +84,6 @@ class _OkayResponse: @attr.s(auto_attribs=True, frozen=True, slots=True) class _ErrorResponse: - error: str stack: str name: str @@ -94,13 +91,11 @@ class _ErrorResponse: @attr.s(auto_attribs=True, frozen=True, slots=True) class _CallbackResponse: - callback: Callback @attr.s(auto_attribs=True, frozen=True, slots=True) class _CompleteRequest: - complete: CompleteRequest @@ -284,7 +279,7 @@ def start(self): self.handshake() - def stop(self): + def stop(self) -> None: # This process is closing already, un-registering the hook to not fire twice atexit.unregister(self.stop) @@ -304,7 +299,7 @@ def stop(self): self._ctx_stack.close() - def handshake(self): + def handshake(self) -> None: # Get the version of the runtime that we're using. resp: _HelloResponse = self._serializer.structure( self._next_message(), _HelloResponse diff --git a/packages/@jsii/python-runtime/src/jsii/_kernel/types.py b/packages/@jsii/python-runtime/src/jsii/_kernel/types.py index 838a24f661..7779a3e6ee 100644 --- a/packages/@jsii/python-runtime/src/jsii/_kernel/types.py +++ b/packages/@jsii/python-runtime/src/jsii/_kernel/types.py @@ -6,21 +6,18 @@ @attr.s(auto_attribs=True, frozen=True, slots=True) class ObjRef: - ref: str interfaces: Optional[List[str]] = None @attr.s(auto_attribs=True, frozen=True, slots=True) class EnumRef: - ref: ObjRef member: str @attr.s(auto_attribs=True, frozen=True, slots=True) class Override: - method: Optional[str] = None property: Optional[str] = None cookie: Optional[str] = None @@ -28,7 +25,6 @@ class Override: @attr.s(auto_attribs=True, frozen=True, slots=True) class LoadRequest: - name: str version: str tarball: str @@ -36,14 +32,12 @@ class LoadRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class LoadResponse: - assembly: str types: int @attr.s(auto_attribs=True, frozen=True, slots=True) class GetScriptCommandRequest: - assembly: str script: str args: List[Any] = attr.Factory(list) @@ -51,7 +45,6 @@ class GetScriptCommandRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class GetScriptCommandResponse: - command: str args: List[str] = attr.Factory(list) env: Dict[str, str] = attr.Factory(dict) @@ -59,7 +52,6 @@ class GetScriptCommandResponse: @attr.s(auto_attribs=True, frozen=True, slots=True) class InvokeScriptRequest: - assembly: str script: str args: List[Any] = attr.Factory(list) @@ -67,7 +59,6 @@ class InvokeScriptRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class InvokeScriptResponse: - status: int stdout: str stderr: str @@ -76,7 +67,6 @@ class InvokeScriptResponse: @attr.s(auto_attribs=True, frozen=True, slots=True) class CreateRequest: - fqn: str args: List[Any] = attr.Factory(list) overrides: List[Override] = attr.Factory(list) @@ -90,7 +80,6 @@ class CreateResponse(ObjRef): @attr.s(auto_attribs=True, frozen=True, slots=True) class DeleteRequest: - objref: ObjRef @@ -101,27 +90,23 @@ class DeleteResponse: @attr.s(auto_attribs=True, frozen=True, slots=True) class GetRequest: - objref: ObjRef property: str @attr.s(auto_attribs=True, frozen=True, slots=True) class StaticGetRequest: - fqn: str property: str @attr.s(auto_attribs=True, frozen=True, slots=True) class GetResponse: - value: Any = None @attr.s(auto_attribs=True, frozen=True, slots=True) class StaticSetRequest: - fqn: str property: str value: str @@ -129,7 +114,6 @@ class StaticSetRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class SetRequest: - objref: ObjRef property: str value: Any @@ -142,7 +126,6 @@ class SetResponse: @attr.s(auto_attribs=True, frozen=True, slots=True) class StaticInvokeRequest: - fqn: str method: str args: Optional[List[Any]] = attr.Factory(list) @@ -150,7 +133,6 @@ class StaticInvokeRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class InvokeRequest: - objref: ObjRef method: str args: Optional[List[Any]] = attr.Factory(list) @@ -158,13 +140,11 @@ class InvokeRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class InvokeResponse: - result: Any = None @attr.s(auto_attribs=True, frozen=True, slots=True) class BeginRequest: - objref: ObjRef method: str args: Optional[List[Any]] = attr.Factory(list) @@ -172,25 +152,21 @@ class BeginRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class BeginResponse: - promiseid: str @attr.s(auto_attribs=True, frozen=True, slots=True) class EndRequest: - promiseid: str @attr.s(auto_attribs=True, frozen=True, slots=True) class EndResponse: - result: Optional[Any] = None @attr.s(auto_attribs=True, frozen=True, slots=True) class Callback: - cbid: str cookie: str invoke: Optional[InvokeRequest] = None @@ -205,13 +181,11 @@ class CallbacksRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class CallbacksResponse: - callbacks: List[Callback] @attr.s(auto_attribs=True, frozen=True, slots=True) class CompleteRequest: - cbid: str err: Optional[str] = None result: Optional[Any] = None @@ -219,19 +193,16 @@ class CompleteRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class CompleteResponse: - cbid: str @attr.s(auto_attribs=True, frozen=True, slots=True) class NamingRequest: - assembly: str @attr.s(auto_attribs=True, frozen=True, slots=True) class NamingResponse: - naming: Mapping[str, Mapping[str, Optional[Any]]] @@ -242,7 +213,6 @@ class StatsRequest: @attr.s(auto_attribs=True, frozen=True, slots=True) class StatsResponse: - objectCount: int diff --git a/packages/@jsii/python-runtime/src/jsii/_runtime.py b/packages/@jsii/python-runtime/src/jsii/_runtime.py index 4604e93db9..19dcc31ba0 100644 --- a/packages/@jsii/python-runtime/src/jsii/_runtime.py +++ b/packages/@jsii/python-runtime/src/jsii/_runtime.py @@ -31,7 +31,6 @@ @attr.s(auto_attribs=True, frozen=True, slots=True) class JSIIAssembly: - name: str version: str module: str diff --git a/packages/@jsii/python-runtime/src/jsii/_utils.py b/packages/@jsii/python-runtime/src/jsii/_utils.py index c486c9bcbf..007a91e5e3 100644 --- a/packages/@jsii/python-runtime/src/jsii/_utils.py +++ b/packages/@jsii/python-runtime/src/jsii/_utils.py @@ -4,7 +4,6 @@ class Singleton(type): - _instances: MutableMapping[Type[Any], Any] = {} def __call__(cls, *args, **kwargs): diff --git a/packages/@jsii/python-runtime/tests/test_compliance.py b/packages/@jsii/python-runtime/tests/test_compliance.py index 9b09682462..7192f96db5 100644 --- a/packages/@jsii/python-runtime/tests/test_compliance.py +++ b/packages/@jsii/python-runtime/tests/test_compliance.py @@ -132,7 +132,6 @@ def override_me_too(self): class SyncOverrides(SyncVirtualMethods): - multiplier = 1 return_super = False call_async = False @@ -648,7 +647,6 @@ def the_property(self, value): def test_propertyOverrides_interfaces(): @jsii.implements(IInterfaceWithProperties) class TInterfaceWithProperties: - x = None @property @@ -673,7 +671,6 @@ def read_write_string(self, value): def test_interfaceBuilder(): @jsii.implements(IInterfaceWithProperties) class TInterfaceWithProperties: - x = "READ_WRITE" @property @@ -729,7 +726,7 @@ def test_fail_syncOverrides_callsDoubleAsync_propertySetter(): obj.caller_is_property = 12 -def test_testInterfaces(): +def test_testInterfaces() -> None: friendly: IFriendly friendlier: IFriendlier random_number_generator: IRandomNumberGenerator diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 30374e20fc..831f0e41e0 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -2081,7 +2081,10 @@ class Package { code.closeFile('README.md'); // Strip " (build abcdef)" from the jsii version - const jsiiVersionSimple = this.metadata.jsiiVersion.replace(/ .*$/, ''); + const jsiiVersionSimple = toReleaseVersion( + this.metadata.jsiiVersion.replace(/ .*$/, ''), + TargetName.PYTHON, + ); const setupKwargs = { name: this.name, diff --git a/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt b/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt index bf9747abe2..524f11fbac 100644 --- a/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt +++ b/packages/jsii-pacmak/lib/targets/python/requirements-dev.txt @@ -3,7 +3,7 @@ # be installed in the virtual environment used for building the distribution # package (wheel, sdist), but not declared as build-system dependencies. -setuptools~=65.5.1 # build-system -wheel~=0.38.4 # build-system +setuptools~=67.3.2 # build-system +wheel~=0.38 # build-system twine~=4.0.2 diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap index c6d4b04771..dd27fd2f5d 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap @@ -1220,7 +1220,7 @@ testpkg.FooBar=example.test.demo.FooBar exports[`diamond-struct-parameter.ts: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] @@ -2641,7 +2641,7 @@ testpkg.Namespace2.Foo.Final=example.test.demo.Namespace2$Foo.Final exports[`nested-types.ts: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap index dfb457b49c..269762fb91 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap @@ -407,7 +407,7 @@ foo exports[`foo@1.2.3 depends on bar@^2.0.0-rc.42: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] @@ -916,7 +916,7 @@ foo exports[`foo@1.2.3 depends on bar@^4.5.6-pre.1337: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] @@ -1405,7 +1405,7 @@ foo exports[`foo@2.0.0-rc.42: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] @@ -1891,7 +1891,7 @@ foo exports[`foo@4.5.6-pre.1337: /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap index d01c555b50..1e09f2e78f 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap @@ -243,7 +243,7 @@ scope.jsii-calc-base exports[`Generated code for "@scope/jsii-calc-base": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] @@ -797,7 +797,7 @@ scope.jsii-calc-base-of-base exports[`Generated code for "@scope/jsii-calc-base-of-base": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] @@ -1324,7 +1324,7 @@ scope.jsii-calc-lib exports[`Generated code for "@scope/jsii-calc-lib": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright] @@ -2914,7 +2914,7 @@ foo = "bar" exports[`Generated code for "jsii-calc": /python/pyproject.toml 1`] = ` [build-system] -requires = ["setuptools~=65.5.1", "wheel~=0.38.4"] +requires = ["setuptools~=67.3.2", "wheel~=0.38"] build-backend = "setuptools.build_meta" [tool.pyright]