Created
November 16, 2024 02:10
-
-
Save mypy-play/b4021ddb8eba737e35b96fa00fe70bb8 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Callable | |
type ValueConverter[T] = Callable[[str], T] | |
class EnvVar[T]: | |
def __init__(self, key: str, convert: ValueConverter[T] = str): | |
self.key = key | |
self.convert = convert | |
class DatasetReference: | |
def __init__(self, project_id: str | None, dataset_id: str): | |
pass | |
@classmethod | |
def from_string(cls, dataset_id: str, default_project_id: str | None = None) -> DatasetReference: | |
return cls(default_project_id, dataset_id) | |
FOO = EnvVar("FOO") | |
BAR = EnvVar("BAR", int) | |
BAZ = EnvVar("BAZ", dataset_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment