Skip to content

[ruff] Add exception for ctypes.Structure._fields_ (RUF012)#22559

Merged
ntBre merged 4 commits intoastral-sh:mainfrom
caiquejjx:fix-22166
Jan 15, 2026
Merged

[ruff] Add exception for ctypes.Structure._fields_ (RUF012)#22559
ntBre merged 4 commits intoastral-sh:mainfrom
caiquejjx:fix-22166

Conversation

@caiquejjx
Copy link
Contributor

Closes #22166

Summary

Adds an exception for ctypes.Structure._fields_ to the rule RUF012 as it has it's own way of enforcing immutability:

The fields class variable can only be set once. Later assignments will raise an AttributeError.

@amyreese amyreese added the rule Implementing or modifying a lint rule label Jan 13, 2026
@amyreese
Copy link
Member

Can you add a test case to the snapshots demonstrating the expected passing case?

@caiquejjx
Copy link
Contributor Author

@amyreese Done, thanks

@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 14, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks great.

I'm just waiting on the release today to finish to merge this.

@ntBre ntBre changed the title [RUF012] Add exception for ctypes.Structure._fields_ [ruff] Add exception for ctypes.Structure._fields_ (RUF012) Jan 15, 2026
@ntBre ntBre enabled auto-merge (squash) January 15, 2026 20:45
@ntBre ntBre merged commit 0ce5ce4 into astral-sh:main Jan 15, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUF012 warns for ctypes Structure._fields_

3 participants