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

pyright complain "component" is not exported from module "solara" #465

Open
zhuoqiang opened this issue Jan 13, 2024 · 3 comments
Open

pyright complain "component" is not exported from module "solara" #465

zhuoqiang opened this issue Jan 13, 2024 · 3 comments

Comments

@zhuoqiang
Copy link

pyright complains "component" is not exported from module "solara" for the following code, line 3

import solara

@solara.component
class Page
    pass

turns out it is not a false alarm, see microsoft/pyright#5929

By default, all imports in a py.typed library are considered private unless they are explicitly re-exported. To indicate that an imported symbol is intended to be re-exported, the maintainers of this library would need to use one of the techniques documented here

so I guess instead of

from reacton import component

it could be updated to re-exported using the redundant form to make pyright happy

from reacton import component as component
@Lundez
Copy link
Contributor

Lundez commented Jan 25, 2024

I think adding the following to .vscode/settings.json solved this for me 👍

    "python.analysis.packageIndexDepths": [
        {
            "name": "",
            "depth": 5
        }
    ],

@Jhsmit
Copy link
Contributor

Jhsmit commented Mar 13, 2024

I have the same issue (with pylance)
Not only solara.component but also solara.use_state (basically any reacton import)

unfortunately @Lundez' fix doesnt seem to help

adding __all__ to __init__.py can also fix the issue

@edan-bainglass
Copy link

@Jhsmit true, an explicit __all__ would help! For now, to calm pylance, I replace solara imports with more specific (deep) ones.

from solara.core import component

@component
def MyComponent():
    ...

A bit more work, but acceptable at least in my use case. There are TODO tags regarding __all__ in the solara module, so hopefully coming soon :)

iisakkirotko added a commit that referenced this issue Dec 23, 2024
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
iisakkirotko added a commit that referenced this issue Dec 27, 2024
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
iisakkirotko added a commit that referenced this issue Jan 31, 2025
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
iisakkirotko added a commit that referenced this issue Feb 4, 2025
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
iisakkirotko added a commit that referenced this issue Feb 5, 2025
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
iisakkirotko added a commit that referenced this issue Feb 5, 2025
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
iisakkirotko added a commit that referenced this issue Feb 5, 2025
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
iisakkirotko added a commit that referenced this issue Feb 7, 2025
Helps typing and linting tools know the structure of the package.
Fixes #950
Fixes #465
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

No branches or pull requests

4 participants