Skip to content

Commit

Permalink
Fix terminal.style.spinner config value (#1471)
Browse files Browse the repository at this point in the history
Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
  • Loading branch information
Grub4K and ofek committed May 23, 2024
1 parent 0e6c93a commit 3d899bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/history/hatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

***Fixed:***

- Fix `terminal.style.spinner` configuration
- Fix entry points in the pre-built distribution that binaries use

## [1.11.0](https://github.com/pypa/hatch/releases/tag/hatch-v1.11.0) - 2024-05-14 ## {: #hatch-v1.11.0 }
Expand Down
15 changes: 13 additions & 2 deletions src/hatch/cli/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import click
from rich.console import Console
from rich.errors import StyleSyntaxError
from rich.style import Style
from rich.text import Text

Expand Down Expand Up @@ -182,6 +181,9 @@ def style_debug(self, text: str) -> Text:
return Text(text, style=self._style_level_debug)

def initialize_styles(self, styles: dict): # no cov
from rich.errors import StyleSyntaxError
from rich.spinner import Spinner

# Lazily display errors so that they use the correct style
errors = []

Expand All @@ -197,8 +199,17 @@ def initialize_styles(self, styles: dict): # no cov
parsed_style = Style.parse(default_level)

setattr(self, attribute, parsed_style)
elif option == 'spinner':
try:
Spinner(style)
except KeyError as e:
errors.append(
f'Invalid style definition for `{option}`, defaulting to `{self._style_spinner}`: {e.args[0]}'
)
else:
self._style_spinner = style
else:
setattr(self, attribute, f'_style_{option}')
setattr(self, f'_style_{option}', style)

return errors

Expand Down

0 comments on commit 3d899bd

Please sign in to comment.