Commit dae724c
authored
fix(python): KeyError in type checks when decorating methods (#3791)
When methods are decorated by users (e.g: replaced with an alternate function that delegates back to the original one), type annotations are not carried over to the new function.
Since type checking code relied on dynamically accessing the checked function for the purpose of getting type hints,this resulted in unexpected errors when executing type checking code.
In order to address this, the type checking code now declares a stub function locally with the relevant type information in order to have a reliable/stable source of type annotations (these cannot be constructed dynamically as Python does not expose the necessary constructors).
---
By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].
[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.01 parent 27cd853 commit dae724c
File tree
6 files changed
+1408
-543
lines changed- packages
- @jsii/python-runtime
- src/jsii
- tests
- jsii-pacmak
- lib/targets
- python
- test/generated-code/__snapshots__
6 files changed
+1408
-543
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
11 | 21 | | |
12 | 22 | | |
13 | | - | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
24 | 48 | | |
25 | 49 | | |
26 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
664 | 666 | | |
665 | 667 | | |
666 | 668 | | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
| 669 | + | |
675 | 670 | | |
676 | 671 | | |
677 | 672 | | |
| |||
945 | 940 | | |
946 | 941 | | |
947 | 942 | | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
| 943 | + | |
960 | 944 | | |
961 | 945 | | |
962 | 946 | | |
| |||
1142 | 1126 | | |
1143 | 1127 | | |
1144 | 1128 | | |
1145 | | - | |
1146 | | - | |
1147 | | - | |
1148 | | - | |
1149 | | - | |
1150 | | - | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
1151 | 1137 | | |
1152 | 1138 | | |
1153 | 1139 | | |
| |||
3055 | 3041 | | |
3056 | 3042 | | |
3057 | 3043 | | |
| 3044 | + | |
3058 | 3045 | | |
3059 | | - | |
3060 | 3046 | | |
3061 | 3047 | | |
3062 | 3048 | | |
3063 | 3049 | | |
3064 | 3050 | | |
3065 | | - | |
3066 | 3051 | | |
3067 | 3052 | | |
3068 | 3053 | | |
| |||
3078 | 3063 | | |
3079 | 3064 | | |
3080 | 3065 | | |
3081 | | - | |
3082 | | - | |
3083 | | - | |
3084 | | - | |
3085 | | - | |
3086 | | - | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
3087 | 3070 | | |
3088 | 3071 | | |
3089 | 3072 | | |
3090 | 3073 | | |
3091 | | - | |
3092 | | - | |
3093 | | - | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
3094 | 3081 | | |
3095 | 3082 | | |
3096 | 3083 | | |
3097 | 3084 | | |
3098 | | - | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
3099 | 3096 | | |
3100 | 3097 | | |
3101 | 3098 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | 406 | | |
421 | 407 | | |
422 | 408 | | |
| |||
Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments