Skip to content

Make kw_only on a class only change fields on that class#97

Merged
DavidCEllis merged 1 commit intomainfrom
kwonly-fixes
Apr 27, 2026
Merged

Make kw_only on a class only change fields on that class#97
DavidCEllis merged 1 commit intomainfrom
kwonly-fixes

Conversation

@DavidCEllis
Copy link
Copy Markdown
Owner

Currently if a class is kw_only, all fields on that class are made keyword only for that class only.

This change makes it so it only affects fields defined specifically on that class which will make subclasses more properly substitutable. This also means classes inheriting from kw_only classes will now have the fields defined on the keyword only class as keyword only.

This behaviour should match that of attrs and dataclasses.

@DavidCEllis DavidCEllis merged commit 225ede0 into main Apr 27, 2026
8 checks passed
@DavidCEllis DavidCEllis deleted the kwonly-fixes branch April 28, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kw_only on a class should make the fields defined on that class keyword only, not the entire class

1 participant