Skip to content

Ban subclassing dataclasses with order=True#3804

Open
ak4-sh wants to merge 2 commits into
facebook:mainfrom
ak4-sh:ban-order-dataclass-subclassing
Open

Ban subclassing dataclasses with order=True#3804
ak4-sh wants to merge 2 commits into
facebook:mainfrom
ak4-sh:ban-order-dataclass-subclassing

Conversation

@ak4-sh

@ak4-sh ak4-sh commented Jun 13, 2026

Copy link
Copy Markdown

Summary

Adds an invalid-inheritance error when a class subclasses a dataclass that has order=True.

Fixes #3762

Test Plan

Added test test_parent_dataclass_with_order to confirm behaviour

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Feat: add stlib origin flag in Dataclass Metadata

Feat: only raise inheritance warning when subclassing ordered dataclass

Add tests to confirm ordered dataclass behaviour

Update docs with new errorkind
@ak4-sh ak4-sh force-pushed the ban-order-dataclass-subclassing branch from 82ea78a to 5b3c20f Compare June 20, 2026 19:54
@ak4-sh

ak4-sh commented Jun 20, 2026

Copy link
Copy Markdown
Author

@yangdanny97 Made the changes we discussed! Please let me know if all looks okay

@ak4-sh ak4-sh force-pushed the ban-order-dataclass-subclassing branch from 7e1ea88 to 08f1344 Compare June 20, 2026 20:22
@github-actions github-actions Bot added size/m and removed size/m labels Jun 20, 2026
@yangdanny97 yangdanny97 self-assigned this Jun 21, 2026
@meta-codesync

meta-codesync Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D109264971.

@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

reconcile latest master changes with branch

run cargo fmt
@ak4-sh ak4-sh force-pushed the ban-order-dataclass-subclassing branch from 08f1344 to a73dbf6 Compare June 22, 2026 19:54
@github-actions github-actions Bot added size/m and removed size/m labels Jun 22, 2026
@ak4-sh

ak4-sh commented Jun 22, 2026

Copy link
Copy Markdown
Author

I think linter was failing to due to me not running cargo fmt after some previous changes, I've run the fmt and pushed changes. Should be good now hopefully. Sorry about this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new rule - ban subtyping dataclass with order=True

2 participants