Skip to content

pyright: "Table" is not exported from module "rich.table" #1523

Closed

Description

@nschloe

Running pyright 1.1.172 on

from rich.table import Table

gives

/tmp/b.py:1:24 - error: "Table" is not exported from module "rich.table" (reportPrivateImportUsage)

Activity

  1. lovetox commented on Sep 29, 2021

    @lovetox

    What version of pyright are you using? There have been changes to this specific check in pyright recently

  2. nschloe commented on Sep 29, 2021

    @nschloe
    Author

    pyright 1.1.169

    Edit: Also occurs with 1.1.172.

  3. willmcgugan commented on Sep 29, 2021

    @willmcgugan
    Member

    I suspect that may be because of the code in the main block, which imports Table. I don’t think it’s a real error to be concerned about, but I’ll see if there is a workaround.

  4. lovetox commented on Sep 29, 2021

    @lovetox

    I looked into this longer than i would have liked.
    The check is very new. The solution could be to import it like this

    from rich.table import Table as Table

    its called a redundant alias and it signals pyright that this symbol has to be re-exported ..

    though i dont know why it would matter that we import it in __main__.py. Why would this matter if we import from rich.table.
    This check is a few weeks old its not out of the question that this is a pyright bug.

    Relevant links
    microsoft/pyright#2277
    https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface

  5. chan-vince commented on Sep 29, 2021

    @chan-vince

    I also see what I think is the same issue, but in pylance:
    "Table" is not exported from module "rich.table"

    Despite that, the Intellisense seems to still work - it can autocomplete methods/attributes of Table, I can cmd+click into the library in site-packages, so I'm not sure what's going on.

    Full VS Code output:

    {
    	"resource": "/path/to/source.py",
    	"owner": "_generated_diagnostic_collection_name_#1",
    	"code": {
    		"value": "reportPrivateImportUsage",
    		"target": {
    			"$mid": 1,
    			"external": "https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules",
    			"path": "/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md",
    			"scheme": "https",
    			"authority": "github.com",
    			"fragment": "diagnostic-severity-rules"
    		}
    	},
    	"severity": 8,
    	"message": "\"Table\" is not exported from module \"rich.table\"",
    	"source": "Pylance",
    	"startLineNumber": 8,
    	"startColumn": 24,
    	"endLineNumber": 8,
    	"endColumn": 29
    }
    
  6. GBeauregard commented on Oct 5, 2021

    @GBeauregard
    Contributor

    I get a similar issue with Live: /home/gregory/Documents/projects/pyffstream/src/pyffstream/cli.py:486:24 - error: "Live" is not exported from module "rich.box.live" (reportPrivateImportUsage)

  7. GBeauregard commented on Oct 7, 2021

    @GBeauregard
    Contributor

    Upstream pyright has affirmatively clarified the behavior is intended and the libraries need to be redundantly imported to be correctly marked as exported. See microsoft/pyright#2277 (comment)

    I'm working on a PR that will close this issue by adding the appropriate TYPE_CHECKING guards to the if __name__ == __main__ blocks following the suggestion here microsoft/pyright#2392 (comment)

  8. github-actions commented on Oct 16, 2021

    @github-actions

    Did I solve your problem?

    Consider sponsoring the ongoing work on Rich and Textual.

    Or buy me a coffee to say thanks.

    – Will McGugan

  9. Akopov4 commented on Mar 26, 2026

    @Akopov4

    I saw this issue again
    versions of rich and pyright below

    Name: rich
    Version: 10.7.0
    
    
    Name: pyright
    Version: 1.1.408
    
    
  10. Akopov4 commented on Mar 26, 2026

    @Akopov4

    @willmcgugan see above

  11. TomJGooding commented on Mar 28, 2026

    @TomJGooding
    Contributor

    @Akopov4 Looks like you need to update rich - v10.7.0 was back in Aug 2021!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions