KotlinIsland / KotlinIsland/basedtyping

Make `assert_type` use `ReifiedGeneric` so that it can check at runtime

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
reified generics runtime todo
Dominant language
Python
Stars
12
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Make `assert_type` use `ReifiedGeneric` so that it can check at runtime.

https://github.com/KotlinIsland/basedtyping/blob/997af522c978e0a5254cfcfe0ab3070219f432ab/basedtyping/typetime_only.py#L24

```python
class assert_type(Generic[T]):
"""Used to assert that a value is type ``T``.

note: This is more like a function than a class,
but it's defined as a class so that you can explicitly specify the generic.
"""

# TODO: make this use ReifiedGeneric so that it can check at runtime
# None return type on __new__ is supported in pyright but not mypy
def __new__(cls, _value: T) -> None: # type: ignore[misc]
pass

```

6accd9872dcd509eea9f2a1ce1cd2138f21bd85f

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with basedtyping/typetime_only.py around line 24 and read the existing ReifiedGeneric implementation to understand its runtime behavior. Update assert_type to use that mechanism so the requested runtime type check works, then verify the relevant typing behavior against the project’s existing checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.