Get the value of a given key from the given .env. Returns `None` if the key isn't found or doesn't have a value.
(
dotenv_path: StrPath,
key_to_get: str,
encoding: Optional[str] = "utf-8",
)
| 123 | |
| 124 | |
| 125 | def get_key( |
| 126 | dotenv_path: StrPath, |
| 127 | key_to_get: str, |
| 128 | encoding: Optional[str] = "utf-8", |
| 129 | ) -> Optional[str]: |
| 130 | """ |
| 131 | Get the value of a given key from the given .env. |
| 132 | |
| 133 | Returns `None` if the key isn't found or doesn't have a value. |
| 134 | """ |
| 135 | return DotEnv(dotenv_path, verbose=True, encoding=encoding).get(key_to_get) |
| 136 | |
| 137 | |
| 138 | @contextmanager |