Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created October 31, 2026 20:25
Show Gist options
  • Select an option

  • Save mypy-play/084d01434c9b7458642e9ee750b427ee to your computer and use it in GitHub Desktop.

Select an option

Save mypy-play/084d01434c9b7458642e9ee750b427ee to your computer and use it in GitHub Desktop.
Shared via mypy Playground
def func_with_kw_only(x: int, *, y: int = 0):
return x + y
def func_with_pos_only(x: int, y: int, /):
return x + y
func_with_kw_only(1) # OK
func_with_kw_only(1, y=2) # OK
func_with_kw_only(1, 2) # error: Too many positional arguments for "func_with_kw_only" [call-arg]
func_with_pos_only(1, 2) # OK
func_with_pos_only(1, y=2) # error: Unexpected keyword argument "y" for "func_with_pos_only" [call-arg]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment