python-attrs / python-attrs/attrs

Subclassed decorator methods not working

Open
#753 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

My framework relies on (smart) subclassing, but I've also got it to work with attrs mostly. Running into a problem like the following.

@attr.s
class BaseClass():
    
    value = attr.ib(default=10)

@attr.s
class TestClass(BaseClass):
    
    @value.default
    def _not_value(self):
        return 20

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

Start by reproducing the reported example using attr.s, attr.ib, and the inherited value.default decorator. Trace how subclassed attributes and decorator methods are handled, then establish the intended behavior for TestClass before adding a regression test and confirming the example works.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.