Removed legacy usage of Union[]
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
from typing import Any, List, Optional, Union
|
||||
from typing import Any, List, Optional
|
||||
|
||||
|
||||
class ConfigKeyError(Exception):
|
||||
"""Raised when config key is not found.
|
||||
|
||||
### Attributes:
|
||||
* key (`Union[str, List[str]]`): Missing config key.
|
||||
* key (`str | List[str]`): Missing config key.
|
||||
"""
|
||||
|
||||
def __init__(self, key: Union[str, List[str]]) -> None:
|
||||
self.key: Union[str, List[str]] = key
|
||||
def __init__(self, key: str | List[str]) -> None:
|
||||
self.key: str | List[str] = key
|
||||
super().__init__(
|
||||
f"Config key {'.'.join(key) if isinstance(key, list) else key} is missing. Please set in your config file."
|
||||
)
|
||||
@@ -22,12 +22,12 @@ class ConfigValueError(Exception):
|
||||
"""Raised when config key's value is invalid.
|
||||
|
||||
### Attributes:
|
||||
* key (`Union[str, List[str]]`): Invalid config key.
|
||||
* key (`str | List[str]`): Invalid config key.
|
||||
* value (`Optional[Any]`): Key's correct value.
|
||||
"""
|
||||
|
||||
def __init__(self, key: Union[str, List[str]], value: Optional[Any] = None) -> None:
|
||||
self.key: Union[str, List[str]] = key
|
||||
def __init__(self, key: str | List[str], value: Optional[Any] = None) -> None:
|
||||
self.key: str | List[str] = key
|
||||
self.value: Optional[Any] = value
|
||||
super().__init__(
|
||||
f"Config key {'.'.join(key) if isinstance(key, list) else key} has invalid value. {f'Must be {value}. ' if value else ''}Please set in your config file."
|
||||
|
Reference in New Issue
Block a user