@typespec/emitter-framework 0.18.1-dev.0 → 0.18.1-dev.2
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/.turbo/turbo-build.log +1 -1
- package/dist/src/python/components/class-declaration/class-declaration.test.js +217 -217
- package/dist/src/python/components/class-declaration/class-member.test.js +35 -35
- package/dist/src/python/components/class-declaration/class-method.test.js +24 -24
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js +45 -45
- package/dist/src/python/components/function-declaration/function-declaration.test.js +53 -53
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js +12 -12
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js +7 -7
- package/dist/src/python/components/type-declaration/type-declaration.test.js +5 -5
- package/dist/src/python/components/type-expression/type-expression.d.ts +1 -1
- package/dist/src/python/components/type-expression/type-expression.d.ts.map +1 -1
- package/dist/src/python/components/type-expression/type-expression.test.js +6 -6
- package/package.json +15 -14
- package/package.json.bak +6 -5
- package/src/python/components/class-declaration/class-declaration.test.tsx +217 -217
- package/src/python/components/class-declaration/class-member.test.tsx +35 -35
- package/src/python/components/class-declaration/class-method.test.tsx +24 -24
- package/src/python/components/enum-declaration/enum-declaration.test.tsx +45 -45
- package/src/python/components/function-declaration/function-declaration.test.tsx +53 -53
- package/src/python/components/protocol-declaration/protocol-declaration.test.tsx +12 -12
- package/src/python/components/type-alias-declaration/type-alias-declaration.test.tsx +7 -7
- package/src/python/components/type-declaration/type-declaration.test.tsx +5 -5
- package/src/python/components/type-expression/type-expression.test.tsx +6 -6
- package/tsconfig.json +1 -1
|
@@ -35,24 +35,24 @@ describe("Python Class from model", () => {
|
|
|
35
35
|
from typing import TYPE_CHECKING
|
|
36
36
|
|
|
37
37
|
if TYPE_CHECKING:
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
from typing import Literal
|
|
39
|
+
from typing import Optional
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
@dataclass(kw_only=True)
|
|
43
43
|
class Widget:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
id: str
|
|
45
|
+
weight: int
|
|
46
|
+
aliases: list[str]
|
|
47
|
+
is_active: bool
|
|
48
|
+
color: Literal["blue", "red"]
|
|
49
|
+
promotional_price: float
|
|
50
|
+
description: Optional[str] = "This is a widget"
|
|
51
|
+
created_at: int = 1717334400
|
|
52
|
+
tags: list[str] = ["tag1", "tag2"]
|
|
53
|
+
is_deleted: bool = False
|
|
54
|
+
alternative_color: Literal["green", "yellow"] = "green"
|
|
55
|
+
price: float = 100.0
|
|
56
56
|
|
|
57
57
|
`,
|
|
58
58
|
);
|
|
@@ -73,13 +73,13 @@ describe("Python Class from model", () => {
|
|
|
73
73
|
from typing import TYPE_CHECKING
|
|
74
74
|
|
|
75
75
|
if TYPE_CHECKING:
|
|
76
|
-
|
|
76
|
+
from typing import Optional
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
@dataclass(kw_only=True)
|
|
80
80
|
class Widget:
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
id: str
|
|
82
|
+
description: Optional[str] = "This is a widget"
|
|
83
83
|
|
|
84
84
|
`,
|
|
85
85
|
);
|
|
@@ -100,13 +100,13 @@ describe("Python Class from model", () => {
|
|
|
100
100
|
from typing import TYPE_CHECKING
|
|
101
101
|
|
|
102
102
|
if TYPE_CHECKING:
|
|
103
|
-
|
|
103
|
+
from typing import Optional
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
@dataclass(kw_only=True)
|
|
107
107
|
class Widget:
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
description: Optional[str] = "This is a widget"
|
|
109
|
+
id: str
|
|
110
110
|
|
|
111
111
|
`,
|
|
112
112
|
);
|
|
@@ -130,12 +130,12 @@ describe("Python Class from model", () => {
|
|
|
130
130
|
|
|
131
131
|
@dataclass(kw_only=True)
|
|
132
132
|
class Foo:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
"""
|
|
134
|
+
This is a test
|
|
135
|
+
with multiple lines
|
|
136
|
+
"""
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
known_prop: str
|
|
139
139
|
|
|
140
140
|
`,
|
|
141
141
|
);
|
|
@@ -166,12 +166,12 @@ describe("Python Class from model", () => {
|
|
|
166
166
|
|
|
167
167
|
@dataclass(kw_only=True)
|
|
168
168
|
class Foo:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
"""
|
|
170
|
+
This is an overridden doc comment
|
|
171
|
+
with multiple lines
|
|
172
|
+
"""
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
known_prop: str
|
|
175
175
|
|
|
176
176
|
`,
|
|
177
177
|
);
|
|
@@ -198,13 +198,13 @@ describe("Python Class from model", () => {
|
|
|
198
198
|
|
|
199
199
|
@dataclass(kw_only=True)
|
|
200
200
|
class Foo:
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
"""
|
|
202
|
+
First paragraph
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
Second paragraph
|
|
205
|
+
"""
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
known_prop: str
|
|
208
208
|
|
|
209
209
|
`,
|
|
210
210
|
);
|
|
@@ -231,13 +231,13 @@ describe("Python Class from model", () => {
|
|
|
231
231
|
|
|
232
232
|
@dataclass(kw_only=True)
|
|
233
233
|
class Foo:
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
"""
|
|
235
|
+
Alpha
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
Beta
|
|
238
|
+
"""
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
known_prop: str
|
|
241
241
|
|
|
242
242
|
`,
|
|
243
243
|
);
|
|
@@ -258,11 +258,11 @@ describe("Python Class from model", () => {
|
|
|
258
258
|
|
|
259
259
|
@dataclass(kw_only=True)
|
|
260
260
|
class Foo:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
261
|
+
"""
|
|
262
|
+
This is a test
|
|
263
|
+
"""
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
known_prop: str
|
|
266
266
|
|
|
267
267
|
`,
|
|
268
268
|
);
|
|
@@ -286,12 +286,12 @@ describe("Python Class from model", () => {
|
|
|
286
286
|
|
|
287
287
|
@dataclass(kw_only=True)
|
|
288
288
|
class Foo:
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
"""
|
|
290
|
+
This is a test
|
|
291
|
+
"""
|
|
292
292
|
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
# This is a known property
|
|
294
|
+
known_prop: str
|
|
295
295
|
|
|
296
296
|
`,
|
|
297
297
|
);
|
|
@@ -352,7 +352,7 @@ describe("Python Class from model", () => {
|
|
|
352
352
|
expect(getOutput(program, [<ClassDeclaration type={Foo} />])).toRenderTo(
|
|
353
353
|
`
|
|
354
354
|
class Foo(list[str]):
|
|
355
|
-
|
|
355
|
+
pass
|
|
356
356
|
|
|
357
357
|
`,
|
|
358
358
|
);
|
|
@@ -381,19 +381,19 @@ describe("Python Class from model", () => {
|
|
|
381
381
|
from typing import TYPE_CHECKING
|
|
382
382
|
|
|
383
383
|
if TYPE_CHECKING:
|
|
384
|
-
|
|
384
|
+
from typing import Literal
|
|
385
385
|
|
|
386
386
|
|
|
387
387
|
class Color(StrEnum):
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
RED = "RED"
|
|
389
|
+
BLUE = "BLUE"
|
|
390
390
|
|
|
391
391
|
|
|
392
392
|
@dataclass(kw_only=True)
|
|
393
393
|
class Widget:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
id: str = "123"
|
|
395
|
+
weight: int = 100
|
|
396
|
+
color: Literal[Color.BLUE]
|
|
397
397
|
|
|
398
398
|
`,
|
|
399
399
|
);
|
|
@@ -422,19 +422,19 @@ describe("Python Class from model", () => {
|
|
|
422
422
|
from typing import TYPE_CHECKING
|
|
423
423
|
|
|
424
424
|
if TYPE_CHECKING:
|
|
425
|
-
|
|
425
|
+
from typing import Literal
|
|
426
426
|
|
|
427
427
|
|
|
428
428
|
class Color(StrEnum):
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
RED = "RED"
|
|
430
|
+
BLUE = "BLUE"
|
|
431
|
+
GREEN = "GREEN"
|
|
432
432
|
|
|
433
433
|
|
|
434
434
|
@dataclass(kw_only=True)
|
|
435
435
|
class Widget:
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
id: str
|
|
437
|
+
primary_color: Literal[Color.RED, Color.BLUE]
|
|
438
438
|
|
|
439
439
|
`,
|
|
440
440
|
);
|
|
@@ -454,13 +454,13 @@ describe("Python Class from model", () => {
|
|
|
454
454
|
from typing import TYPE_CHECKING
|
|
455
455
|
|
|
456
456
|
if TYPE_CHECKING:
|
|
457
|
-
|
|
457
|
+
from typing import Literal
|
|
458
458
|
|
|
459
459
|
|
|
460
460
|
@dataclass(kw_only=True)
|
|
461
461
|
class Widget:
|
|
462
|
-
|
|
463
|
-
|
|
462
|
+
id: str
|
|
463
|
+
priority: Literal[1, 2, 3]
|
|
464
464
|
|
|
465
465
|
`,
|
|
466
466
|
);
|
|
@@ -480,13 +480,13 @@ describe("Python Class from model", () => {
|
|
|
480
480
|
from typing import TYPE_CHECKING
|
|
481
481
|
|
|
482
482
|
if TYPE_CHECKING:
|
|
483
|
-
|
|
483
|
+
from typing import Literal
|
|
484
484
|
|
|
485
485
|
|
|
486
486
|
@dataclass(kw_only=True)
|
|
487
487
|
class Widget:
|
|
488
|
-
|
|
489
|
-
|
|
488
|
+
id: str
|
|
489
|
+
is_active_or_enabled: Literal[True, False]
|
|
490
490
|
|
|
491
491
|
`,
|
|
492
492
|
);
|
|
@@ -514,18 +514,18 @@ describe("Python Class from model", () => {
|
|
|
514
514
|
from typing import TYPE_CHECKING
|
|
515
515
|
|
|
516
516
|
if TYPE_CHECKING:
|
|
517
|
-
|
|
517
|
+
from typing import Literal
|
|
518
518
|
|
|
519
519
|
|
|
520
520
|
class Color(StrEnum):
|
|
521
|
-
|
|
522
|
-
|
|
521
|
+
RED = "RED"
|
|
522
|
+
BLUE = "BLUE"
|
|
523
523
|
|
|
524
524
|
|
|
525
525
|
@dataclass(kw_only=True)
|
|
526
526
|
class Widget:
|
|
527
|
-
|
|
528
|
-
|
|
527
|
+
id: str
|
|
528
|
+
mixed_value: Literal["custom", 42, True, Color.RED]
|
|
529
529
|
|
|
530
530
|
`,
|
|
531
531
|
);
|
|
@@ -543,12 +543,12 @@ describe("Python Class from model", () => {
|
|
|
543
543
|
from typing import TYPE_CHECKING
|
|
544
544
|
|
|
545
545
|
if TYPE_CHECKING:
|
|
546
|
-
|
|
546
|
+
from typing import Never
|
|
547
547
|
|
|
548
548
|
|
|
549
549
|
@dataclass(kw_only=True)
|
|
550
550
|
class Widget:
|
|
551
|
-
|
|
551
|
+
property: Never
|
|
552
552
|
|
|
553
553
|
`);
|
|
554
554
|
});
|
|
@@ -568,14 +568,14 @@ describe("Python Class from model", () => {
|
|
|
568
568
|
from typing import TYPE_CHECKING
|
|
569
569
|
|
|
570
570
|
if TYPE_CHECKING:
|
|
571
|
-
|
|
571
|
+
from typing import Literal
|
|
572
572
|
|
|
573
573
|
|
|
574
574
|
@dataclass(kw_only=True)
|
|
575
575
|
class MyOperations:
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
576
|
+
id: str
|
|
577
|
+
weight: int
|
|
578
|
+
color: Literal["blue", "red"]
|
|
579
579
|
|
|
580
580
|
`);
|
|
581
581
|
});
|
|
@@ -603,15 +603,15 @@ describe("Python Class from model", () => {
|
|
|
603
603
|
from typing import TYPE_CHECKING
|
|
604
604
|
|
|
605
605
|
if TYPE_CHECKING:
|
|
606
|
-
|
|
606
|
+
from typing import Literal
|
|
607
607
|
|
|
608
608
|
|
|
609
609
|
@dataclass(kw_only=True)
|
|
610
610
|
class MyOperations:
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
611
|
+
id: str
|
|
612
|
+
weight: int
|
|
613
|
+
color: Literal["blue", "red"]
|
|
614
|
+
custom_property: str
|
|
615
615
|
|
|
616
616
|
`);
|
|
617
617
|
});
|
|
@@ -639,20 +639,20 @@ describe("Python Class from model", () => {
|
|
|
639
639
|
from typing import TYPE_CHECKING
|
|
640
640
|
|
|
641
641
|
if TYPE_CHECKING:
|
|
642
|
-
|
|
642
|
+
from typing import Literal
|
|
643
643
|
|
|
644
644
|
|
|
645
645
|
@dataclass(kw_only=True)
|
|
646
646
|
class Widget:
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
647
|
+
id: str
|
|
648
|
+
weight: int
|
|
649
|
+
color: Literal["blue", "red"]
|
|
650
650
|
|
|
651
651
|
|
|
652
652
|
@dataclass(kw_only=True)
|
|
653
653
|
class ErrorWidget(Widget):
|
|
654
|
-
|
|
655
|
-
|
|
654
|
+
code: int
|
|
655
|
+
message: str
|
|
656
656
|
|
|
657
657
|
`);
|
|
658
658
|
});
|
|
@@ -672,9 +672,9 @@ describe("Python Class from interface", () => {
|
|
|
672
672
|
|
|
673
673
|
|
|
674
674
|
class WidgetOperations(ABC):
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
675
|
+
@abstractmethod
|
|
676
|
+
def get_name(self, id: str) -> str:
|
|
677
|
+
pass
|
|
678
678
|
|
|
679
679
|
|
|
680
680
|
`);
|
|
@@ -705,17 +705,17 @@ describe("Python Class from interface", () => {
|
|
|
705
705
|
|
|
706
706
|
@dataclass(kw_only=True)
|
|
707
707
|
class Foo:
|
|
708
|
-
|
|
708
|
+
name: str
|
|
709
709
|
|
|
710
710
|
|
|
711
711
|
class WidgetOperations(ABC):
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
712
|
+
@abstractmethod
|
|
713
|
+
def get_name(self, foo: Foo) -> str:
|
|
714
|
+
pass
|
|
715
715
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
716
|
+
@abstractmethod
|
|
717
|
+
def get_other_name(self, name: str) -> str:
|
|
718
|
+
pass
|
|
719
719
|
|
|
720
720
|
|
|
721
721
|
`);
|
|
@@ -757,28 +757,28 @@ describe("Python Class from interface", () => {
|
|
|
757
757
|
from typing import TYPE_CHECKING
|
|
758
758
|
|
|
759
759
|
if TYPE_CHECKING:
|
|
760
|
-
|
|
760
|
+
from typing import Literal
|
|
761
761
|
|
|
762
762
|
|
|
763
763
|
class WidgetOperations(ABC):
|
|
764
|
-
"""
|
|
765
|
-
Operations for Widget
|
|
766
|
-
"""
|
|
767
|
-
|
|
768
|
-
@abstractmethod
|
|
769
|
-
def get_name(self, id: str) -> Widget:
|
|
770
764
|
"""
|
|
771
|
-
|
|
765
|
+
Operations for Widget
|
|
772
766
|
"""
|
|
773
|
-
|
|
767
|
+
|
|
768
|
+
@abstractmethod
|
|
769
|
+
def get_name(self, id: str) -> Widget:
|
|
770
|
+
"""
|
|
771
|
+
Get the name of the widget
|
|
772
|
+
"""
|
|
773
|
+
pass
|
|
774
774
|
|
|
775
775
|
|
|
776
776
|
|
|
777
777
|
@dataclass(kw_only=True)
|
|
778
778
|
class Widget:
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
779
|
+
id: str
|
|
780
|
+
weight: int
|
|
781
|
+
color: Literal["blue", "red"]
|
|
782
782
|
|
|
783
783
|
`);
|
|
784
784
|
});
|
|
@@ -814,32 +814,32 @@ describe("Python Class from interface", () => {
|
|
|
814
814
|
from typing import TYPE_CHECKING
|
|
815
815
|
|
|
816
816
|
if TYPE_CHECKING:
|
|
817
|
-
|
|
817
|
+
from typing import Literal
|
|
818
818
|
|
|
819
819
|
|
|
820
820
|
class WidgetOperations(ABC):
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
821
|
+
@abstractmethod
|
|
822
|
+
def get_name(self, id: str) -> Widget:
|
|
823
|
+
pass
|
|
824
824
|
|
|
825
825
|
|
|
826
826
|
|
|
827
827
|
class WidgetOperationsExtended(ABC):
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
828
|
+
@abstractmethod
|
|
829
|
+
def get_name(self, id: str) -> Widget:
|
|
830
|
+
pass
|
|
831
831
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
832
|
+
@abstractmethod
|
|
833
|
+
def delete(self, id: str) -> None:
|
|
834
|
+
pass
|
|
835
835
|
|
|
836
836
|
|
|
837
837
|
|
|
838
838
|
@dataclass(kw_only=True)
|
|
839
839
|
class Widget:
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
840
|
+
id: str
|
|
841
|
+
weight: int
|
|
842
|
+
color: Literal["blue", "red"]
|
|
843
843
|
|
|
844
844
|
`);
|
|
845
845
|
});
|
|
@@ -870,14 +870,14 @@ describe("Python Class overrides", () => {
|
|
|
870
870
|
|
|
871
871
|
@dataclass(kw_only=True)
|
|
872
872
|
class WidgetOperations:
|
|
873
|
-
|
|
874
|
-
|
|
873
|
+
id: str
|
|
874
|
+
weight: int
|
|
875
875
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
876
|
+
def do_work(self) -> None:
|
|
877
|
+
"""
|
|
878
|
+
This is a test
|
|
879
|
+
"""
|
|
880
|
+
pass
|
|
881
881
|
|
|
882
882
|
|
|
883
883
|
`);
|
|
@@ -907,14 +907,14 @@ describe("Python Class overrides", () => {
|
|
|
907
907
|
|
|
908
908
|
@dataclass(kw_only=True)
|
|
909
909
|
class WidgetOperations:
|
|
910
|
-
|
|
911
|
-
|
|
910
|
+
id: str
|
|
911
|
+
weight: int
|
|
912
912
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
913
|
+
def do_work(self) -> None:
|
|
914
|
+
"""
|
|
915
|
+
This is a test
|
|
916
|
+
"""
|
|
917
|
+
pass
|
|
918
918
|
|
|
919
919
|
|
|
920
920
|
`);
|
|
@@ -944,15 +944,15 @@ describe("Python Class overrides", () => {
|
|
|
944
944
|
|
|
945
945
|
@dataclass(kw_only=True)
|
|
946
946
|
class WidgetOperations:
|
|
947
|
-
|
|
948
|
-
|
|
947
|
+
id: str
|
|
948
|
+
weight: int
|
|
949
949
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
950
|
+
@classmethod
|
|
951
|
+
def do_work(cls) -> None:
|
|
952
|
+
"""
|
|
953
|
+
This is a test
|
|
954
|
+
"""
|
|
955
|
+
pass
|
|
956
956
|
|
|
957
957
|
|
|
958
958
|
`);
|
|
@@ -982,15 +982,15 @@ describe("Python Class overrides", () => {
|
|
|
982
982
|
|
|
983
983
|
@dataclass(kw_only=True)
|
|
984
984
|
class WidgetOperations:
|
|
985
|
-
|
|
986
|
-
|
|
985
|
+
id: str
|
|
986
|
+
weight: int
|
|
987
987
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
988
|
+
@staticmethod
|
|
989
|
+
def do_work() -> None:
|
|
990
|
+
"""
|
|
991
|
+
This is a test
|
|
992
|
+
"""
|
|
993
|
+
pass
|
|
994
994
|
|
|
995
995
|
|
|
996
996
|
`);
|
|
@@ -1009,9 +1009,9 @@ describe("Python Class overrides", () => {
|
|
|
1009
1009
|
|
|
1010
1010
|
|
|
1011
1011
|
class WidgetOperations(ABC):
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1012
|
+
@abstractmethod
|
|
1013
|
+
def get_name(self, id: str) -> str:
|
|
1014
|
+
pass
|
|
1015
1015
|
|
|
1016
1016
|
|
|
1017
1017
|
`);
|
|
@@ -1031,9 +1031,9 @@ describe("Python Class overrides", () => {
|
|
|
1031
1031
|
|
|
1032
1032
|
|
|
1033
1033
|
class WidgetOperations(ABC):
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1034
|
+
@abstractmethod
|
|
1035
|
+
def get_name(self, id: str) -> str:
|
|
1036
|
+
pass
|
|
1037
1037
|
|
|
1038
1038
|
|
|
1039
1039
|
`);
|
|
@@ -1053,10 +1053,10 @@ describe("Python Class overrides", () => {
|
|
|
1053
1053
|
|
|
1054
1054
|
|
|
1055
1055
|
class WidgetOperations(ABC):
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1056
|
+
@classmethod
|
|
1057
|
+
@abstractmethod
|
|
1058
|
+
def get_name(cls, id: str) -> str:
|
|
1059
|
+
pass
|
|
1060
1060
|
|
|
1061
1061
|
|
|
1062
1062
|
`);
|
|
@@ -1076,10 +1076,10 @@ describe("Python Class overrides", () => {
|
|
|
1076
1076
|
|
|
1077
1077
|
|
|
1078
1078
|
class WidgetOperations(ABC):
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1079
|
+
@staticmethod
|
|
1080
|
+
@abstractmethod
|
|
1081
|
+
def get_name(id: str) -> str:
|
|
1082
|
+
pass
|
|
1083
1083
|
|
|
1084
1084
|
|
|
1085
1085
|
`);
|
|
@@ -1104,8 +1104,8 @@ describe("Python Class overrides", () => {
|
|
|
1104
1104
|
|
|
1105
1105
|
@dataclass(kw_only=True)
|
|
1106
1106
|
class StringResponse:
|
|
1107
|
-
|
|
1108
|
-
|
|
1107
|
+
data: str
|
|
1108
|
+
status: str
|
|
1109
1109
|
|
|
1110
1110
|
`);
|
|
1111
1111
|
});
|
|
@@ -1134,14 +1134,14 @@ describe("Python Class overrides", () => {
|
|
|
1134
1134
|
|
|
1135
1135
|
@dataclass(kw_only=True)
|
|
1136
1136
|
class StringResult:
|
|
1137
|
-
|
|
1138
|
-
|
|
1137
|
+
value: str
|
|
1138
|
+
error: str
|
|
1139
1139
|
|
|
1140
1140
|
|
|
1141
1141
|
@dataclass(kw_only=True)
|
|
1142
1142
|
class IntResult:
|
|
1143
|
-
|
|
1144
|
-
|
|
1143
|
+
value: int
|
|
1144
|
+
error: str
|
|
1145
1145
|
|
|
1146
1146
|
`);
|
|
1147
1147
|
});
|
|
@@ -1164,8 +1164,8 @@ describe("Python Class overrides", () => {
|
|
|
1164
1164
|
|
|
1165
1165
|
@dataclass(kw_only=True)
|
|
1166
1166
|
class StringResponse:
|
|
1167
|
-
|
|
1168
|
-
|
|
1167
|
+
data: str
|
|
1168
|
+
status: str
|
|
1169
1169
|
|
|
1170
1170
|
`);
|
|
1171
1171
|
});
|
|
@@ -1190,17 +1190,17 @@ describe("Python Class overrides", () => {
|
|
|
1190
1190
|
|
|
1191
1191
|
|
|
1192
1192
|
class StringRepository(ABC):
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1193
|
+
@abstractmethod
|
|
1194
|
+
def get(self, id: str) -> str:
|
|
1195
|
+
pass
|
|
1196
1196
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1197
|
+
@abstractmethod
|
|
1198
|
+
def list(self) -> list[str]:
|
|
1199
|
+
pass
|
|
1200
1200
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1201
|
+
@abstractmethod
|
|
1202
|
+
def find_by_prefix(self, prefix: str) -> list[str]:
|
|
1203
|
+
pass
|
|
1204
1204
|
|
|
1205
1205
|
|
|
1206
1206
|
`);
|
|
@@ -1234,24 +1234,24 @@ describe("Python Class overrides", () => {
|
|
|
1234
1234
|
|
|
1235
1235
|
|
|
1236
1236
|
class UserRepository(ABC):
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1237
|
+
@abstractmethod
|
|
1238
|
+
def get(self, id: str) -> str:
|
|
1239
|
+
pass
|
|
1240
1240
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1241
|
+
@abstractmethod
|
|
1242
|
+
def find_by_email(self, email: str) -> str:
|
|
1243
|
+
pass
|
|
1244
1244
|
|
|
1245
1245
|
|
|
1246
1246
|
|
|
1247
1247
|
class ProductRepository(ABC):
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1248
|
+
@abstractmethod
|
|
1249
|
+
def get(self, id: str) -> int:
|
|
1250
|
+
pass
|
|
1251
1251
|
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1252
|
+
@abstractmethod
|
|
1253
|
+
def find_by_category(self, category: str) -> list[int]:
|
|
1254
|
+
pass
|
|
1255
1255
|
|
|
1256
1256
|
|
|
1257
1257
|
`);
|
|
@@ -1275,14 +1275,14 @@ describe("Python Class overrides", () => {
|
|
|
1275
1275
|
from typing import TYPE_CHECKING
|
|
1276
1276
|
|
|
1277
1277
|
if TYPE_CHECKING:
|
|
1278
|
-
|
|
1278
|
+
from typing import Never
|
|
1279
1279
|
|
|
1280
1280
|
|
|
1281
1281
|
@dataclass(kw_only=True)
|
|
1282
1282
|
class CanadaAddress:
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1283
|
+
state: Never
|
|
1284
|
+
city: str
|
|
1285
|
+
street: str
|
|
1286
1286
|
|
|
1287
1287
|
`);
|
|
1288
1288
|
});
|
|
@@ -1306,8 +1306,8 @@ describe("Python Class overrides", () => {
|
|
|
1306
1306
|
|
|
1307
1307
|
@dataclass(kw_only=True)
|
|
1308
1308
|
class StringContainer:
|
|
1309
|
-
|
|
1310
|
-
|
|
1309
|
+
value: str
|
|
1310
|
+
label: str
|
|
1311
1311
|
|
|
1312
1312
|
`);
|
|
1313
1313
|
});
|
|
@@ -1330,8 +1330,8 @@ describe("Python Class overrides", () => {
|
|
|
1330
1330
|
|
|
1331
1331
|
@dataclass(kw_only=True)
|
|
1332
1332
|
class MyResult:
|
|
1333
|
-
|
|
1334
|
-
|
|
1333
|
+
value: str
|
|
1334
|
+
error: int
|
|
1335
1335
|
|
|
1336
1336
|
`);
|
|
1337
1337
|
});
|
|
@@ -1359,12 +1359,12 @@ describe("Python Class overrides", () => {
|
|
|
1359
1359
|
|
|
1360
1360
|
@dataclass(kw_only=True)
|
|
1361
1361
|
class Address:
|
|
1362
|
-
|
|
1362
|
+
city: str
|
|
1363
1363
|
|
|
1364
1364
|
|
|
1365
1365
|
@dataclass(kw_only=True)
|
|
1366
1366
|
class CanadaAddress(Address):
|
|
1367
|
-
|
|
1367
|
+
street: str
|
|
1368
1368
|
|
|
1369
1369
|
`);
|
|
1370
1370
|
});
|
|
@@ -1394,13 +1394,13 @@ describe("Python Class overrides", () => {
|
|
|
1394
1394
|
|
|
1395
1395
|
@dataclass(kw_only=True)
|
|
1396
1396
|
class Response:
|
|
1397
|
-
|
|
1398
|
-
|
|
1397
|
+
data: str
|
|
1398
|
+
status: str
|
|
1399
1399
|
|
|
1400
1400
|
|
|
1401
1401
|
@dataclass(kw_only=True)
|
|
1402
1402
|
class ConcreteResponse(Response):
|
|
1403
|
-
|
|
1403
|
+
timestamp: str
|
|
1404
1404
|
|
|
1405
1405
|
`);
|
|
1406
1406
|
});
|
|
@@ -1426,14 +1426,14 @@ describe("Python Class overrides", () => {
|
|
|
1426
1426
|
from typing import TYPE_CHECKING
|
|
1427
1427
|
|
|
1428
1428
|
if TYPE_CHECKING:
|
|
1429
|
-
|
|
1429
|
+
from typing import Never
|
|
1430
1430
|
|
|
1431
1431
|
|
|
1432
1432
|
@dataclass(kw_only=True)
|
|
1433
1433
|
class CanadaAddress:
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1434
|
+
state: Never
|
|
1435
|
+
city: str
|
|
1436
|
+
street: str
|
|
1437
1437
|
|
|
1438
1438
|
`);
|
|
1439
1439
|
});
|
|
@@ -1454,8 +1454,8 @@ describe("Python Class overrides", () => {
|
|
|
1454
1454
|
|
|
1455
1455
|
@dataclass(kw_only=True)
|
|
1456
1456
|
class BaseEntity(ABC):
|
|
1457
|
-
|
|
1458
|
-
|
|
1457
|
+
id: str
|
|
1458
|
+
created_at: str
|
|
1459
1459
|
|
|
1460
1460
|
`);
|
|
1461
1461
|
});
|