Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created May 24, 2024 11:11
Show Gist options
  • Save mypy-play/4dd674f2450bdba21a59c3348d237bad to your computer and use it in GitHub Desktop.
Save mypy-play/4dd674f2450bdba21a59c3348d237bad 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 ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment