Skip to content

Commit

Permalink
Remove rich markdown header override (#2938)
Browse files Browse the repository at this point in the history
As rich 13.2 is changing internals related to markdown rendering, it
is better to remove our custom header rendering override, so users
can use the library with any version of rich.
  • Loading branch information
ssbarnea committed Jan 25, 2023
1 parent f42dbdb commit c3ef3f3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .config/requirements-lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pygments==2.13.0
pyrsistent==0.19.3
pyyaml==6.0
resolvelib==0.8.1
rich==13.0.0
rich==13.2.0
ruamel-yaml==0.17.21
setuptools==65.6.3
subprocess-tee==0.4.1
Expand Down
3 changes: 1 addition & 2 deletions .config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.0.1
click==8.1.3
commonmark==0.9.1
coverage==7.0.5
coverage-enable-subprocess==1.0
cryptography==39.0.0
Expand Down Expand Up @@ -64,7 +63,7 @@ pytz==2022.7.1
pyyaml==6.0
requests==2.28.2
resolvelib==0.8.1
rich==13.1.0
rich==13.2.0
ruamel-yaml==0.17.21
ruamel-yaml-clib==0.2.7
setuptools==66.0.0
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ repos:
- prettier-plugin-toml
- prettier-plugin-sort-json
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v6.17.1
rev: v6.19.2
hooks:
- id: cspell
# entry: codespell --relative
args: [--relative, --no-progress, --no-summary]
name: Spell check with cspell
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.20.0
rev: 0.21.0
hooks:
- id: check-github-workflows
- repo: https://github.com/pre-commit/pre-commit-hooks.git
Expand Down Expand Up @@ -169,7 +169,7 @@ repos:
- filelock
- jinja2
- pytest>=7.2.0
- rich>=11.0.0
- rich>=13.2.0
- ruamel.yaml
- types-PyYAML
- types-jsonschema>=4.4.2
Expand All @@ -182,7 +182,7 @@ repos:
plugins/.*
)$
- repo: https://github.com/pycqa/pylint
rev: v2.16.0b0
rev: v2.16.0b1
hooks:
- id: pylint
args:
Expand All @@ -196,7 +196,7 @@ repos:
- jsonschema>=4.9.0
- pytest>=7.2.0
- pyyaml
- rich>=11.0.0
- rich>=13.2.0
- ruamel.yaml
- sphinx
- typing_extensions
Expand Down
13 changes: 0 additions & 13 deletions src/ansiblelint/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,6 @@ def render_yaml(text: str) -> Syntax:
return Syntax(text, "yaml", theme="ansi_dark")


# pylint: disable=redefined-outer-name,unused-argument
def _rich_heading_custom_rich_console(
self: rich.markdown.Heading,
console: rich.console.Console,
options: rich.console.ConsoleOptions,
) -> rich.console.RenderResult:
"""Override for rich console heading."""
yield f"[bold]{self.level * '#'} {self.text}[/]"


# pylint: disable=redefined-outer-name,unused-argument
def _rich_codeblock_custom_rich_console(
self: rich.markdown.CodeBlock,
Expand All @@ -115,7 +105,4 @@ def _rich_codeblock_custom_rich_console(
yield syntax


# Monkey-patch rich to alter its rendering of headings
# https://github.com/python/mypy/issues/2427
rich.markdown.Heading.__rich_console__ = _rich_heading_custom_rich_console # type: ignore
rich.markdown.CodeBlock.__rich_console__ = _rich_codeblock_custom_rich_console # type: ignore

0 comments on commit c3ef3f3

Please sign in to comment.