-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pacmak): allow typeguard==3.x
and typeguard==4.x
#4611
Changes from all commits
bef73f6
4701ee1
ade49c6
a0e88b0
413f5c1
9bb6969
b600103
d94b5b4
239b974
a10e213
d60622f
04c5fe7
cb65a51
6b849e8
5560950
59afc90
9f1f4cd
fec8d74
d19f566
59edf5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -168,6 +168,10 @@ def implements(*interfaces: Type[Any]) -> Callable[[T], T]: | |||||||||||||
def deco(cls): | ||||||||||||||
cls.__jsii_type__ = getattr(cls, "__jsii_type__", None) | ||||||||||||||
cls.__jsii_ifaces__ = getattr(cls, "__jsii_ifaces__", []) + list(interfaces) | ||||||||||||||
cls.__jsii_proxy_class__ = lambda: getattr(cls, "__jsii_proxy_class__", None) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required because jsii/packages/jsii-pacmak/lib/targets/python.ts Lines 1068 to 1070 in 9ecea56
For pacmak generated classes, jsii/packages/jsii-pacmak/lib/targets/python.ts Lines 1496 to 1498 in 9ecea56
But in order to support user defined protocol implementations, this needs to be added via the Note that prior to 4.x, |
||||||||||||||
|
||||||||||||||
# https://github.com/agronholm/typeguard/issues/479 | ||||||||||||||
cls.__protocol_attrs__ = getattr(cls, "__protocol_attrs__", []) | ||||||||||||||
return cls | ||||||||||||||
|
||||||||||||||
return deco | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,17 +27,6 @@ def test_inheritance_maintained(self): | |
|
||
assert base_names == ["DerivedStruct", "MyFirstStruct"] | ||
|
||
def test_descriptive_error_when_passing_function(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to |
||
obj = jsii_calc.Calculator() | ||
|
||
with pytest.raises( | ||
TypeError, | ||
match=re.escape( | ||
"type of argument value must be one of (int, float); got method instead" | ||
), | ||
): | ||
obj.add(cast(Any, self.test_descriptive_error_when_passing_function)) | ||
|
||
def test_implements_interface(self) -> None: | ||
"""Checks that jsii-generated classes correctly implement the relevant jsii-generated interfaces.""" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will now run three test suites, for each typeguard major version we support. These tests are pretty quick so compared to the current latency of PR validation, they don't add much.