Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Argument 1 to "fields" has incompatible type "type[AttrsInstance]"; expected an attrs class #16254

@Redoubts

Description

@Redoubts

Bug Report

mypy is reporting that a type[attrs.AttrsInstance] is not a valid argument to attrs.fields

To Reproduce

from __future__ import annotations

import attrs


@attrs.define
class X:
    x: int


attrs.fields(X) # fine


def func(klass: type[attrs.AttrsInstance]) -> None:
    fields = attrs.fields(klass) # error
    print(fields)


func(X) # fine

Expected Behavior

% mypy x.py
Success: no issues found in 1 source file

Actual Behavior

% mypy x.py
x.py:15: error: Argument 1 to "fields" has incompatible type "type[AttrsInstance]"; expected an attrs class [misc]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.6
  • Mypy command-line flags: (w/ or w/o --no-incremental)
  • Mypy configuration options from mypy.ini (and other config files): default
  • Python version used: 3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions