@typespec/emitter-framework 0.18.0 → 0.18.1-dev.1
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 +14 -13
- package/package.json.bak +4 -3
- 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
|
@@ -38,24 +38,24 @@ describe("Python Class from model", () => {
|
|
|
38
38
|
from typing import TYPE_CHECKING
|
|
39
39
|
|
|
40
40
|
if TYPE_CHECKING:
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
from typing import Literal
|
|
42
|
+
from typing import Optional
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
@dataclass(kw_only=True)
|
|
46
46
|
class Widget:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
id: str
|
|
48
|
+
weight: int
|
|
49
|
+
aliases: list[str]
|
|
50
|
+
is_active: bool
|
|
51
|
+
color: Literal["blue", "red"]
|
|
52
|
+
promotional_price: float
|
|
53
|
+
description: Optional[str] = "This is a widget"
|
|
54
|
+
created_at: int = 1717334400
|
|
55
|
+
tags: list[str] = ["tag1", "tag2"]
|
|
56
|
+
is_deleted: bool = False
|
|
57
|
+
alternative_color: Literal["green", "yellow"] = "green"
|
|
58
|
+
price: float = 100.0
|
|
59
59
|
|
|
60
60
|
`);
|
|
61
61
|
});
|
|
@@ -77,13 +77,13 @@ describe("Python Class from model", () => {
|
|
|
77
77
|
from typing import TYPE_CHECKING
|
|
78
78
|
|
|
79
79
|
if TYPE_CHECKING:
|
|
80
|
-
|
|
80
|
+
from typing import Optional
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
@dataclass(kw_only=True)
|
|
84
84
|
class Widget:
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
id: str
|
|
86
|
+
description: Optional[str] = "This is a widget"
|
|
87
87
|
|
|
88
88
|
`);
|
|
89
89
|
});
|
|
@@ -105,13 +105,13 @@ describe("Python Class from model", () => {
|
|
|
105
105
|
from typing import TYPE_CHECKING
|
|
106
106
|
|
|
107
107
|
if TYPE_CHECKING:
|
|
108
|
-
|
|
108
|
+
from typing import Optional
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
@dataclass(kw_only=True)
|
|
112
112
|
class Widget:
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
description: Optional[str] = "This is a widget"
|
|
114
|
+
id: str
|
|
115
115
|
|
|
116
116
|
`);
|
|
117
117
|
});
|
|
@@ -136,12 +136,12 @@ describe("Python Class from model", () => {
|
|
|
136
136
|
|
|
137
137
|
@dataclass(kw_only=True)
|
|
138
138
|
class Foo:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
"""
|
|
140
|
+
This is a test
|
|
141
|
+
with multiple lines
|
|
142
|
+
"""
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
known_prop: str
|
|
145
145
|
|
|
146
146
|
`);
|
|
147
147
|
});
|
|
@@ -167,12 +167,12 @@ describe("Python Class from model", () => {
|
|
|
167
167
|
|
|
168
168
|
@dataclass(kw_only=True)
|
|
169
169
|
class Foo:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
"""
|
|
171
|
+
This is an overridden doc comment
|
|
172
|
+
with multiple lines
|
|
173
|
+
"""
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
known_prop: str
|
|
176
176
|
|
|
177
177
|
`);
|
|
178
178
|
});
|
|
@@ -197,13 +197,13 @@ describe("Python Class from model", () => {
|
|
|
197
197
|
|
|
198
198
|
@dataclass(kw_only=True)
|
|
199
199
|
class Foo:
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
"""
|
|
201
|
+
First paragraph
|
|
202
202
|
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
Second paragraph
|
|
204
|
+
"""
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
known_prop: str
|
|
207
207
|
|
|
208
208
|
`);
|
|
209
209
|
});
|
|
@@ -234,13 +234,13 @@ describe("Python Class from model", () => {
|
|
|
234
234
|
|
|
235
235
|
@dataclass(kw_only=True)
|
|
236
236
|
class Foo:
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
"""
|
|
238
|
+
Alpha
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
Beta
|
|
241
|
+
"""
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
known_prop: str
|
|
244
244
|
|
|
245
245
|
`);
|
|
246
246
|
});
|
|
@@ -262,11 +262,11 @@ describe("Python Class from model", () => {
|
|
|
262
262
|
|
|
263
263
|
@dataclass(kw_only=True)
|
|
264
264
|
class Foo:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
"""
|
|
266
|
+
This is a test
|
|
267
|
+
"""
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
known_prop: str
|
|
270
270
|
|
|
271
271
|
`);
|
|
272
272
|
});
|
|
@@ -291,12 +291,12 @@ describe("Python Class from model", () => {
|
|
|
291
291
|
|
|
292
292
|
@dataclass(kw_only=True)
|
|
293
293
|
class Foo:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
"""
|
|
295
|
+
This is a test
|
|
296
|
+
"""
|
|
297
297
|
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
# This is a known property
|
|
299
|
+
known_prop: str
|
|
300
300
|
|
|
301
301
|
`);
|
|
302
302
|
});
|
|
@@ -370,7 +370,7 @@ describe("Python Class from model", () => {
|
|
|
370
370
|
type: Foo
|
|
371
371
|
})])).toRenderTo(`
|
|
372
372
|
class Foo(list[str]):
|
|
373
|
-
|
|
373
|
+
pass
|
|
374
374
|
|
|
375
375
|
`);
|
|
376
376
|
});
|
|
@@ -401,19 +401,19 @@ describe("Python Class from model", () => {
|
|
|
401
401
|
from typing import TYPE_CHECKING
|
|
402
402
|
|
|
403
403
|
if TYPE_CHECKING:
|
|
404
|
-
|
|
404
|
+
from typing import Literal
|
|
405
405
|
|
|
406
406
|
|
|
407
407
|
class Color(StrEnum):
|
|
408
|
-
|
|
409
|
-
|
|
408
|
+
RED = "RED"
|
|
409
|
+
BLUE = "BLUE"
|
|
410
410
|
|
|
411
411
|
|
|
412
412
|
@dataclass(kw_only=True)
|
|
413
413
|
class Widget:
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
id: str = "123"
|
|
415
|
+
weight: int = 100
|
|
416
|
+
color: Literal[Color.BLUE]
|
|
417
417
|
|
|
418
418
|
`);
|
|
419
419
|
});
|
|
@@ -444,19 +444,19 @@ describe("Python Class from model", () => {
|
|
|
444
444
|
from typing import TYPE_CHECKING
|
|
445
445
|
|
|
446
446
|
if TYPE_CHECKING:
|
|
447
|
-
|
|
447
|
+
from typing import Literal
|
|
448
448
|
|
|
449
449
|
|
|
450
450
|
class Color(StrEnum):
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
RED = "RED"
|
|
452
|
+
BLUE = "BLUE"
|
|
453
|
+
GREEN = "GREEN"
|
|
454
454
|
|
|
455
455
|
|
|
456
456
|
@dataclass(kw_only=True)
|
|
457
457
|
class Widget:
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
id: str
|
|
459
|
+
primary_color: Literal[Color.RED, Color.BLUE]
|
|
460
460
|
|
|
461
461
|
`);
|
|
462
462
|
});
|
|
@@ -477,13 +477,13 @@ describe("Python Class from model", () => {
|
|
|
477
477
|
from typing import TYPE_CHECKING
|
|
478
478
|
|
|
479
479
|
if TYPE_CHECKING:
|
|
480
|
-
|
|
480
|
+
from typing import Literal
|
|
481
481
|
|
|
482
482
|
|
|
483
483
|
@dataclass(kw_only=True)
|
|
484
484
|
class Widget:
|
|
485
|
-
|
|
486
|
-
|
|
485
|
+
id: str
|
|
486
|
+
priority: Literal[1, 2, 3]
|
|
487
487
|
|
|
488
488
|
`);
|
|
489
489
|
});
|
|
@@ -504,13 +504,13 @@ describe("Python Class from model", () => {
|
|
|
504
504
|
from typing import TYPE_CHECKING
|
|
505
505
|
|
|
506
506
|
if TYPE_CHECKING:
|
|
507
|
-
|
|
507
|
+
from typing import Literal
|
|
508
508
|
|
|
509
509
|
|
|
510
510
|
@dataclass(kw_only=True)
|
|
511
511
|
class Widget:
|
|
512
|
-
|
|
513
|
-
|
|
512
|
+
id: str
|
|
513
|
+
is_active_or_enabled: Literal[True, False]
|
|
514
514
|
|
|
515
515
|
`);
|
|
516
516
|
});
|
|
@@ -540,18 +540,18 @@ describe("Python Class from model", () => {
|
|
|
540
540
|
from typing import TYPE_CHECKING
|
|
541
541
|
|
|
542
542
|
if TYPE_CHECKING:
|
|
543
|
-
|
|
543
|
+
from typing import Literal
|
|
544
544
|
|
|
545
545
|
|
|
546
546
|
class Color(StrEnum):
|
|
547
|
-
|
|
548
|
-
|
|
547
|
+
RED = "RED"
|
|
548
|
+
BLUE = "BLUE"
|
|
549
549
|
|
|
550
550
|
|
|
551
551
|
@dataclass(kw_only=True)
|
|
552
552
|
class Widget:
|
|
553
|
-
|
|
554
|
-
|
|
553
|
+
id: str
|
|
554
|
+
mixed_value: Literal["custom", 42, True, Color.RED]
|
|
555
555
|
|
|
556
556
|
`);
|
|
557
557
|
});
|
|
@@ -571,12 +571,12 @@ describe("Python Class from model", () => {
|
|
|
571
571
|
from typing import TYPE_CHECKING
|
|
572
572
|
|
|
573
573
|
if TYPE_CHECKING:
|
|
574
|
-
|
|
574
|
+
from typing import Never
|
|
575
575
|
|
|
576
576
|
|
|
577
577
|
@dataclass(kw_only=True)
|
|
578
578
|
class Widget:
|
|
579
|
-
|
|
579
|
+
property: Never
|
|
580
580
|
|
|
581
581
|
`);
|
|
582
582
|
});
|
|
@@ -599,14 +599,14 @@ describe("Python Class from model", () => {
|
|
|
599
599
|
from typing import TYPE_CHECKING
|
|
600
600
|
|
|
601
601
|
if TYPE_CHECKING:
|
|
602
|
-
|
|
602
|
+
from typing import Literal
|
|
603
603
|
|
|
604
604
|
|
|
605
605
|
@dataclass(kw_only=True)
|
|
606
606
|
class MyOperations:
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
607
|
+
id: str
|
|
608
|
+
weight: int
|
|
609
|
+
color: Literal["blue", "red"]
|
|
610
610
|
|
|
611
611
|
`);
|
|
612
612
|
});
|
|
@@ -636,15 +636,15 @@ describe("Python Class from model", () => {
|
|
|
636
636
|
from typing import TYPE_CHECKING
|
|
637
637
|
|
|
638
638
|
if TYPE_CHECKING:
|
|
639
|
-
|
|
639
|
+
from typing import Literal
|
|
640
640
|
|
|
641
641
|
|
|
642
642
|
@dataclass(kw_only=True)
|
|
643
643
|
class MyOperations:
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
644
|
+
id: str
|
|
645
|
+
weight: int
|
|
646
|
+
color: Literal["blue", "red"]
|
|
647
|
+
custom_property: str
|
|
648
648
|
|
|
649
649
|
`);
|
|
650
650
|
});
|
|
@@ -674,20 +674,20 @@ describe("Python Class from model", () => {
|
|
|
674
674
|
from typing import TYPE_CHECKING
|
|
675
675
|
|
|
676
676
|
if TYPE_CHECKING:
|
|
677
|
-
|
|
677
|
+
from typing import Literal
|
|
678
678
|
|
|
679
679
|
|
|
680
680
|
@dataclass(kw_only=True)
|
|
681
681
|
class Widget:
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
682
|
+
id: str
|
|
683
|
+
weight: int
|
|
684
|
+
color: Literal["blue", "red"]
|
|
685
685
|
|
|
686
686
|
|
|
687
687
|
@dataclass(kw_only=True)
|
|
688
688
|
class ErrorWidget(Widget):
|
|
689
|
-
|
|
690
|
-
|
|
689
|
+
code: int
|
|
690
|
+
message: str
|
|
691
691
|
|
|
692
692
|
`);
|
|
693
693
|
});
|
|
@@ -710,9 +710,9 @@ describe("Python Class from interface", () => {
|
|
|
710
710
|
|
|
711
711
|
|
|
712
712
|
class WidgetOperations(ABC):
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
713
|
+
@abstractmethod
|
|
714
|
+
def get_name(self, id: str) -> str:
|
|
715
|
+
pass
|
|
716
716
|
|
|
717
717
|
|
|
718
718
|
`);
|
|
@@ -744,17 +744,17 @@ describe("Python Class from interface", () => {
|
|
|
744
744
|
|
|
745
745
|
@dataclass(kw_only=True)
|
|
746
746
|
class Foo:
|
|
747
|
-
|
|
747
|
+
name: str
|
|
748
748
|
|
|
749
749
|
|
|
750
750
|
class WidgetOperations(ABC):
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
751
|
+
@abstractmethod
|
|
752
|
+
def get_name(self, foo: Foo) -> str:
|
|
753
|
+
pass
|
|
754
754
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
755
|
+
@abstractmethod
|
|
756
|
+
def get_other_name(self, name: str) -> str:
|
|
757
|
+
pass
|
|
758
758
|
|
|
759
759
|
|
|
760
760
|
`);
|
|
@@ -797,28 +797,28 @@ describe("Python Class from interface", () => {
|
|
|
797
797
|
from typing import TYPE_CHECKING
|
|
798
798
|
|
|
799
799
|
if TYPE_CHECKING:
|
|
800
|
-
|
|
800
|
+
from typing import Literal
|
|
801
801
|
|
|
802
802
|
|
|
803
803
|
class WidgetOperations(ABC):
|
|
804
|
-
"""
|
|
805
|
-
Operations for Widget
|
|
806
|
-
"""
|
|
807
|
-
|
|
808
|
-
@abstractmethod
|
|
809
|
-
def get_name(self, id: str) -> Widget:
|
|
810
804
|
"""
|
|
811
|
-
|
|
805
|
+
Operations for Widget
|
|
812
806
|
"""
|
|
813
|
-
|
|
807
|
+
|
|
808
|
+
@abstractmethod
|
|
809
|
+
def get_name(self, id: str) -> Widget:
|
|
810
|
+
"""
|
|
811
|
+
Get the name of the widget
|
|
812
|
+
"""
|
|
813
|
+
pass
|
|
814
814
|
|
|
815
815
|
|
|
816
816
|
|
|
817
817
|
@dataclass(kw_only=True)
|
|
818
818
|
class Widget:
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
819
|
+
id: str
|
|
820
|
+
weight: int
|
|
821
|
+
color: Literal["blue", "red"]
|
|
822
822
|
|
|
823
823
|
`);
|
|
824
824
|
});
|
|
@@ -856,32 +856,32 @@ describe("Python Class from interface", () => {
|
|
|
856
856
|
from typing import TYPE_CHECKING
|
|
857
857
|
|
|
858
858
|
if TYPE_CHECKING:
|
|
859
|
-
|
|
859
|
+
from typing import Literal
|
|
860
860
|
|
|
861
861
|
|
|
862
862
|
class WidgetOperations(ABC):
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
863
|
+
@abstractmethod
|
|
864
|
+
def get_name(self, id: str) -> Widget:
|
|
865
|
+
pass
|
|
866
866
|
|
|
867
867
|
|
|
868
868
|
|
|
869
869
|
class WidgetOperationsExtended(ABC):
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
870
|
+
@abstractmethod
|
|
871
|
+
def get_name(self, id: str) -> Widget:
|
|
872
|
+
pass
|
|
873
873
|
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
874
|
+
@abstractmethod
|
|
875
|
+
def delete(self, id: str) -> None:
|
|
876
|
+
pass
|
|
877
877
|
|
|
878
878
|
|
|
879
879
|
|
|
880
880
|
@dataclass(kw_only=True)
|
|
881
881
|
class Widget:
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
882
|
+
id: str
|
|
883
|
+
weight: int
|
|
884
|
+
color: Literal["blue", "red"]
|
|
885
885
|
|
|
886
886
|
`);
|
|
887
887
|
});
|
|
@@ -916,14 +916,14 @@ describe("Python Class overrides", () => {
|
|
|
916
916
|
|
|
917
917
|
@dataclass(kw_only=True)
|
|
918
918
|
class WidgetOperations:
|
|
919
|
-
|
|
920
|
-
|
|
919
|
+
id: str
|
|
920
|
+
weight: int
|
|
921
921
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
922
|
+
def do_work(self) -> None:
|
|
923
|
+
"""
|
|
924
|
+
This is a test
|
|
925
|
+
"""
|
|
926
|
+
pass
|
|
927
927
|
|
|
928
928
|
|
|
929
929
|
`);
|
|
@@ -958,14 +958,14 @@ describe("Python Class overrides", () => {
|
|
|
958
958
|
|
|
959
959
|
@dataclass(kw_only=True)
|
|
960
960
|
class WidgetOperations:
|
|
961
|
-
|
|
962
|
-
|
|
961
|
+
id: str
|
|
962
|
+
weight: int
|
|
963
963
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
964
|
+
def do_work(self) -> None:
|
|
965
|
+
"""
|
|
966
|
+
This is a test
|
|
967
|
+
"""
|
|
968
|
+
pass
|
|
969
969
|
|
|
970
970
|
|
|
971
971
|
`);
|
|
@@ -1000,15 +1000,15 @@ describe("Python Class overrides", () => {
|
|
|
1000
1000
|
|
|
1001
1001
|
@dataclass(kw_only=True)
|
|
1002
1002
|
class WidgetOperations:
|
|
1003
|
-
|
|
1004
|
-
|
|
1003
|
+
id: str
|
|
1004
|
+
weight: int
|
|
1005
1005
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1006
|
+
@classmethod
|
|
1007
|
+
def do_work(cls) -> None:
|
|
1008
|
+
"""
|
|
1009
|
+
This is a test
|
|
1010
|
+
"""
|
|
1011
|
+
pass
|
|
1012
1012
|
|
|
1013
1013
|
|
|
1014
1014
|
`);
|
|
@@ -1043,15 +1043,15 @@ describe("Python Class overrides", () => {
|
|
|
1043
1043
|
|
|
1044
1044
|
@dataclass(kw_only=True)
|
|
1045
1045
|
class WidgetOperations:
|
|
1046
|
-
|
|
1047
|
-
|
|
1046
|
+
id: str
|
|
1047
|
+
weight: int
|
|
1048
1048
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1049
|
+
@staticmethod
|
|
1050
|
+
def do_work() -> None:
|
|
1051
|
+
"""
|
|
1052
|
+
This is a test
|
|
1053
|
+
"""
|
|
1054
|
+
pass
|
|
1055
1055
|
|
|
1056
1056
|
|
|
1057
1057
|
`);
|
|
@@ -1073,9 +1073,9 @@ describe("Python Class overrides", () => {
|
|
|
1073
1073
|
|
|
1074
1074
|
|
|
1075
1075
|
class WidgetOperations(ABC):
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1076
|
+
@abstractmethod
|
|
1077
|
+
def get_name(self, id: str) -> str:
|
|
1078
|
+
pass
|
|
1079
1079
|
|
|
1080
1080
|
|
|
1081
1081
|
`);
|
|
@@ -1098,9 +1098,9 @@ describe("Python Class overrides", () => {
|
|
|
1098
1098
|
|
|
1099
1099
|
|
|
1100
1100
|
class WidgetOperations(ABC):
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1101
|
+
@abstractmethod
|
|
1102
|
+
def get_name(self, id: str) -> str:
|
|
1103
|
+
pass
|
|
1104
1104
|
|
|
1105
1105
|
|
|
1106
1106
|
`);
|
|
@@ -1123,10 +1123,10 @@ describe("Python Class overrides", () => {
|
|
|
1123
1123
|
|
|
1124
1124
|
|
|
1125
1125
|
class WidgetOperations(ABC):
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1126
|
+
@classmethod
|
|
1127
|
+
@abstractmethod
|
|
1128
|
+
def get_name(cls, id: str) -> str:
|
|
1129
|
+
pass
|
|
1130
1130
|
|
|
1131
1131
|
|
|
1132
1132
|
`);
|
|
@@ -1149,10 +1149,10 @@ describe("Python Class overrides", () => {
|
|
|
1149
1149
|
|
|
1150
1150
|
|
|
1151
1151
|
class WidgetOperations(ABC):
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1152
|
+
@staticmethod
|
|
1153
|
+
@abstractmethod
|
|
1154
|
+
def get_name(id: str) -> str:
|
|
1155
|
+
pass
|
|
1156
1156
|
|
|
1157
1157
|
|
|
1158
1158
|
`);
|
|
@@ -1181,8 +1181,8 @@ describe("Python Class overrides", () => {
|
|
|
1181
1181
|
|
|
1182
1182
|
@dataclass(kw_only=True)
|
|
1183
1183
|
class StringResponse:
|
|
1184
|
-
|
|
1185
|
-
|
|
1184
|
+
data: str
|
|
1185
|
+
status: str
|
|
1186
1186
|
|
|
1187
1187
|
`);
|
|
1188
1188
|
});
|
|
@@ -1213,14 +1213,14 @@ describe("Python Class overrides", () => {
|
|
|
1213
1213
|
|
|
1214
1214
|
@dataclass(kw_only=True)
|
|
1215
1215
|
class StringResult:
|
|
1216
|
-
|
|
1217
|
-
|
|
1216
|
+
value: str
|
|
1217
|
+
error: str
|
|
1218
1218
|
|
|
1219
1219
|
|
|
1220
1220
|
@dataclass(kw_only=True)
|
|
1221
1221
|
class IntResult:
|
|
1222
|
-
|
|
1223
|
-
|
|
1222
|
+
value: int
|
|
1223
|
+
error: str
|
|
1224
1224
|
|
|
1225
1225
|
`);
|
|
1226
1226
|
});
|
|
@@ -1247,8 +1247,8 @@ describe("Python Class overrides", () => {
|
|
|
1247
1247
|
|
|
1248
1248
|
@dataclass(kw_only=True)
|
|
1249
1249
|
class StringResponse:
|
|
1250
|
-
|
|
1251
|
-
|
|
1250
|
+
data: str
|
|
1251
|
+
status: str
|
|
1252
1252
|
|
|
1253
1253
|
`);
|
|
1254
1254
|
});
|
|
@@ -1277,17 +1277,17 @@ describe("Python Class overrides", () => {
|
|
|
1277
1277
|
|
|
1278
1278
|
|
|
1279
1279
|
class StringRepository(ABC):
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1280
|
+
@abstractmethod
|
|
1281
|
+
def get(self, id: str) -> str:
|
|
1282
|
+
pass
|
|
1283
1283
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1284
|
+
@abstractmethod
|
|
1285
|
+
def list(self) -> list[str]:
|
|
1286
|
+
pass
|
|
1287
1287
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1288
|
+
@abstractmethod
|
|
1289
|
+
def find_by_prefix(self, prefix: str) -> list[str]:
|
|
1290
|
+
pass
|
|
1291
1291
|
|
|
1292
1292
|
|
|
1293
1293
|
`);
|
|
@@ -1323,24 +1323,24 @@ describe("Python Class overrides", () => {
|
|
|
1323
1323
|
|
|
1324
1324
|
|
|
1325
1325
|
class UserRepository(ABC):
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1326
|
+
@abstractmethod
|
|
1327
|
+
def get(self, id: str) -> str:
|
|
1328
|
+
pass
|
|
1329
1329
|
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1330
|
+
@abstractmethod
|
|
1331
|
+
def find_by_email(self, email: str) -> str:
|
|
1332
|
+
pass
|
|
1333
1333
|
|
|
1334
1334
|
|
|
1335
1335
|
|
|
1336
1336
|
class ProductRepository(ABC):
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1337
|
+
@abstractmethod
|
|
1338
|
+
def get(self, id: str) -> int:
|
|
1339
|
+
pass
|
|
1340
1340
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1341
|
+
@abstractmethod
|
|
1342
|
+
def find_by_category(self, category: str) -> list[int]:
|
|
1343
|
+
pass
|
|
1344
1344
|
|
|
1345
1345
|
|
|
1346
1346
|
`);
|
|
@@ -1368,14 +1368,14 @@ describe("Python Class overrides", () => {
|
|
|
1368
1368
|
from typing import TYPE_CHECKING
|
|
1369
1369
|
|
|
1370
1370
|
if TYPE_CHECKING:
|
|
1371
|
-
|
|
1371
|
+
from typing import Never
|
|
1372
1372
|
|
|
1373
1373
|
|
|
1374
1374
|
@dataclass(kw_only=True)
|
|
1375
1375
|
class CanadaAddress:
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1376
|
+
state: Never
|
|
1377
|
+
city: str
|
|
1378
|
+
street: str
|
|
1379
1379
|
|
|
1380
1380
|
`);
|
|
1381
1381
|
});
|
|
@@ -1403,8 +1403,8 @@ describe("Python Class overrides", () => {
|
|
|
1403
1403
|
|
|
1404
1404
|
@dataclass(kw_only=True)
|
|
1405
1405
|
class StringContainer:
|
|
1406
|
-
|
|
1407
|
-
|
|
1406
|
+
value: str
|
|
1407
|
+
label: str
|
|
1408
1408
|
|
|
1409
1409
|
`);
|
|
1410
1410
|
});
|
|
@@ -1431,8 +1431,8 @@ describe("Python Class overrides", () => {
|
|
|
1431
1431
|
|
|
1432
1432
|
@dataclass(kw_only=True)
|
|
1433
1433
|
class MyResult:
|
|
1434
|
-
|
|
1435
|
-
|
|
1434
|
+
value: str
|
|
1435
|
+
error: int
|
|
1436
1436
|
|
|
1437
1437
|
`);
|
|
1438
1438
|
});
|
|
@@ -1462,12 +1462,12 @@ describe("Python Class overrides", () => {
|
|
|
1462
1462
|
|
|
1463
1463
|
@dataclass(kw_only=True)
|
|
1464
1464
|
class Address:
|
|
1465
|
-
|
|
1465
|
+
city: str
|
|
1466
1466
|
|
|
1467
1467
|
|
|
1468
1468
|
@dataclass(kw_only=True)
|
|
1469
1469
|
class CanadaAddress(Address):
|
|
1470
|
-
|
|
1470
|
+
street: str
|
|
1471
1471
|
|
|
1472
1472
|
`);
|
|
1473
1473
|
});
|
|
@@ -1499,13 +1499,13 @@ describe("Python Class overrides", () => {
|
|
|
1499
1499
|
|
|
1500
1500
|
@dataclass(kw_only=True)
|
|
1501
1501
|
class Response:
|
|
1502
|
-
|
|
1503
|
-
|
|
1502
|
+
data: str
|
|
1503
|
+
status: str
|
|
1504
1504
|
|
|
1505
1505
|
|
|
1506
1506
|
@dataclass(kw_only=True)
|
|
1507
1507
|
class ConcreteResponse(Response):
|
|
1508
|
-
|
|
1508
|
+
timestamp: str
|
|
1509
1509
|
|
|
1510
1510
|
`);
|
|
1511
1511
|
});
|
|
@@ -1535,14 +1535,14 @@ describe("Python Class overrides", () => {
|
|
|
1535
1535
|
from typing import TYPE_CHECKING
|
|
1536
1536
|
|
|
1537
1537
|
if TYPE_CHECKING:
|
|
1538
|
-
|
|
1538
|
+
from typing import Never
|
|
1539
1539
|
|
|
1540
1540
|
|
|
1541
1541
|
@dataclass(kw_only=True)
|
|
1542
1542
|
class CanadaAddress:
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1543
|
+
state: Never
|
|
1544
|
+
city: str
|
|
1545
|
+
street: str
|
|
1546
1546
|
|
|
1547
1547
|
`);
|
|
1548
1548
|
});
|
|
@@ -1566,8 +1566,8 @@ describe("Python Class overrides", () => {
|
|
|
1566
1566
|
|
|
1567
1567
|
@dataclass(kw_only=True)
|
|
1568
1568
|
class BaseEntity(ABC):
|
|
1569
|
-
|
|
1570
|
-
|
|
1569
|
+
id: str
|
|
1570
|
+
created_at: str
|
|
1571
1571
|
|
|
1572
1572
|
`);
|
|
1573
1573
|
});
|