From 2054fbfe8f863b6cddd92eb4c8f6103280da5346 Mon Sep 17 00:00:00 2001 From: dwreeves Date: Fri, 29 Dec 2023 16:58:09 -0500 Subject: [PATCH] inconsequential refactor --- src/rich_click/rich_context.py | 9 +++++---- src/rich_click/rich_help_configuration.py | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/rich_click/rich_context.py b/src/rich_click/rich_context.py index cc14face..8387b8b0 100644 --- a/src/rich_click/rich_context.py +++ b/src/rich_click/rich_context.py @@ -37,8 +37,11 @@ def __init__( self.console = rich_console - if rich_help_config is None and hasattr(parent, "help_config"): - self.help_config = parent.help_config # type: ignore[has-type,union-attr] + if rich_help_config is None: + if hasattr(parent, "help_config"): + self.help_config = parent.help_config # type: ignore[has-type,union-attr] + else: + self.help_config = RichHelpConfiguration.load_from_globals() elif isinstance(rich_help_config, Mapping): if hasattr(parent, "help_config"): if TYPE_CHECKING: @@ -48,8 +51,6 @@ def __init__( self.help_config = RichHelpConfiguration(**kw) else: self.help_config = RichHelpConfiguration.load_from_globals(**rich_help_config) - elif rich_help_config is None: - self.help_config = RichHelpConfiguration.load_from_globals() else: self.help_config = rich_help_config diff --git a/src/rich_click/rich_help_configuration.py b/src/rich_click/rich_help_configuration.py index 2ee0572b..b8d7cd20 100644 --- a/src/rich_click/rich_help_configuration.py +++ b/src/rich_click/rich_help_configuration.py @@ -2,7 +2,7 @@ from dataclasses import dataclass, field from os import getenv from types import ModuleType -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, TypeVar, Union +from typing import Any, Dict, List, Optional, Tuple, TypeVar, Union import rich.align import rich.highlighter @@ -14,10 +14,6 @@ from rich_click.utils import truthy -if TYPE_CHECKING: - pass - - T = TypeVar("T", bound="RichHelpConfiguration")