Comment

Comment by meander_water

You can also explicitly specify which arguments need to be keyword only using the KW_ONLY sentinel type annotation:

  from dataclasses import KW_ONLY

  @dataclass
  class Point:
      x: float
      _: KW_ONLY
      y: float
      z: float

  p = Point(0, y=1.5, z=2.0)

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton