Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created September 17, 2021 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mypy-play/faa66ac61b63d292f5078b254707acf7 to your computer and use it in GitHub Desktop.
Save mypy-play/faa66ac61b63d292f5078b254707acf7 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from __future__ import annotations
from collections.abc import Sequence
from os import PathLike
from pathlib import Path
from typing import Any, BinaryIO, TextIO, Union
FileDesignator = Union[PathLike[Any], str, bytes]
FileHandle = Union[TextIO, BinaryIO]
input_files: Sequence[FileDesignator]
input_sources: Sequence[FileDesignator | FileHandle]
if input_files:
input_sources = list(map(Path, input_files))
else:
input_sources = [sys.stdin]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment