explosion/thinc

Type checkers don't like non-literal `__all__` in `thinc.api` for exposing the public interface

willfrey opened this issue · 2 comments

If you forbid implicit reexports in Mypy (or turn Pyright/Pylance on at all), the type checkers will complain about thinc.api not exposing anything publicly. This is because the imports are of the form from name import target and __all__ can only be inferred at runtime.

Would there be any objection to doing either of the following?

  1. Explicitly re-export names in thinc.api through imports of the form from namespace import target as target.
  2. Change __all__ to be made up of string literals for each public member in thinc.api.

The first option eliminates the need for a __all__ entirely, if you're concerned about having to repeat each public interface member three times.

If you're okay with either (or both), I'm happy to make the changes and open a PR.

Thank you!

Hi! Thanks for the report, we'll have a look how best to address this issue!

Thanks!