Skip to content

Commit

Permalink
Merge branch 'main' into rmuller/go-iface-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller authored Mar 2, 2021
2 parents 6f07e23 + cda7e25 commit 44262db
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gh-pages/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mkdocs~=1.1.2
mkdocs-awesome-pages-plugin~=2.5.0
mkdocs-material~=6.2.8
mkdocs-material~=7.0.3
mkdocs-git-revision-date-plugin~=0.3.1
2 changes: 1 addition & 1 deletion packages/@jsii/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Update="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" />
<PackageReference Update="Microsoft.CodeQuality.Analyzers" Version="3.3.2" />

<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Update="NSubstitute" Version="4.2.2" />
<PackageReference Update="xunit" Version="2.4.1" />
<PackageReference Update="xunit.runner.visualstudio" Version="2.4.3" />
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/python-runtime/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mypy==0.812
pip~=21.0
pytest~=6.2
pytest-mypy~=0.8
setuptools~=53.0
setuptools~=54.0
wheel~=0.36

-e .
2 changes: 1 addition & 1 deletion packages/@jsii/python-runtime/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
install_requires=[
"attrs~=20.1",
"cattrs~=1.0.0 ; python_version < '3.7'",
"cattrs~=1.1.0 ; python_version >= '3.7'",
"cattrs~=1.3.0 ; python_version >= '3.7'",
"importlib_resources ; python_version < '3.7'",
"python-dateutil",
"typing_extensions~=3.7",
Expand Down
11 changes: 10 additions & 1 deletion packages/@jsii/python-runtime/src/jsii/_kernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import functools

import attr
import enum

from ..errors import JSIIError
from .. import _reference_map
Expand Down Expand Up @@ -137,15 +138,20 @@ def _make_reference_for_native(kernel, d):
k: _make_reference_for_native(kernel, v) for k, v in d.items()
}
}

elif isinstance(d, list):
return [_make_reference_for_native(kernel, i) for i in d]

if getattr(d, "__jsii_type__", None) is not None:
typeFqn = getattr(d, "__jsii_type__")

if isinstance(d, enum.Enum):
return {"$jsii.enum": f"{typeFqn}/{d.value}"}

# Ugly delayed import here because I can't solve the cyclic
# package dependency right now :(.
from .._runtime import python_jsii_mapping

typeFqn = getattr(d, "__jsii_type__")
mapping = python_jsii_mapping(d)
if mapping: # This means we are handling a data_type (aka Struct)
return {
Expand All @@ -160,8 +166,10 @@ def _make_reference_for_native(kernel, d):
}
}
return d

elif isinstance(d, (int, type(None), str, float, bool, datetime.datetime)):
return d

elif isinstance(d, (FunctionType, MethodType, BuiltinFunctionType, LambdaType)):
# Whether a given object is a function-like object.
# We won't use iscallable() since objects may implement __call__()
Expand All @@ -170,6 +178,7 @@ def _make_reference_for_native(kernel, d):
"Cannot pass function as argument here (did you mean to call this function?): %r"
% d
)

else:
kernel.create(d.__class__, d)
_reference_map.register_reference(d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ class _CompleteRequest:


_ProcessResponse = Union[_OkayResponse, _ErrorRespose, _CallbackResponse]
# Workaround for mypy#5354
_ProcessResponse_R: Type[Any]
if not TYPE_CHECKING:
_ProcessResponse_R = _ProcessResponse


def _with_api_key(api_name, asdict):
Expand Down Expand Up @@ -319,7 +315,7 @@ def send(
self._process.stdin.flush()

resp: _ProcessResponse = self._serializer.structure(
self._next_message(), _ProcessResponse_R
self._next_message(), _ProcessResponse
)

if isinstance(resp, _OkayResponse):
Expand Down
9 changes: 2 additions & 7 deletions packages/@jsii/python-runtime/src/jsii/_kernel/types.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
from typing import Union, List, Any, Optional, Mapping
from typing import Any, Generic, List, Optional, Mapping, TypeVar, Union
from typing_extensions import Protocol

import attr


# TODO:
# - HelloResponse
# - OkayResponse
# - ErrorResponse


@attr.s(auto_attribs=True, frozen=True, slots=True)
class ObjRef:

Expand Down Expand Up @@ -241,6 +235,7 @@ class StatsResponse:
CreateRequest,
DeleteRequest,
GetRequest,
SetRequest,
StaticGetRequest,
InvokeRequest,
InvokeScriptRequest,
Expand Down

0 comments on commit 44262db

Please sign in to comment.