Skip to content

Commit

Permalink
Add rationale doc to lazy importer
Browse files Browse the repository at this point in the history
  • Loading branch information
sirosen committed Nov 8, 2024
1 parent adcd1ff commit 424ff09
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/globus_sdk/_lazy_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@
then if `foo.pyi` has an import `from .bar import BarType`, it is possible to
*read* `foo.pyi` at runtime and use that information to load
`BarType` from `bar`.
Rationale
---------
Why use this type of lazy importer?
The major goals are:
- type information is still available to type checkers (and other tools like IDEs)
- we minimize manual duplication of names
- we minimize specialized knowledge needed to update our package exports
- the lazy importer itself is easy to maintain and update
``.pyi`` type stubs are designed for use with type checkers. The data format choice here
is "regular type stubs". We treat it as runtime data, which is a bit unusual, but we
are guaranteed that `mypy` and other tools can understand it without issue.
We reduce duplication with this technique, and the content in the ``.pyi`` file should
be easy for most developers to read and modify.
"""

from __future__ import annotations
Expand Down

0 comments on commit 424ff09

Please sign in to comment.