File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ def serialize(self) -> JsonDict:
7272 'line' : self .line ,
7373 'column' : self .column ,
7474 'type' : self .type .serialize (),
75+ 'kw_only' : self .kw_only ,
7576 }
7677
7778 @classmethod
@@ -335,6 +336,7 @@ def collect_attributes(self) -> Optional[List[DataclassAttribute]]:
335336 super_attrs .append (attr )
336337 break
337338 all_attrs = super_attrs + all_attrs
339+ all_attrs .sort (key = lambda a : a .kw_only )
338340
339341 # Ensure that arguments without a default don't follow
340342 # arguments that have a default.
Original file line number Diff line number Diff line change @@ -368,6 +368,24 @@ class Application:
368368
369369[builtins fixtures/list.pyi]
370370
371+ [case testDataclassesOrderingKwOnlyWithSentinelAndSubclass]
372+ # flags: --python-version 3.10
373+ from dataclasses import dataclass, field, KW_ONLY
374+
375+ @dataclass
376+ class Base:
377+ x: str
378+ _: KW_ONLY
379+ y: int = 0
380+ w: int = 1
381+
382+ @dataclass
383+ class D(Base):
384+ z: str
385+ a: str = "a"
386+
387+ [builtins fixtures/list.pyi]
388+
371389[case testDataclassesClassmethods]
372390# flags: --python-version 3.7
373391from dataclasses import dataclass
You can’t perform that action at this time.
0 commit comments