Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Support `Literal` types

Open
#274 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

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

enhancement

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dry-python/classes

All issues in dry-python/classes

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.