Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created October 29, 2026 22:35
Show Gist options
  • Select an option

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

Select an option

Save mypy-play/77745ad2a91a922249899a057737f667 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import overload, Optional
class A:
pass
class B:
pass
class C:
pass
@overload
def foo(a_or_c: A, b: B, /, x: Optional[str] = None): ...
@overload
def foo(a_or_c: C, /, x: Optional[str] = None): ...
def foo(a_or_c: A | C, b: Optional[B] = None, /, x: Optional[str] = None):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment