You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Argument 1 to "fields" has incompatible type "type[AttrsInstance]"; expected an attrs class #16254
mypy is reporting that a type[attrs.AttrsInstance] is not a valid argument to attrs.fields
To Reproduce
from __future__ importannotationsimportattrs@attrs.defineclassX:
x: intattrs.fields(X) # finedeffunc(klass: type[attrs.AttrsInstance]) ->None:
fields=attrs.fields(klass) # errorprint(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
$ .venv/bin/mypy test.py
exp.py:7: error: Argument 1 to "fields" has incompatible type"type[MyClass]"; expected an attrs class [misc]
return attr.fields(cls)
^~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)
Activity
Ranfir commentedon Oct 12, 2023
I'm also seeing this in 1.6, but not 1.5.1.
awerchniak commentedon Oct 19, 2023
I started seeing this when my mypy version jumped from 1.5.1 -> 1.6.1. No difference in my source code or attrs version. Code to reproduce:
we can then see:
jp-larose commentedon Oct 24, 2023
I am too. However, I tested with the latest from
master, and it seems to be fixed 🤞. So I would expect the fix to be included in the next release.ikonst commentedon Oct 24, 2023
This was fixed in #15983.
Redoubts commentedon Oct 24, 2023
Do you know if we will get a 1.6.2 cut with this fix?
AlexWaygood commentedon Oct 24, 2023
Probably not; mypy 1.7 is expected soon, I believe. But @hauntsaninja has been managing patch releases for mypy 1.6, so it'll be up to him to decide