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

fix: 🐞 add missing exports to __all__ in supervision module #1682

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

onuralpszr
Copy link
Collaborator

Fix: #1681

@onuralpszr onuralpszr added the bug Something isn't working label Nov 24, 2024
@onuralpszr onuralpszr self-assigned this Nov 24, 2024
@LinasKo
Copy link
Collaborator

LinasKo commented Nov 25, 2024

Non-empty __init__ files in repo:

./supervision/metrics/__init__.py
./supervision/__init__.py
./supervision/validators/__init__.py
./supervision/assets/__init__.py
  1. I believe we should add this to metrics/__init__.py and assets/__init__.py as well.
  2. Instead, do you think this would be a better approach?
import inspect

...

# Explicitly declares public variables; required for pyright. See #1681
__all__ = [
    name
    for name in globals()
    if not name.startswith("_") and not inspect.ismodule(globals()[name])
]

I teste the set of variables I get with this:

print(__all__)
print(__all__2)
print(set(__all__) == set(__all__2))
  1. In case you dug this far: Shouldn't the definition of exported variables happen automatically for non-protected methods (without leading _)? Edit: reportPrivateImportUsage error on public-looking symbol defined with relative import microsoft/pyright#2639

Thanks for triaging this issue at such a late hour!

@onuralpszr
Copy link
Collaborator Author

1- For adding others I agreed

2- I like your for loop but the reason I prefer list is because "no import and logicless" sometimes using for loop + import more costly compare to simple list beside adding them not gonna be big of a deal anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pyright reportPrivateImportUsage error on supervision.Detections
2 participants