Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created May 24, 2024 11:14
Show Gist options
  • Save mypy-play/7732fe61aa2a29f792f5084e65e564bd to your computer and use it in GitHub Desktop.
Save mypy-play/7732fe61aa2a29f792f5084e65e564bd to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import overload, Literal
@overload
def execute_command(command: str,
additional_arguments: str = '',
*,
capture_output: Literal[True],
) -> str:
...
@overload
def execute_command(command: str,
additional_arguments: str = '',
capture_output: Literal[False] = False,
) -> None:
...
def execute_command(command, additional_arguments='', capture_output=False):
if capture_output:
return ''
execute_command(command='hello', capture_arguments=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment