Fix issue with trailing whitespace (#3195)

* chore: upgrade all pre-commit hooks to latest version

* chore: add trailing-whitespace pre-commit hook

* refactor: Avoid trailing whitespace in box definitions

* docs: Add Robin Bowes as a contributor

---------

Co-authored-by: Robin Bowes <robin.bowes@yo61.com>
This commit is contained in:
Darren Burns 2023-11-08 11:43:38 +00:00 committed by GitHub
parent 50d2a457c8
commit b32e42bda0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 157 additions and 191 deletions

View File

@ -16,6 +16,7 @@ repos:
- id: mixed-line-ending
- id: check-vcs-permalinks
- id: check-shebang-scripts-are-executable
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
@ -34,7 +35,7 @@ repos:
hooks:
- id: black
exclude: ^benchmarks/
- repo: https://github.com/pycqa/isort
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

View File

@ -8,6 +8,7 @@ The following people have contributed to the development of Rich:
- [Gregory Beauregard](https://github.com/GBeauregard/pyffstream)
- [Artur Borecki](https://github.com/pufereq)
- [Pedro Aaron](https://github.com/paaaron)
- [Robin Bowes](https://github.com/yo61)
- [Dennis Brakhane](https://github.com/brakhane)
- [Darren Burns](https://github.com/darrenburns)
- [Jim Crist-Harif](https://github.com/jcrist)

View File

@ -188,260 +188,224 @@ class Box:
return "".join(parts)
# fmt: off
ASCII: Box = Box(
"""\
+--+
| ||
|-+|
| ||
|-+|
|-+|
| ||
+--+
""",
"+--+\n"
"| ||\n"
"|-+|\n"
"| ||\n"
"|-+|\n"
"|-+|\n"
"| ||\n"
"+--+\n",
ascii=True,
)
ASCII2: Box = Box(
"""\
+-++
| ||
+-++
| ||
+-++
+-++
| ||
+-++
""",
"+-++\n"
"| ||\n"
"+-++\n"
"| ||\n"
"+-++\n"
"+-++\n"
"| ||\n"
"+-++\n",
ascii=True,
)
ASCII_DOUBLE_HEAD: Box = Box(
"""\
+-++
| ||
+=++
| ||
+-++
+-++
| ||
+-++
""",
"+-++\n"
"| ||\n"
"+=++\n"
"| ||\n"
"+-++\n"
"+-++\n"
"| ||\n"
"+-++\n",
ascii=True,
)
SQUARE: Box = Box(
"""\
"""
"┌─┬┐\n"
"│ ││\n"
"├─┼┤\n"
"│ ││\n"
"├─┼┤\n"
"├─┼┤\n"
"│ ││\n"
"└─┴┘\n"
)
SQUARE_DOUBLE_HEAD: Box = Box(
"""\
"""
"┌─┬┐\n"
"│ ││\n"
"╞═╪╡\n"
"│ ││\n"
"├─┼┤\n"
"├─┼┤\n"
"│ ││\n"
"└─┴┘\n"
)
MINIMAL: Box = Box(
"""\
"""
"\n"
"\n"
"╶─┼╴\n"
"\n"
"╶─┼╴\n"
"╶─┼╴\n"
"\n"
"\n"
)
MINIMAL_HEAVY_HEAD: Box = Box(
"""\
"""
"\n"
"\n"
"╺━┿╸\n"
"\n"
"╶─┼╴\n"
"╶─┼╴\n"
"\n"
"\n"
)
MINIMAL_DOUBLE_HEAD: Box = Box(
"""\
"""
"\n"
"\n"
" ═╪ \n"
"\n"
" ─┼ \n"
" ─┼ \n"
"\n"
"\n"
)
SIMPLE: Box = Box(
"""\
"""
" \n"
" \n"
" ── \n"
" \n"
" \n"
" ── \n"
" \n"
" \n"
)
SIMPLE_HEAD: Box = Box(
"""\
"""
" \n"
" \n"
" ── \n"
" \n"
" \n"
" \n"
" \n"
" \n"
)
SIMPLE_HEAVY: Box = Box(
"""\
"""
" \n"
" \n"
" ━━ \n"
" \n"
" \n"
" ━━ \n"
" \n"
" \n"
)
HORIZONTALS: Box = Box(
"""\
"""
" ── \n"
" \n"
" ── \n"
" \n"
" ── \n"
" ── \n"
" \n"
" ── \n"
)
ROUNDED: Box = Box(
"""\
"""
"╭─┬╮\n"
"│ ││\n"
"├─┼┤\n"
"│ ││\n"
"├─┼┤\n"
"├─┼┤\n"
"│ ││\n"
"╰─┴╯\n"
)
HEAVY: Box = Box(
"""\
"""
"┏━┳┓\n"
"┃ ┃┃\n"
"┣━╋┫\n"
"┃ ┃┃\n"
"┣━╋┫\n"
"┣━╋┫\n"
"┃ ┃┃\n"
"┗━┻┛\n"
)
HEAVY_EDGE: Box = Box(
"""\
"""
"┏━┯┓\n"
"┃ │┃\n"
"┠─┼┨\n"
"┃ │┃\n"
"┠─┼┨\n"
"┠─┼┨\n"
"┃ │┃\n"
"┗━┷┛\n"
)
HEAVY_HEAD: Box = Box(
"""\
"""
"┏━┳┓\n"
"┃ ┃┃\n"
"┡━╇┩\n"
"│ ││\n"
"├─┼┤\n"
"├─┼┤\n"
"│ ││\n"
"└─┴┘\n"
)
DOUBLE: Box = Box(
"""\
"""
"╔═╦╗\n"
"║ ║║\n"
"╠═╬╣\n"
"║ ║║\n"
"╠═╬╣\n"
"╠═╬╣\n"
"║ ║║\n"
"╚═╩╝\n"
)
DOUBLE_EDGE: Box = Box(
"""\
"""
"╔═╤╗\n"
"║ │║\n"
"╟─┼╢\n"
"║ │║\n"
"╟─┼╢\n"
"╟─┼╢\n"
"║ │║\n"
"╚═╧╝\n"
)
MARKDOWN: Box = Box(
"""\
| ||
|-||
| ||
|-||
|-||
| ||
""",
" \n"
"| ||\n"
"|-||\n"
"| ||\n"
"|-||\n"
"|-||\n"
"| ||\n"
" \n",
ascii=True,
)
# fmt: on
# Map Boxes that don't render with raster fonts on to equivalent that do
LEGACY_WINDOWS_SUBSTITUTIONS = {