Stop Rich auto-colouring integers in default prints #957
-
|
Rich auto-colours the integer I'm on 3.8 with the latest version of Rich from PyPi :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
See https://rich.readthedocs.io/en/latest/highlighting.html for how to disable highlighting. |
Beta Was this translation helpful? Give feedback.
-
|
@willmcgugan Is it possible to simply pass through the For example: Before: def print(
*objects: Any,
sep: str = " ",
end: str = "\n",
file: Optional[IO[str]] = None,
flush: bool = False,
) -> None:
r"""Print object(s) supplied via positional arguments.
This function has an identical signature to the built-in print.
For more advanced features, see the :class:`~rich.console.Console` class.
Args:
sep (str, optional): Separator between printed objects. Defaults to " ".
end (str, optional): Character to write at end of output. Defaults to "\\n".
file (IO[str], optional): File to write to, or None for stdout. Defaults to None.
flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.
"""
from .console import Console
write_console = get_console() if file is None else Console(file=file)
return write_console.print(*objects, sep=sep, end=end)After: def print(
*objects: Any,
sep: str = " ",
end: str = "\n",
file: Optional[IO[str]] = None,
flush: bool = False,
highlight: bool = True,
) -> None:
r"""Print object(s) supplied via positional arguments.
This function has a near-identical signature to the built-in print.
For more advanced features, see the :class:`~rich.console.Console` class.
Args:
sep (str, optional): Separator between printed objects. Defaults to " ".
end (str, optional): Character to write at end of output. Defaults to "\\n".
file (IO[str], optional): File to write to, or None for stdout. Defaults to None.
flush (bool, optional): Has no effect as Rich always flushes output. Defaults to False.
highlight (bool, optional): Highlight special characters and numbers.
"""
from .console import Console
write_console = get_console() if file is None else Console(file=file)
return write_console.print(*objects, sep=sep, end=end, highlight=highlight)Note that there are only around 30 characters changed, if that. Is there a reason this cannot be implemented? I believe it would make things a lot easier for the average user and not require them to use the My apologies if posting on an old discussion like this is unwarranted. I initially intended to just make a pull request solving it myself but I cannot do that without permission, which I cannot do without an issue, which I cannot do without a discussion. And I cannot make a new discussion without first ensuring there isn't an existing one, so that's how I ended up here. I understand this would not match Python's default I, personally, favor convenience and progress over tradition for tradition's sake, so if we're following Python's signature just because, I would like to ask why we can't change that. But if there's some underlying reason, then, of course, I respect that. As an alternative, disabling default highlighting outright may be the best of both worlds - Edit: P.S., Thank you! |
Beta Was this translation helpful? Give feedback.

See https://rich.readthedocs.io/en/latest/highlighting.html for how to disable highlighting.