From adebfbffaadfaf81bc17834c48623be1f0a17f76 Mon Sep 17 00:00:00 2001 From: bscan <10503608+bscan@users.noreply.github.com> Date: Fri, 16 Sep 2022 17:54:21 -0400 Subject: [PATCH] Update __init__.py (#76) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. ``` --- lingua/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lingua/__init__.py b/lingua/__init__.py index fe6f206d..482cea0e 100644 --- a/lingua/__init__.py +++ b/lingua/__init__.py @@ -413,6 +413,8 @@ ``` """ +__all__ = ('LanguageDetectorBuilder', 'LanguageDetector', 'IsoCode639_1', 'IsoCode639_3', 'Language', 'LanguageModelFilesWriter', 'TestDataFilesWriter') + from .builder import LanguageDetectorBuilder from .detector import LanguageDetector from .isocode import IsoCode639_1, IsoCode639_3