Skip to content

Type annotation for attr.ib wrappers functions  #779

Open
@williamjamir

Description

@williamjamir

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTypingTyping/stub/Mypy/PyRight related bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions