jsii-pacmak 1.70.0 → 1.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/jsii-pacmak.js +11 -2
- package/lib/targets/python/requirements-dev.txt +2 -2
- package/lib/targets/python/type-name.js +12 -4
- package/lib/targets/python.d.ts +8 -0
- package/lib/targets/python.js +82 -26
- package/lib/version.d.ts +1 -1
- package/lib/version.js +3 -3
- package/package.json +14 -14
package/bin/jsii-pacmak.js
CHANGED
|
@@ -12,16 +12,25 @@ const version_1 = require("../lib/version");
|
|
|
12
12
|
.env('JSII_PACMAK')
|
|
13
13
|
.command(['$0 [PROJECTS...]', 'generate [PROJECTS...]'], 'Generates jsii bindings for the selected project(s)', (argv) => argv.positional('PROJECTS', {
|
|
14
14
|
type: 'string',
|
|
15
|
+
array: true,
|
|
15
16
|
desc: 'Project(s) to generate',
|
|
16
17
|
normalize: true,
|
|
17
18
|
default: ['.'],
|
|
18
19
|
}))
|
|
19
20
|
.option('targets', {
|
|
20
21
|
alias: ['target', 't'],
|
|
21
|
-
type: '
|
|
22
|
+
type: 'string',
|
|
23
|
+
array: true,
|
|
22
24
|
desc: 'target languages for which to generate bindings',
|
|
23
25
|
defaultDescription: 'all targets defined in `package.json` will be generated',
|
|
24
|
-
|
|
26
|
+
coerce: (value) => (typeof value === 'string'
|
|
27
|
+
? value.split(',')
|
|
28
|
+
: value.flatMap((item) => item.split(','))).map((choice) => {
|
|
29
|
+
if (Object.values(lib_1.TargetName).includes(choice)) {
|
|
30
|
+
return choice;
|
|
31
|
+
}
|
|
32
|
+
throw new Error(`Invalid target name: ${choice} (valid values are: ${Object.values(lib_1.TargetName).join(', ')})`);
|
|
33
|
+
}),
|
|
25
34
|
required: false,
|
|
26
35
|
})
|
|
27
36
|
.option('outdir', {
|
|
@@ -199,20 +199,28 @@ class UserType {
|
|
|
199
199
|
const type = typeResolver(__classPrivateFieldGet(this, _UserType_fqn, "f"));
|
|
200
200
|
const isStruct = (0, spec_1.isInterfaceType)(type) && !!type.datatype;
|
|
201
201
|
const wrapType = typeAnnotation && parameterType && isStruct
|
|
202
|
-
? (pyType) => `typing.Union[${pyType}, typing.Dict[str, typing.Any]]`
|
|
202
|
+
? (pyType) => `typing.Union[${pyType}, typing.Dict[builtins.str, typing.Any]]`
|
|
203
203
|
: (pyType) => pyType;
|
|
204
|
+
// Emit aliased imports for dependencies (this avoids name collisions)
|
|
204
205
|
if (assemblyName !== assembly.name) {
|
|
206
|
+
const aliasSuffix = (0, crypto_1.createHash)('sha256')
|
|
207
|
+
.update(assemblyName)
|
|
208
|
+
.update('.*')
|
|
209
|
+
.digest('hex')
|
|
210
|
+
.substring(0, 8);
|
|
211
|
+
const alias = `_${packageName.replace(/\./g, '_')}_${aliasSuffix}`;
|
|
212
|
+
const aliasedFqn = `${alias}${pythonFqn.slice(packageName.length)}`;
|
|
205
213
|
return {
|
|
206
214
|
// If it's a struct, then we allow passing as a dict, too...
|
|
207
|
-
pythonType: wrapType(
|
|
215
|
+
pythonType: wrapType(aliasedFqn),
|
|
208
216
|
requiredImport: {
|
|
209
|
-
sourcePackage: packageName
|
|
217
|
+
sourcePackage: `${packageName} as ${alias}`,
|
|
210
218
|
item: '',
|
|
211
219
|
},
|
|
212
220
|
};
|
|
213
221
|
}
|
|
214
222
|
const submodulePythonName = toPythonFqn(submodule, assembly).pythonFqn;
|
|
215
|
-
const typeSubmodulePythonName = toPythonFqn(findParentSubmodule(
|
|
223
|
+
const typeSubmodulePythonName = toPythonFqn(findParentSubmodule(type, assembly), assembly).pythonFqn;
|
|
216
224
|
if (typeSubmodulePythonName === submodulePythonName) {
|
|
217
225
|
// Identify declarations that are not yet initialized and hence cannot be
|
|
218
226
|
// used as part of a type qualification. Since this is not a forward
|
package/lib/targets/python.d.ts
CHANGED
|
@@ -17,6 +17,14 @@ interface EmitContext extends NamingContext {
|
|
|
17
17
|
readonly runtimeTypeChecking: boolean;
|
|
18
18
|
/** Whether to runtime type check keyword arguments (i.e: struct constructors) */
|
|
19
19
|
readonly runtimeTypeCheckKwargs?: boolean;
|
|
20
|
+
/** The numerical IDs used for type annotation data storing */
|
|
21
|
+
readonly typeCheckingHelper: TypeCheckingHelper;
|
|
22
|
+
}
|
|
23
|
+
declare class TypeCheckingHelper {
|
|
24
|
+
#private;
|
|
25
|
+
getTypeHints(fqn: string, args: readonly string[]): string;
|
|
26
|
+
/** Emits instructions that create the annotations data... */
|
|
27
|
+
flushStubs(code: CodeMaker): void;
|
|
20
28
|
}
|
|
21
29
|
interface PythonBase {
|
|
22
30
|
readonly pythonName: string;
|
package/lib/targets/python.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var _TypeCheckingHelper_stubs, _a, _TypeCheckingStub_PREFIX, _TypeCheckingStub_arguments, _TypeCheckingStub_hash;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
const spec = require("@jsii/spec");
|
|
4
16
|
const assert = require("assert");
|
|
5
17
|
const codemaker_1 = require("codemaker");
|
|
18
|
+
const crypto = require("crypto");
|
|
6
19
|
const escapeStringRegexp = require("escape-string-regexp");
|
|
7
20
|
const fs = require("fs-extra");
|
|
8
21
|
const jsii_rosetta_1 = require("jsii-rosetta");
|
|
@@ -74,6 +87,50 @@ class Python extends target_1.Target {
|
|
|
74
87
|
}
|
|
75
88
|
}
|
|
76
89
|
exports.default = Python;
|
|
90
|
+
class TypeCheckingHelper {
|
|
91
|
+
constructor() {
|
|
92
|
+
_TypeCheckingHelper_stubs.set(this, new Array());
|
|
93
|
+
}
|
|
94
|
+
getTypeHints(fqn, args) {
|
|
95
|
+
const stub = new TypeCheckingStub(fqn, args);
|
|
96
|
+
__classPrivateFieldGet(this, _TypeCheckingHelper_stubs, "f").push(stub);
|
|
97
|
+
return `typing.get_type_hints(${stub.name})`;
|
|
98
|
+
}
|
|
99
|
+
/** Emits instructions that create the annotations data... */
|
|
100
|
+
flushStubs(code) {
|
|
101
|
+
for (const stub of __classPrivateFieldGet(this, _TypeCheckingHelper_stubs, "f")) {
|
|
102
|
+
stub.emit(code);
|
|
103
|
+
}
|
|
104
|
+
// Reset the stubs list
|
|
105
|
+
__classPrivateFieldSet(this, _TypeCheckingHelper_stubs, [], "f");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_TypeCheckingHelper_stubs = new WeakMap();
|
|
109
|
+
class TypeCheckingStub {
|
|
110
|
+
constructor(fqn, args) {
|
|
111
|
+
_TypeCheckingStub_arguments.set(this, void 0);
|
|
112
|
+
_TypeCheckingStub_hash.set(this, void 0);
|
|
113
|
+
// Removing the quoted type names -- this will be emitted at the very end of the module.
|
|
114
|
+
__classPrivateFieldSet(this, _TypeCheckingStub_arguments, args.map((arg) => arg.replace(/"/g, '')), "f");
|
|
115
|
+
__classPrivateFieldSet(this, _TypeCheckingStub_hash, crypto
|
|
116
|
+
.createHash('sha256')
|
|
117
|
+
.update(__classPrivateFieldGet(TypeCheckingStub, _a, "f", _TypeCheckingStub_PREFIX))
|
|
118
|
+
.update(fqn)
|
|
119
|
+
.digest('hex'), "f");
|
|
120
|
+
}
|
|
121
|
+
get name() {
|
|
122
|
+
return `${__classPrivateFieldGet(TypeCheckingStub, _a, "f", _TypeCheckingStub_PREFIX)}${__classPrivateFieldGet(this, _TypeCheckingStub_hash, "f")}`;
|
|
123
|
+
}
|
|
124
|
+
emit(code) {
|
|
125
|
+
code.line();
|
|
126
|
+
openSignature(code, 'def', this.name, __classPrivateFieldGet(this, _TypeCheckingStub_arguments, "f"), 'None');
|
|
127
|
+
code.line(`"""Type checking stubs"""`);
|
|
128
|
+
code.line('pass');
|
|
129
|
+
code.closeBlock();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
_a = TypeCheckingStub, _TypeCheckingStub_arguments = new WeakMap(), _TypeCheckingStub_hash = new WeakMap();
|
|
133
|
+
_TypeCheckingStub_PREFIX = { value: '_typecheckingstub__' };
|
|
77
134
|
const pythonModuleNameToFilename = (name) => {
|
|
78
135
|
return path.join(...name.split('.'));
|
|
79
136
|
};
|
|
@@ -295,7 +352,7 @@ class BasePythonClassType {
|
|
|
295
352
|
}
|
|
296
353
|
}
|
|
297
354
|
class BaseMethod {
|
|
298
|
-
constructor(generator, pythonName, jsName, parameters, returns, docs, isStatic, opts) {
|
|
355
|
+
constructor(generator, pythonName, jsName, parameters, returns, docs, isStatic, pythonParent, opts) {
|
|
299
356
|
this.generator = generator;
|
|
300
357
|
this.pythonName = pythonName;
|
|
301
358
|
this.jsName = jsName;
|
|
@@ -303,6 +360,7 @@ class BaseMethod {
|
|
|
303
360
|
this.returns = returns;
|
|
304
361
|
this.docs = docs;
|
|
305
362
|
this.isStatic = isStatic;
|
|
363
|
+
this.pythonParent = pythonParent;
|
|
306
364
|
this.classAsFirstParameter = false;
|
|
307
365
|
this.returnFromJSIIMethod = true;
|
|
308
366
|
this.shouldEmitBody = true;
|
|
@@ -441,7 +499,7 @@ class BaseMethod {
|
|
|
441
499
|
});
|
|
442
500
|
if ((this.shouldEmitBody || forceEmitBody) &&
|
|
443
501
|
(!renderAbstract || !this.abstract)) {
|
|
444
|
-
emitParameterTypeChecks(code, context, pythonParams.slice(1));
|
|
502
|
+
emitParameterTypeChecks(code, context, pythonParams.slice(1), `${this.pythonParent.fqn ?? this.pythonParent.pythonName}#${this.pythonName}`);
|
|
445
503
|
}
|
|
446
504
|
this.emitBody(code, context, renderAbstract, forceEmitBody, liftedPropNames, pythonParams[0], returnType);
|
|
447
505
|
code.closeBlock();
|
|
@@ -542,12 +600,13 @@ class BaseMethod {
|
|
|
542
600
|
}
|
|
543
601
|
}
|
|
544
602
|
class BaseProperty {
|
|
545
|
-
constructor(generator, pythonName, jsName, type, docs, opts) {
|
|
603
|
+
constructor(generator, pythonName, jsName, type, docs, pythonParent, opts) {
|
|
546
604
|
this.generator = generator;
|
|
547
605
|
this.pythonName = pythonName;
|
|
548
606
|
this.jsName = jsName;
|
|
549
607
|
this.type = type;
|
|
550
608
|
this.docs = docs;
|
|
609
|
+
this.pythonParent = pythonParent;
|
|
551
610
|
this.shouldEmitBody = true;
|
|
552
611
|
const { abstract = false, immutable = false, isStatic = false } = opts;
|
|
553
612
|
this.abstract = abstract;
|
|
@@ -598,7 +657,7 @@ class BaseProperty {
|
|
|
598
657
|
openSignature(code, 'def', this.pythonName, [this.implicitParameter, `value: ${pythonType}`], 'None');
|
|
599
658
|
if ((this.shouldEmitBody || forceEmitBody) &&
|
|
600
659
|
(!renderAbstract || !this.abstract)) {
|
|
601
|
-
emitParameterTypeChecks(code, context, [`value: ${pythonType}`]);
|
|
660
|
+
emitParameterTypeChecks(code, context, [`value: ${pythonType}`], `${this.pythonParent.fqn ?? this.pythonParent.pythonName}#${this.pythonName}`);
|
|
602
661
|
code.line(`jsii.${this.jsiiSetMethod}(${this.implicitParameter}, "${this.jsName}", value)`);
|
|
603
662
|
}
|
|
604
663
|
else {
|
|
@@ -747,10 +806,10 @@ class Struct extends BasePythonClassType {
|
|
|
747
806
|
if (kwargs.length > 0) {
|
|
748
807
|
emitParameterTypeChecks(code,
|
|
749
808
|
// Runtime type check keyword args as this is a struct __init__ function.
|
|
750
|
-
{ ...context, runtimeTypeCheckKwargs: true }, ['*', ...kwargs]);
|
|
809
|
+
{ ...context, runtimeTypeCheckKwargs: true }, ['*', ...kwargs], `${this.fqn ?? this.pythonName}#__init__`);
|
|
751
810
|
}
|
|
752
811
|
// Required properties, those will always be put into the dict
|
|
753
|
-
assignDictionary(code, `${implicitParameter}._values: typing.Dict[str, typing.Any]`, members
|
|
812
|
+
assignDictionary(code, `${implicitParameter}._values: typing.Dict[builtins.str, typing.Any]`, members
|
|
754
813
|
.filter((m) => !m.optional)
|
|
755
814
|
.map((member) => `${JSON.stringify(member.pythonName)}: ${member.pythonName}`));
|
|
756
815
|
// Optional properties, will only be put into the dict if they're not None
|
|
@@ -1340,6 +1399,7 @@ class Package {
|
|
|
1340
1399
|
const filename = path.join('src', pythonModuleNameToFilename(mod.pythonName), '__init__.py');
|
|
1341
1400
|
code.openFile(filename);
|
|
1342
1401
|
mod.emit(code, context);
|
|
1402
|
+
context.typeCheckingHelper.flushStubs(code);
|
|
1343
1403
|
code.closeFile(filename);
|
|
1344
1404
|
scripts.push(...mod.emitBinScripts(code));
|
|
1345
1405
|
}
|
|
@@ -1735,6 +1795,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1735
1795
|
resolver,
|
|
1736
1796
|
runtimeTypeChecking: this.runtimeTypeChecking,
|
|
1737
1797
|
submodule: assm.name,
|
|
1798
|
+
typeCheckingHelper: new TypeCheckingHelper(),
|
|
1738
1799
|
typeResolver: (fqn) => resolver.dereference(fqn),
|
|
1739
1800
|
});
|
|
1740
1801
|
}
|
|
@@ -1783,7 +1844,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1783
1844
|
if (cls.initializer !== undefined) {
|
|
1784
1845
|
const { parameters = [] } = cls.initializer;
|
|
1785
1846
|
klass.addMember(new Initializer(this, '__init__', undefined, parameters, undefined, cls.initializer.docs, false, // Never static
|
|
1786
|
-
{ liftedProp: this.getliftedProp(cls.initializer), parent: cls }));
|
|
1847
|
+
klass, { liftedProp: this.getliftedProp(cls.initializer), parent: cls }));
|
|
1787
1848
|
}
|
|
1788
1849
|
this.addPythonType(klass);
|
|
1789
1850
|
}
|
|
@@ -1791,7 +1852,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1791
1852
|
const { parameters = [] } = method;
|
|
1792
1853
|
const klass = this.getPythonType(cls.fqn);
|
|
1793
1854
|
klass.addMember(new StaticMethod(this, toPythonMethodName(method.name), method.name, parameters, method.returns, method.docs, true, // Always static
|
|
1794
|
-
{
|
|
1855
|
+
klass, {
|
|
1795
1856
|
abstract: method.abstract,
|
|
1796
1857
|
liftedProp: this.getliftedProp(method),
|
|
1797
1858
|
parent: cls,
|
|
@@ -1799,7 +1860,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1799
1860
|
}
|
|
1800
1861
|
onStaticProperty(cls, prop) {
|
|
1801
1862
|
const klass = this.getPythonType(cls.fqn);
|
|
1802
|
-
klass.addMember(new StaticProperty(this, toPythonPropertyName(prop.name, prop.const), prop.name, prop, prop.docs, {
|
|
1863
|
+
klass.addMember(new StaticProperty(this, toPythonPropertyName(prop.name, prop.const), prop.name, prop, prop.docs, klass, {
|
|
1803
1864
|
abstract: prop.abstract,
|
|
1804
1865
|
immutable: prop.immutable,
|
|
1805
1866
|
isStatic: prop.static,
|
|
@@ -1810,14 +1871,14 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1810
1871
|
const { parameters = [] } = method;
|
|
1811
1872
|
const klass = this.getPythonType(cls.fqn);
|
|
1812
1873
|
if (method.async) {
|
|
1813
|
-
klass.addMember(new AsyncMethod(this, toPythonMethodName(method.name, method.protected), method.name, parameters, method.returns, method.docs, !!method.static, {
|
|
1874
|
+
klass.addMember(new AsyncMethod(this, toPythonMethodName(method.name, method.protected), method.name, parameters, method.returns, method.docs, !!method.static, klass, {
|
|
1814
1875
|
abstract: method.abstract,
|
|
1815
1876
|
liftedProp: this.getliftedProp(method),
|
|
1816
1877
|
parent: cls,
|
|
1817
1878
|
}));
|
|
1818
1879
|
}
|
|
1819
1880
|
else {
|
|
1820
|
-
klass.addMember(new Method(this, toPythonMethodName(method.name, method.protected), method.name, parameters, method.returns, method.docs, !!method.static, {
|
|
1881
|
+
klass.addMember(new Method(this, toPythonMethodName(method.name, method.protected), method.name, parameters, method.returns, method.docs, !!method.static, klass, {
|
|
1821
1882
|
abstract: method.abstract,
|
|
1822
1883
|
liftedProp: this.getliftedProp(method),
|
|
1823
1884
|
parent: cls,
|
|
@@ -1826,7 +1887,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1826
1887
|
}
|
|
1827
1888
|
onProperty(cls, prop) {
|
|
1828
1889
|
const klass = this.getPythonType(cls.fqn);
|
|
1829
|
-
klass.addMember(new Property(this, toPythonPropertyName(prop.name, prop.const, prop.protected), prop.name, prop, prop.docs, {
|
|
1890
|
+
klass.addMember(new Property(this, toPythonPropertyName(prop.name, prop.const, prop.protected), prop.name, prop, prop.docs, klass, {
|
|
1830
1891
|
abstract: prop.abstract,
|
|
1831
1892
|
immutable: prop.immutable,
|
|
1832
1893
|
isStatic: prop.static,
|
|
@@ -1852,7 +1913,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1852
1913
|
onInterfaceMethod(ifc, method) {
|
|
1853
1914
|
const { parameters = [] } = method;
|
|
1854
1915
|
const klass = this.getPythonType(ifc.fqn);
|
|
1855
|
-
klass.addMember(new InterfaceMethod(this, toPythonMethodName(method.name, method.protected), method.name, parameters, method.returns, method.docs, !!method.static, { liftedProp: this.getliftedProp(method), parent: ifc }));
|
|
1916
|
+
klass.addMember(new InterfaceMethod(this, toPythonMethodName(method.name, method.protected), method.name, parameters, method.returns, method.docs, !!method.static, klass, { liftedProp: this.getliftedProp(method), parent: ifc }));
|
|
1856
1917
|
}
|
|
1857
1918
|
onInterfaceProperty(ifc, prop) {
|
|
1858
1919
|
let ifaceProperty;
|
|
@@ -1861,7 +1922,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1861
1922
|
ifaceProperty = new StructField(this, prop, ifc);
|
|
1862
1923
|
}
|
|
1863
1924
|
else {
|
|
1864
|
-
ifaceProperty = new InterfaceProperty(this, toPythonPropertyName(prop.name, prop.const, prop.protected), prop.name, prop, prop.docs, { immutable: prop.immutable, isStatic: prop.static, parent: ifc });
|
|
1925
|
+
ifaceProperty = new InterfaceProperty(this, toPythonPropertyName(prop.name, prop.const, prop.protected), prop.name, prop, prop.docs, klass, { immutable: prop.immutable, isStatic: prop.static, parent: ifc });
|
|
1865
1926
|
}
|
|
1866
1927
|
klass.addMember(ifaceProperty);
|
|
1867
1928
|
}
|
|
@@ -2017,10 +2078,11 @@ function openSignature(code, keyword, name, params, returnType, lineComment) {
|
|
|
2017
2078
|
* @param code the CodeMaker to use for emitting code.
|
|
2018
2079
|
* @param context the emit context used when emitting this code.
|
|
2019
2080
|
* @param params the parameter signatures to be type-checked.
|
|
2081
|
+
* @params pythonName the name of the Python function being checked (qualified).
|
|
2020
2082
|
*/
|
|
2021
|
-
function emitParameterTypeChecks(code, context, params) {
|
|
2083
|
+
function emitParameterTypeChecks(code, context, params, fqn) {
|
|
2022
2084
|
if (!context.runtimeTypeChecking) {
|
|
2023
|
-
return;
|
|
2085
|
+
return false;
|
|
2024
2086
|
}
|
|
2025
2087
|
const paramInfo = params.map((param) => {
|
|
2026
2088
|
const [name] = param.split(/\s*[:=#]\s*/, 1);
|
|
@@ -2049,16 +2111,7 @@ function emitParameterTypeChecks(code, context, params) {
|
|
|
2049
2111
|
}
|
|
2050
2112
|
if (!openedBlock) {
|
|
2051
2113
|
code.openBlock('if __debug__');
|
|
2052
|
-
|
|
2053
|
-
// Inline a stub function to be able to have the required type hints regardless of what customers do with the
|
|
2054
|
-
// code. Using a reference to the `Type.function` may result in incorrect data if some function was replaced (e.g.
|
|
2055
|
-
// by a decorated version with different type annotations). We also cannot construct the actual value expected by
|
|
2056
|
-
// typeguard's `check_type` because Python does not expose the APIs necessary to build many of these objects in
|
|
2057
|
-
// regular Python code.
|
|
2058
|
-
openSignature(code, 'def', stubVar, params, 'None');
|
|
2059
|
-
code.line('...');
|
|
2060
|
-
code.closeBlock();
|
|
2061
|
-
code.line(`${typesVar} = typing.get_type_hints(${stubVar})`);
|
|
2114
|
+
code.line(`${typesVar} = ${context.typeCheckingHelper.getTypeHints(fqn, params)}`);
|
|
2062
2115
|
openedBlock = true;
|
|
2063
2116
|
}
|
|
2064
2117
|
let expectedType = `${typesVar}[${JSON.stringify(name)}]`;
|
|
@@ -2073,7 +2126,10 @@ function emitParameterTypeChecks(code, context, params) {
|
|
|
2073
2126
|
}
|
|
2074
2127
|
if (openedBlock) {
|
|
2075
2128
|
code.closeBlock();
|
|
2129
|
+
return true;
|
|
2076
2130
|
}
|
|
2131
|
+
// We did not reference type annotations data if we never opened a type-checking block.
|
|
2132
|
+
return false;
|
|
2077
2133
|
}
|
|
2078
2134
|
function assignCallResult(code, variable, funct, params) {
|
|
2079
2135
|
const prefix = `${variable} = ${funct}(`;
|
package/lib/version.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
|
|
2
2
|
export declare const VERSION: string;
|
|
3
3
|
/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
|
|
4
|
-
export declare const VERSION_DESC = "1.
|
|
4
|
+
export declare const VERSION_DESC = "1.72.0 (build 4b8828b)";
|
|
5
5
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/version.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Generated at 2022-
|
|
2
|
+
// Generated at 2022-12-05T11:41:26Z by generate.sh
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.VERSION_DESC = exports.VERSION = void 0;
|
|
5
5
|
/** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
7
|
-
exports.VERSION = '1.
|
|
7
|
+
exports.VERSION = '1.72.0';
|
|
8
8
|
/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
|
|
9
|
-
exports.VERSION_DESC = '1.
|
|
9
|
+
exports.VERSION_DESC = '1.72.0 (build 4b8828b)';
|
|
10
10
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsii-pacmak",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.72.0",
|
|
4
4
|
"description": "A code generation framework for jsii backend languages",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,35 +37,35 @@
|
|
|
37
37
|
"package": "package-js"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@jsii/check-node": "1.
|
|
41
|
-
"@jsii/spec": "^1.
|
|
40
|
+
"@jsii/check-node": "1.72.0",
|
|
41
|
+
"@jsii/spec": "^1.72.0",
|
|
42
42
|
"clone": "^2.1.2",
|
|
43
|
-
"codemaker": "^1.
|
|
43
|
+
"codemaker": "^1.72.0",
|
|
44
44
|
"commonmark": "^0.30.0",
|
|
45
45
|
"escape-string-regexp": "^4.0.0",
|
|
46
46
|
"fs-extra": "^10.1.0",
|
|
47
|
-
"jsii-reflect": "^1.
|
|
48
|
-
"jsii-rosetta": "^1.
|
|
47
|
+
"jsii-reflect": "^1.72.0",
|
|
48
|
+
"jsii-rosetta": "^1.72.0",
|
|
49
49
|
"semver": "^7.3.8",
|
|
50
50
|
"spdx-license-list": "^6.6.0",
|
|
51
51
|
"xmlbuilder": "^15.1.1",
|
|
52
52
|
"yargs": "^16.2.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@jsii/dotnet-runtime": "^1.
|
|
56
|
-
"@jsii/java-runtime": "^1.
|
|
57
|
-
"@jsii/go-runtime": "^1.
|
|
58
|
-
"@scope/jsii-calc-lib": "^1.
|
|
55
|
+
"@jsii/dotnet-runtime": "^1.72.0",
|
|
56
|
+
"@jsii/java-runtime": "^1.72.0",
|
|
57
|
+
"@jsii/go-runtime": "^1.72.0",
|
|
58
|
+
"@scope/jsii-calc-lib": "^1.72.0",
|
|
59
59
|
"@types/clone": "^2.1.1",
|
|
60
60
|
"@types/diff": "^5.0.2",
|
|
61
61
|
"@types/commonmark": "^0.27.5",
|
|
62
62
|
"@types/fs-extra": "^9.0.13",
|
|
63
|
-
"@types/semver": "^7.3.
|
|
63
|
+
"@types/semver": "^7.3.13",
|
|
64
64
|
"diff": "^5.1.0",
|
|
65
|
-
"jsii": "^1.
|
|
66
|
-
"jsii-build-tools": "^1.
|
|
65
|
+
"jsii": "^1.72.0",
|
|
66
|
+
"jsii-build-tools": "^1.72.0",
|
|
67
67
|
"jsii-calc": "^3.20.120",
|
|
68
|
-
"pyright": "^1.1.
|
|
68
|
+
"pyright": "^1.1.282"
|
|
69
69
|
},
|
|
70
70
|
"keywords": [
|
|
71
71
|
"jsii",
|