Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose diagnose.report as a function #1917

Merged
merged 6 commits into from Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
darrenburns marked this conversation as resolved.
Show resolved Hide resolved
report()