aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-02-07 20:12:04 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commitb3a378462ba3f7851c4e4d8f63c781f8d498290d (patch)
treed767546a90f6605e05f6d03cafc3fa6e338521c7
parent4de39f91d9d8942816b8967a115010c466b8f252 (diff)
downloadwee-slack-b3a378462ba3f7851c4e4d8f63c781f8d498290d.tar.gz
Use Optional instead of Union with None
-rw-r--r--slack/config.py14
-rw-r--r--slack/weechat_config.py10
2 files changed, 12 insertions, 12 deletions
diff --git a/slack/config.py b/slack/config.py
index ae31350..8b60ac1 100644
--- a/slack/config.py
+++ b/slack/config.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Union
+from typing import Optional
import weechat
@@ -88,8 +88,8 @@ class SlackConfigSectionWorkspace:
def __init__(
self,
section: WeeChatSection,
- workspace_name: Union[str, None],
- parent_config: Union[SlackConfigSectionWorkspace, None],
+ workspace_name: Optional[str],
+ parent_config: Optional[SlackConfigSectionWorkspace],
):
self._section = section
self._workspace_name = workspace_name
@@ -132,9 +132,9 @@ class SlackConfigSectionWorkspace:
name: str,
description: str,
default_value: WeeChatOptionType,
- min_value: Union[int, None] = None,
- max_value: Union[int, None] = None,
- string_values: Union[str, None] = None,
+ min_value: Optional[int] = None,
+ max_value: Optional[int] = None,
+ string_values: Optional[str] = None,
) -> WeeChatOption[WeeChatOptionType]:
if self._workspace_name:
option_name = f"{self._workspace_name}.{name}"
@@ -159,7 +159,7 @@ class SlackConfigSectionWorkspace:
def config_section_workspace_read_cb(
- data: str, config_file: str, section: str, option_name: str, value: Union[str, None]
+ data: str, config_file: str, section: str, option_name: str, value: Optional[str]
) -> int:
option_split = option_name.split(".", 1)
if len(option_split) < 2:
diff --git a/slack/weechat_config.py b/slack/weechat_config.py
index 8d17b13..7fc2742 100644
--- a/slack/weechat_config.py
+++ b/slack/weechat_config.py
@@ -1,7 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass
-from typing import Generic, TypeVar, Union, cast
+from typing import Generic, Optional, TypeVar, Union, cast
import weechat
@@ -58,10 +58,10 @@ class WeeChatOption(Generic[WeeChatOptionType]):
name: str
description: str
default_value: WeeChatOptionType
- min_value: Union[int, None] = None
- max_value: Union[int, None] = None
- string_values: Union[str, None] = None
- parent_option: Union[WeeChatOption[WeeChatOptionType], None] = None
+ min_value: Optional[int] = None
+ max_value: Optional[int] = None
+ string_values: Optional[str] = None
+ parent_option: Optional[WeeChatOption[WeeChatOptionType]] = None
def __post_init__(self):
self._pointer = self._create_weechat_option()