Skip to content

Commit

Permalink
PEP 673: minor fixes to the code samples (#2242)
Browse files Browse the repository at this point in the history
- Use `...` instead of a unicode ellipsis
- Fix dataclass definition with defaulted before non-defaulted field
  • Loading branch information
JelleZijlstra committed Jan 15, 2022
1 parent f5a8209 commit e4a6c82
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pep-0673.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]):
Expand Down

0 comments on commit e4a6c82

Please sign in to comment.