Skip to content

Commit

Permalink
Merge pull request janluke#163 from janluke/helptheme-as-dataclass
Browse files Browse the repository at this point in the history
`HelpTheme` as `dataclass` rather than `NamedTuple`
  • Loading branch information
janluke authored Jul 14, 2023
2 parents 56049d5 + 1372cfb commit b407fb2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cloup/styling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
This module contains components that specifically address the styling and theming
of the ``--help`` output.
"""
import dataclasses
import dataclasses as dc
from typing import Any, Callable, Dict, NamedTuple, Optional
from dataclasses import dataclass
from typing import Any, Callable, Dict, Optional

import click

Expand All @@ -14,8 +16,8 @@
"""A callable that takes a string and returns a styled version of it."""


# noinspection PyUnresolvedReferences
class HelpTheme(NamedTuple):
@dataclass(frozen=True)
class HelpTheme:
"""A collection of styles for several elements of the help page.
A "style" is just a function or a callable that takes a string and returns
Expand Down Expand Up @@ -95,7 +97,7 @@ def with_(
del kwargs["alias_secondary"]
kwargs.pop('self')
if kwargs:
return self._replace(**kwargs)
return dataclasses.replace(self, **kwargs)
return self

@staticmethod
Expand Down

0 comments on commit b407fb2

Please sign in to comment.