Skip to content

Commit

Permalink
Merge pull request #199 from dwreeves/fix-warning
Browse files Browse the repository at this point in the history
Fix warning issue (again)
  • Loading branch information
dwreeves authored May 14, 2024
2 parents bcd77f1 + 4ebf2f9 commit 7662593
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ repos:
hooks:
- id: pyproject-fmt

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 1.7.0
hooks:
- id: pyproject-fmt

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 1.8.2 (2023-05-14)

- Fix another deprecation warning issue.

## Version 1.8.1 (2023-05-07)

- Fixed bad deprecation warning with `highlighter`
Expand Down
2 changes: 1 addition & 1 deletion src/rich_click/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
customisation required.
"""

__version__ = "1.8.1"
__version__ = "1.8.2"

# Import the entire click API here.
# We need to manually import these instead of `from click import *` to force
Expand Down
24 changes: 13 additions & 11 deletions src/rich_click/rich_help_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,19 @@ class RichHelpConfiguration:
legacy_windows: Optional[bool] = field(default=None)

def __post_init__(self) -> None: # noqa: D105
if self.highlighter is not None:
import warnings

warnings.warn(
"`highlighter` kwarg is deprecated in RichHelpConfiguration."
" Please do one of the following instead: either set highlighter_patterns=[...] if you want"
" to use regex; or for more advanced use cases where you'd like to use a different type"
" of rich.highlighter.Highlighter, subclass the `RichHelpFormatter` and update its `highlighter`.",
DeprecationWarning,
stacklevel=2,
)
# Todo: Fix this so that the deprecation warning works properly.

# if self.highlighter is not None:
# import warnings
#
# warnings.warn(
# "`highlighter` kwarg is deprecated in RichHelpConfiguration."
# " Please do one of the following instead: either set highlighter_patterns=[...] if you want"
# " to use regex; or for more advanced use cases where you'd like to use a different type"
# " of rich.highlighter.Highlighter, subclass the `RichHelpFormatter` and update its `highlighter`.",
# DeprecationWarning,
# stacklevel=2,
# )

self.__dataclass_fields__.pop("highlighter", None)

Expand Down

0 comments on commit 7662593

Please sign in to comment.