Usage and community perspectives on mypy --no-implicit-reexport in library development

In my personal projects, I often enable mypy --strict --no-implicit-reexport. I appreciate the explicit control this offers over module exports, even though stubs provide additional flexibility. This has piqued my curiosity about the broader Python community’s stance on this option.

How prevalent is the use of --no-implicit-reexport? Do you consider it a niche setting suitable for exceptionally clean codebases, or should we expect third-party libraries to also adhere to these explicit reexport standards?

Interestingly, I rarely encounter issues with external libraries only implicitly reexporting symbols. However, I recently faced this with a library known for its robust type annotations. After reporting the issue, the developers were receptive.

This experience leads me to wonder: Is it generally advisable to report such issues to maintainers of libraries with high-quality type annotations, or might such reports be viewed as bothersome rather than helpful? I’m interested in hearing your experiences and perspectives on this matter.

--strict implies --no-implicit-reexport, so I’d say it’s quite widely used.

Note that you can set this setting on a per-module basis using mypy configuration overrides, in case a library you use implicitly exports symbols. Also make sure to use latest mypy, I think there are some improvements I made recently around preserving types in cases where you end up using an implicitly exported symbol and are okay with that.

My guess is libraries that are clearly committed to high quality type annotations would usually be receptive to issues / PRs about this. The only example I can remember of a generally on board with types project specifically disliking --no-implicit-reexport is Pallets projects, although they eventually accepted it.

More generally — if your issue report comes with a thank you, a PR, and no implicit expectation that your no implicit export change will be accepted, maintainers are less likely to view it as bothersome.

2 Likes