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

Expose diagnose.report as a function #1917

merged 6 commits into from
Feb 7, 2022

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Feb 4, 2022

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Adds diagnose.report function. Also adds some additional information from env vars if the user is using Jupyter, that might help convey what platform they're using if they don't specify in the bug report.

I've added the file as an omission to coverage reporting since it's only used for debug purposes.

╭──────────────────── <class 'rich.console.Console'> ─────────────────────╮
│ A high level console interface.                                         │
│                                                                         │
│ ╭─────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=93 ColorSystem.TRUECOLOR>                            │ │
│ ╰─────────────────────────────────────────────────────────────────────╯ │
│                                                                         │
│     color_system = 'truecolor'                                          │
│         encoding = 'utf-8'                                              │
│             file = <ipykernel.iostream.OutStream object at 0x10535c730> │
│           height = 100                                                  │
│    is_alt_screen = False                                                │
│ is_dumb_terminal = False                                                │
│   is_interactive = False                                                │
│       is_jupyter = True                                                 │
│      is_terminal = False                                                │
│   legacy_windows = False                                                │
│         no_color = False                                                │
│          options = ConsoleOptions(                                      │
│                        size=ConsoleDimensions(width=93, height=100),    │
│                        legacy_windows=False,                            │
│                        min_width=1,                                     │
│                        max_width=93,                                    │
│                        is_terminal=False,                               │
│                        encoding='utf-8',                                │
│                        max_height=100,                                  │
│                        justify=None,                                    │
│                        overflow=None,                                   │
│                        no_wrap=False,                                   │
│                        highlight=None,                                  │
│                        markup=None,                                     │
│                        height=None                                      │
│                    )                                                    │
│            quiet = False                                                │
│           record = False                                                │
│         safe_box = True                                                 │
│             size = ConsoleDimensions(width=93, height=100)              │
│        soft_wrap = False                                                │
│           stderr = False                                                │
│            style = None                                                 │
│         tab_size = 8                                                    │
│            width = 93                                                   │
╰─────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭──────────────────────────────── Jupyter Environment Hints ────────────────────────────────╮
│ JPY_PARENT_PID = 89228                                                                    │
│ VSCODE_VERBOSE_LOGGING = true                                                             │
│                                                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────╯
platform="Darwin"

@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2022

Codecov Report

Merging #1917 (bcbaed2) into master (e839bfb) will decrease coverage by 0.02%.
The diff coverage is 98.99%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1917      +/-   ##
==========================================
- Coverage   99.82%   99.80%   -0.03%     
==========================================
  Files          71       71              
  Lines        6943     7035      +92     
==========================================
+ Hits         6931     7021      +90     
- Misses         12       14       +2     
Flag Coverage Δ
unittests 99.80% <98.99%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/default_styles.py 100.00% <ø> (ø)
rich/markdown.py 100.00% <ø> (ø)
rich/syntax.py 99.27% <97.72%> (-0.34%) ⬇️
rich/pretty.py 99.71% <98.88%> (-0.29%) ⬇️
rich/__main__.py 100.00% <100.00%> (ø)
rich/_inspect.py 100.00% <100.00%> (ø)
rich/color.py 100.00% <100.00%> (ø)
rich/console.py 100.00% <100.00%> (ø)
rich/segment.py 99.34% <100.00%> (+0.05%) ⬆️
rich/table.py 100.00% <100.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94273ee...bcbaed2. Read the comment docs.

@willmcgugan
Copy link
Collaborator

Can I see an example of the report?

@darrenburns
Copy link
Member Author

@willmcgugan Added the output to the original post

Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be worth adding some additional env vars. Not quite everything, since users might have issues re privacy.

In addition to the Jupyter ones, I would add:

TERM
COLORTERM
CLICOLOR
NO_COLOR
TERM_PROGRAM
COLUMNS
LINES

Maybe extract those to a dict and pretty print them with

Panel(Pretty(env_vars))

rich/diagnose.py Show resolved Hide resolved
rich/diagnose.py Outdated Show resolved Hide resolved
.github/ISSUE_TEMPLATE/bug_report.md Outdated Show resolved Hide resolved
@darrenburns
Copy link
Member Author

Will do

@darrenburns
Copy link
Member Author

╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-256color',      │
│     'COLORTERM': 'truecolor',      │
│     'CLICOLOR': None,              │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': 'iTerm.app',   │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯

Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@willmcgugan willmcgugan merged commit b67d7aa into master Feb 7, 2022
@willmcgugan willmcgugan deleted the diagnose branch February 7, 2022 10:50
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Feb 21, 2022
11.2.0

Added

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

Fixed

Fixed performance issue in measuring text
Fixed test failures on PyPy3 Textualize/rich#1904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants