Commit 3fbbeb3
Use TYPE_CHECKING pattern for nlpo3 to retain type info with lazy imports
This solves the issue of balancing type information with optional dependencies:
- Imports nlpo3 types only during type checking (TYPE_CHECKING block)
- Does lazy imports inside functions for runtime
- Provides helpful error messages when nlpo3 is not installed
- Mypy can still see and use nlpo3's type information
- Module can be imported even when nlpo3 is not installed
Benefits:
✅ Type checking works (mypy sees nlpo3 types)
✅ No import errors when nlpo3 is not installed
✅ Functionality works when nlpo3 is installed
✅ nlpo3 stays OUT of mypy ignore list
Co-authored-by: bact <128572+bact@users.noreply.github.com>1 parent c7074d1 commit 3fbbeb3
1 file changed
Lines changed: 25 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
| |||
57 | 66 | | |
58 | 67 | | |
59 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
60 | 76 | | |
61 | 77 | | |
62 | 78 | | |
| |||
87 | 103 | | |
88 | 104 | | |
89 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
90 | 113 | | |
91 | 114 | | |
92 | 115 | | |
| |||
0 commit comments