KotlinIsland / KotlinIsland/basedmypy
type imports
- Dominant language
- Python
- Stars
- 202
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Currently type only imports suck
```py
if TYPE_CHECKING:
from x import Y
```
This sucks because then they don't exist at runtime
What about something like:
```py
Y = Import["from x import Y"] # or maybe "x.Y"
```
Then it:
1. exists as a local name
2. isn't actually imported
3. can be imported later when forward refs are being determined
4. doesn't screw with mypys module loading analysis
5. doesn't have gross typetime/runtime code blocks
```py
class X:
y: Y
get_type_hints(X) # resolves the import
```
Contributor guide
Research direction
Start by examining how basedmypy handles type-only imports, forward references, and mypy module-loading analysis. Define the behavior of the proposed Import expression, including runtime name availability and get_type_hints(X) resolution, before identifying the affected implementation and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100