[ruff] Added cls.__dict__.get('__annotations__') check (RUF063) by dericcrago · Pull Request #18233 · astral-sh/ruff (original) (raw)

@AlexWaygood added the rule

Implementing or modifying a lint rule

label

May 20, 2025

JelleZijlstra

JelleZijlstra

ntBre

@ntBre ntBre mentioned this pull request

Jun 5, 2025

@dericcrago

Python < 3.10 with typing_extensions enabled.

@dericcrago

@dericcrago

@dericcrago

@dericcrago @ntBre

Co-authored-by: Brent Westbrook 36778786+ntBre@users.noreply.github.com

@dericcrago

@dericcrago

@dericcrago

@dericcrago

@dericcrago

@dericcrago

@dericcrago

This commit renames the rule from AnnotationsFromClassDict to AccessAnnotationsFromClassDict to better reflect its expanded scope.

The rule has been extended to detect direct subscript access (e.g., foo.__dict__["__annotations__"]), in addition to the existing check for foo.__dict__.get("__annotations__") method calls.

This change provides more comprehensive detection of this discouraged access pattern.

@MichaReiser

@MichaReiser

@ntBre ntBre changed the titleAdded cls.__dict__.get('__annotations__') check [ruff] Added cls.__dict__.get('__annotations__') check (RUF063)

Jun 20, 2025

dcreager added a commit that referenced this pull request

Jun 20, 2025

@dcreager

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})