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

Mark symbols in primary interface as public #76

Merged
merged 1 commit into from
Sep 16, 2022
Merged

Conversation

bscan
Copy link
Contributor

@bscan bscan commented Sep 14, 2022

Thanks for making lingua!

Adding an __all__ variable to control the set of variables exported by lingua. This helps with type checking by Pyright. The alternative would be changing to a form such as: from .builder import LanguageDetectorBuilder as LanguageDetectorBuilder

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

Imported symbols are considered private by default. If they use the “import A as A” (a redundant module alias), “from X import A as A” (a redundant symbol alias), or “from . import A” forms, symbol “A” is not private unless the name begins with an underscore. If a file init.py uses the form “from .A import X”, symbol “A” is not private unless the name begins with an underscore (but “X” is still private). If a wildcard import (of the form “from X import *”) is used, all symbols referenced by the wildcard are not private.

I assume this only started happening with releases following: #63

image

Adding an __all__ variable to control the set of variables exported by lingua. This helps with type checking by Pyright. The alternative would be changing to a form such as:
` from .builder import LanguageDetectorBuilder as LanguageDetectorBuilder `

https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface
```
Imported symbols are considered private by default. If they use the “import A as A” (a redundant module alias), “from X import A as A” (a redundant symbol alias), or “from . import A” forms, symbol “A” is not private unless the name begins with an underscore. If a file __init__.py uses the form “from .A import X”, symbol “A” is not private unless the name begins with an underscore (but “X” is still private). If a wildcard import (of the form “from X import *”) is used, all symbols referenced by the wildcard are not private.
```
@pemistahl
Copy link
Owner

Thank you @bscan, I forgot about Python's weird exporting rules. Specifying __all__ certainly helps.

@pemistahl pemistahl merged commit adebfbf into pemistahl:main Sep 16, 2022
@pemistahl pemistahl added this to the Lingua 1.1.3 milestone Sep 29, 2022
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

Successfully merging this pull request may close these issues.

2 participants