attrs icon indicating copy to clipboard operation
attrs copied to clipboard

kw_only=True in class cannot be overridden by attributes

Open euresti opened this issue 6 years ago • 5 comments

Mostly wondering if this is expected/desired:

import attr
@attr.s(kw_only=True)
class A:
    a = attr.ib(kw_only=False)

A(1)  # Error

euresti avatar Dec 27 '18 21:12 euresti

That’s a good question. It’s inconsistent with other settings where attribute settings always take precedence over class settings. Kw_only is kind of special but probably not special enough to break that contract? 🤔

hynek avatar Dec 28 '18 04:12 hynek

Let me know if this changes because I'll have to update the mypy plugin. (Currently it's written with the current behavior)

euresti avatar Dec 29 '18 22:12 euresti

Just wondering if there's still planned support for overriding the class kw_only=True setting in attributes? I don't think this is supported as of v21.2.0.

huzecong avatar Oct 22 '21 21:10 huzecong

“Planned” is a strong word, but a good PR has good chances to get merged.

hynek avatar Oct 23 '21 09:10 hynek

I think I'll do some brain-storming on this.

chrysle avatar Apr 06 '23 19:04 chrysle