PEP 673: minor fixes to the code samples (#2242)

- Use `...` instead of a unicode ellipsis
- Fix dataclass definition with defaulted before non-defaulted field
This commit is contained in:
Jelle Zijlstra 2022-01-15 06:09:30 -08:00 committed by GitHub
parent f5a820919a
commit e4a6c82c01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -290,7 +290,7 @@ We propose using ``Self`` directly to achieve the same behavior:
class Shape:
def difference(self, other: Self) -> float: ...
def apply(self, f: Callable[[Self], None]) -> None:
def apply(self, f: Callable[[Self], None]) -> None: ...
Note that specifying ``self: Self`` is harmless, so some users may find it
more readable to write the above as:
@ -350,9 +350,8 @@ We propose expressing this constraint using ``next: Self | None``:
@dataclass
class LinkedList(Generic[T]):
next: Self | None = None
value: T
next: Self | None = None
@dataclass
class OrdinalLinkedList(LinkedList[int]):