Skip to content

Commit

Permalink
Merge pull request #1917 from Textualize/diagnose
Browse files Browse the repository at this point in the history
Expose diagnose.report as a function
  • Loading branch information
willmcgugan committed Feb 7, 2022
2 parents 9dd56e0 + 1e39db5 commit b67d7aa
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .coveragerc
Expand Up @@ -2,7 +2,8 @@
omit = rich/jupyter.py
rich/_windows.py
rich/_timer.py

rich/diagnose.py

[report]
exclude_lines =
pragma: no cover
Expand Down
15 changes: 12 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -20,12 +20,21 @@ Provide a minimal code example that demonstrates the issue if you can. If the is

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

I may ask you to cut and paste the output of the following commands. It may save some time if you do it now.
I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.

If you're using Rich in a terminal:

```
python -m rich.diagnose
python -m rich._windows
pip freeze | grep rich
```


If you're using Rich in a Jupyter Notebook, run the following snippet in a cell
and paste the output in your bug report.

```python
from rich.diagnose import report
report()
```

</details>
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add support for US spelling of "gray" in ANSI color names https://github.com/Textualize/rich/issues/1890
- Added `rich.diagnose.report` to expose environment debugging logic as function https://github.com/Textualize/rich/pull/1917
- Added classmethod `Progress.get_default_columns()` to get the default list of progress bar columns https://github.com/Textualize/rich/pull/1894

## [11.1.0] - 2022-01-28
Expand Down
35 changes: 32 additions & 3 deletions rich/diagnose.py
@@ -1,6 +1,35 @@
if __name__ == "__main__": # pragma: no cover
from rich.console import Console
from rich import inspect
import os
import platform

from rich import inspect
from rich.console import Console, get_windows_console_features
from rich.panel import Panel
from rich.pretty import Pretty


def report() -> None: # pragma: no cover
"""Print a report to the terminal with debugging information"""
console = Console()
inspect(console)
features = get_windows_console_features()
inspect(features)

env_names = (
"TERM",
"COLORTERM",
"CLICOLOR",
"NO_COLOR",
"TERM_PROGRAM",
"COLUMNS",
"LINES",
"JPY_PARENT_PID",
"VSCODE_VERBOSE_LOGGING",
)
env = {name: os.getenv(name) for name in env_names}
console.print(Panel.fit((Pretty(env)), title="[b]Environment Variables"))

console.print(f'platform="{platform.system()}"')


if __name__ == "__main__": # pragma: no cover
report()

0 comments on commit b67d7aa

Please sign in to comment.