pemistahl / lingua-py

The most accurate natural language detection library for Python, suitable for short text and mixed-language text
Apache License 2.0
1.1k stars 44 forks source link

Mark symbols in primary interface as public #76

Closed bscan closed 1 year ago

bscan commented 2 years ago

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: https://github.com/pemistahl/lingua-py/issues/63

image

pemistahl commented 1 year ago

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