Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HelpTheme as dataclass rather than NamedTuple #163

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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