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",
)
| 114 | |
| 115 | |
| 116 | def get_key( |
| 117 | dotenv_path: StrPath, |
| 118 | key_to_get: str, |
| 119 | encoding: Optional[str] = "utf-8", |
| 120 | ) -> Optional[str]: |
| 121 | """ |
| 122 | Get the value of a given key from the given .env. |
| 123 | |
| 124 | Returns `None` if the key isn't found or doesn't have a value. |
| 125 | """ |
| 126 | return DotEnv(dotenv_path, verbose=True, encoding=encoding).get(key_to_get) |
| 127 | |
| 128 | |
| 129 | @contextmanager |