Support `Literal` types
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start by tracing how typeclass, AssociatedType, Supports, and @some.instance handle delegated types, then compare that path with the Literal[1] example. Done means the example type-checks and some(1) resolves correctly through the Literal registration, with the existing delegate behavior preserved.
Written by the indexing model from the issue text.
Description
After we have delegate in-place we can use Literal types.
But, now they are not supported.
Ideally, something like this should work:
from classes import typeclass, AssociatedType, Supports
from typing_extensions import Literal
class SomeDelegate(object):
... # TODO: write proper `__instancecheck__`
class A(AssociatedType):
...
@typeclass(A)
def some(instance) -> int:
...
@some.instance(Literal[1], delegate=SomeDelegate)
def _some_tuple(instance: Literal[1]) -> int:
return instance
def test(i: Supports[A]):
return some(i)
some(1)
- Dominant language
- Python
- Stars
- 730
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dry-python/classes
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
dry-python/classes#496 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
dry-python/classes#494 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
dry-python/classes#492 · 2 comments ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
dry-python/classes#481 · 5 comments · 4 reactions ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
dry-python/classes#386 ·
All issues in dry-python/classes
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
browser-use/browser-use#5905 ·
-
type: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ynput/ayon-python-api#363 ·
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
modelscope/FunASR#3728 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
open-compass/opencompass#2655 ·