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

Let IDE(s) know public symbols #420

Closed
akihironitta opened this issue Aug 3, 2021 · 2 comments · Fixed by #425
Closed

Let IDE(s) know public symbols #420

akihironitta opened this issue Aug 3, 2021 · 2 comments · Fixed by #425
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@akihironitta
Copy link
Contributor

akihironitta commented Aug 3, 2021

🚀 Feature (or Bug?)

I'm using Pylance on VSCode, and it doesn't autocomplete, for example, Accuracy even if I typed the following:

from torchmetrics import Ac

This is because imported symbols are considered private by default (by at least pylance (pyright) as documented here).

Motivation

For better coding experience (autocomplete + docstring reference) :]

Pitch

As stated in https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface, we have the following options to explicitly make symbols public.

1. Add __all__ to __init__.py files.

# torchmetrics/__init__.py
from torchmetrics.classification import (
    Accuracy,
    ...
)
__all__ = [
    "Accuracy",
    ...
]

2. Use wildcard imports.

# torchmetrics/__init__.py
from torchmetrics.classification import *

# torchmetrics/classification/__init__.py
__all__ = [
    "Accuracy",
    ...
]

3. Use redundant symbol aliases.

# torchmetrics/__init__.py
from torchmetrics.classification import (
    Accuracy as Accuracy,
    ...
)

Additional context

microsoft/pylance-release#1032
microsoft/pyright#1877

@akihironitta akihironitta added enhancement New feature or request help wanted Extra attention is needed labels Aug 3, 2021
@github-actions
Copy link

github-actions bot commented Aug 3, 2021

Hi! thanks for your contribution!, great first issue!

@SkafteNicki
Copy link
Member

@akihironitta sounds good to me :]
I would prefer option 1 but have no strong opinions here.

@akihironitta akihironitta self-assigned this Aug 3, 2021
@Borda Borda added this to the v0.5 milestone Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants