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

[BUG] rich.inspect shows classes as functions #1658

Closed
zachriggle opened this issue Nov 8, 2021 · 1 comment · Fixed by #1874
Closed

[BUG] rich.inspect shows classes as functions #1658

zachriggle opened this issue Nov 8, 2021 · 1 comment · Fixed by #1874
Assignees

Comments

@zachriggle
Copy link

zachriggle commented Nov 8, 2021

Describe the bug
rich.inspect(pygments_solarized.dark256) incorrectly shows a class as a function (SolarizedDark256Style = def SolarizedDark256Style()).

This might be intended behavior when inspect()ing modules, but it's unexpected that methods=True would cause classes to be shown. I might even be so bold as to say when expecting a module, that classes and methods should be displayed by default, but I understand if the current behavior is preferred.

To Reproduce

$ pip3 install -U --user pygments_solarized

The class is declared as:

class SolarizedDark256Style(Style):

    """ Dark 256-color version solarized theme (http://ethanschoonover.com/solarized). """
    ...

Note that SolarizedDark256Style is not shown.

>>> rich.inspect(pygments_solarized.dark256)
>>> rich.inspect(pygments_solarized.dark256)
╭─ <module 'pygments_solarized.dark256' from '/Users/zachriggle/Library/Python/3.8/lib/python/site-─╮
│    BASE0 = '#808080'                                                                              │
│   BASE00 = '#585858'                                                                              │
│   BASE01 = '#4e4e4e'                                                                              │
│   BASE02 = '#262626'                                                                              │
│   BASE03 = '#1c1c1c'                                                                              │
│    BASE1 = '#8a8a8a'                                                                              │
│    BASE2 = '#d7d7af'                                                                              │
│    BASE3 = '#ffffd7'                                                                              │
│     BLUE = '#0087ff'                                                                              │
│  Comment = Token.Comment                                                                          │
│     CYAN = '#00afaf'                                                                              │
│  Generic = Token.Generic                                                                          │
│    GREEN = '#5f8700'                                                                              │
│  Keyword = Token.Keyword                                                                          │
│  MAGENTA = '#af005f'                                                                              │
│     Name = Token.Name                                                                             │
│   Number = Token.Literal.Number                                                                   │
│ Operator = Token.Operator                                                                         │
│   ORANGE = '#d75f00'                                                                              │
│      RED = '#af0000'                                                                              │
│   String = Token.Literal.String                                                                   │
│    Token = Token                                                                                  │
│   VIOLET = '#5f5faf'                                                                              │
│   YELLOW = '#af8700'                                                                              │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯

However, it is shown when specifying methods=True.

>>> rich.inspect(pygments_solarized.dark256, methods=True)
╭─ <module 'pygments_solarized.dark256' from '/Users/zachriggle/Library/Python/3.8/lib/python/site-─╮
│                 BASE0 = '#808080'                                                                 │
│                BASE00 = '#585858'                                                                 │
│                BASE01 = '#4e4e4e'                                                                 │
│                BASE02 = '#262626'                                                                 │
...
│                YELLOW = '#af8700'                                                                 │
│ SolarizedDark256Style = def SolarizedDark256Style(): Dark 256-color version solarized theme       │
│                         (http://ethanschoonover.com/solarized).                                   │
│                 Style = def Style():                                                              │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯```

Platform
Mac
iTerm

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

$ python3 -m rich.diagnose
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=101 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 40                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = True                                                          │
│       is_jupyter = False                                                         │
│      is_terminal = True                                                          │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=101, height=40),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=101,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=40,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=101, height=40)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 101                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯

$ python3 -m rich._windows
platform="Darwin"
WindowsConsoleFeatures(vt=False, truecolor=False)

$ pip freeze | grep rich
rich==10.12.0
@github-actions
Copy link

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants