python-attrs / python-attrs/attrs

Adding runtime_checkable to AttrsInstance

Open
#1,388 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature
Dominant language
Python
Stars
5.8k
Forks
480
Avg merge
2h 15m
Merged PRs (30d)
2

Description

Is it possible to add the runtime_checkable decorator to AttrsInstance protocol?

https://github.com/python-attrs/attrs/blob/598494a618410490cfbe0c896b7a544f6d23e0d9/src/attr/__init__.py#L37-L38

In my project, I am working on a decorator that automates converting a dict into an AttrsInstance.
To perform reflection checks on input definitions, I found myself needing to subclass AttrsInstance without modifying it—just to add the runtime_checkable decorator.
It would be incredibly helpful if the attrs library's definition already included runtime_checkable.

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.

Research direction

Read src/attr/init.py at lines 37-38, where AttrsInstance is defined. Add the requested runtime_checkable support and verify that callers can perform runtime checks on AttrsInstance without subclassing it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.