Skip to content

Commit 5e82813

Browse files
committed
Add information that pyi files are used in runtime when use attach_stub
1 parent acbce79 commit 5e82813

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ lazily loaded imports. As a workaround you can load [type
7979
stubs](https://mypy.readthedocs.io/en/stable/stubs.html) (`.pyi`
8080
files) with `lazy.attach_stub`.
8181

82+
```python
83+
import lazy_loader as lazy
84+
__getattr__, __dir__, _ = lazy.attach_stub(__name__, "subpackages.pyi")
85+
```
86+
87+
In such scenario the `lazy_loader` determine imports base on `.pyi`,
88+
so `.pyi` files are then required not only for type checking but also in runtime.
89+
(during freezing app that uses library using `lazy_loader` it is required to collect also `.pyi` files)
90+
8291
The SPEC [describes this workaround in more
8392
detail](https://scientific-python.org/specs/spec-0001/#type-checkers).
8493

0 commit comments

Comments
 (0)