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

Type annotation for attr.ib wrappers functions

Open
#779 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the example with mypy 0.812, Python 3.7.3, and attrs 20.3.0, focusing on the unexpected keyword argument for the wrapped attribute. Then inspect the attrs typing integration and determine what support is needed; done means the example type-checks without the acme error.

Written by the indexing model from the issue text.

Description

Bug Typing

It's possible to type a method that wraps an attr.ib attribute?

Example:

import attr
from typing import Any

def typed() -> Any:
    return attr.ib(type=str)

@attr.s
class TestingParams:
    foo = attr.ib(type=str)
    acme = typed()

TestingParams(foo='1', acme='3')

Executing mypy (0.812) with Python (3.7.3) and attrs (20.3.0) I got the following output

error: Unexpected keyword argument "acme" for "TestingParams"  [call-arg]
Dominant language
Python
Stars
5.8k
Forks
480
Avg merge
2h 15m
Merged PRs (30d)
2

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 python-attrs/attrs

All issues in python-attrs/attrs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.