Skip to content

[ty] Add snapshots for __init_subclass__ diagnostics#24539

Merged
AlexWaygood merged 1 commit intomainfrom
alex/init-subclass-diags
Apr 10, 2026
Merged

[ty] Add snapshots for __init_subclass__ diagnostics#24539
AlexWaygood merged 1 commit intomainfrom
alex/init-subclass-diags

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

Summary

If you pass incorrect keyword arguments when creating a class, we emit a diagnostic for the bad implicit call to __init_subclass__. That's great, except the range of this diagnostic is currently the whole class node, which can be huge if the class has lots of statements in it (most classes do).

This PR adds some snapshots that demonstrate this issue. I'll improve the diagnostic range in a followup PR after the baseline has been established in our test suite.

@AlexWaygood AlexWaygood added testing Related to testing Ruff itself ty Multi-file analysis & type inference labels Apr 10, 2026
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Great, thanks.

@AlexWaygood AlexWaygood enabled auto-merge (squash) April 10, 2026 13:30
@AlexWaygood AlexWaygood merged commit a07f3cf into main Apr 10, 2026
49 checks passed
@AlexWaygood AlexWaygood deleted the alex/init-subclass-diags branch April 10, 2026 13:32
carljm added a commit that referenced this pull request Apr 10, 2026
* main:
  [ty] Fix bad diagnostic range for incorrect implicit `__init_subclass__` calls (#24541)
  [ty] Add a `SupportedPythonVersion` enum (#24412)
  [ty] Ignore unsupported editor-selected Python versions (#24498)
  [ty] Add snapshots for `__init_subclass__` diagnostics (#24539)
  [ty] Minor fix in tests (#24538)
  [ty] Allow `Final` variable assignments in `__post_init__` (#24529)
  [ty] Expand test suite for assignment errors (#24537)
  [ty] Use `map`, not `__map`, as the name of the mapping parameter in `TypedDict` `__init__` methods (#24535)
  [ty] Rework logic for synthesizing `TypedDict` methods (#24534)
  [flake8-bandit] Fix S103 false positives and negatives in mask analysis (#24424)
  [ty] mdtest.py: update dependencies (#24533)
  Rename patterns and arguments source order iterator method (#24532)
  [ty] Omit invalid keyword arguments from `TypedDict` signature (#24522)
  [ty] support super() in metaclass methods (#24483)
  [ty] Synthesize `__init__` for `TypedDict` (#24476)
carljm added a commit that referenced this pull request Apr 10, 2026
* main:
  Bump typing conformance suite commit to latest upstream (#24553)
  [ty] Reject deleting`Final` attributes (#24508)
  [ty] Respect property deleters in attribute deletion checks (#24500)
  [ty] stop unioning Unknown into types of un-annotated attributes (#24531)
  [ty] Fix bad diagnostic range for incorrect implicit `__init_subclass__` calls (#24541)
  [ty] Add a `SupportedPythonVersion` enum (#24412)
  [ty] Ignore unsupported editor-selected Python versions (#24498)
  [ty] Add snapshots for `__init_subclass__` diagnostics (#24539)
  [ty] Minor fix in tests (#24538)
  [ty] Allow `Final` variable assignments in `__post_init__` (#24529)
  [ty] Expand test suite for assignment errors (#24537)
  [ty] Use `map`, not `__map`, as the name of the mapping parameter in `TypedDict` `__init__` methods (#24535)
  [ty] Rework logic for synthesizing `TypedDict` methods (#24534)
  [flake8-bandit] Fix S103 false positives and negatives in mask analysis (#24424)
  [ty] mdtest.py: update dependencies (#24533)
  Rename patterns and arguments source order iterator method (#24532)
  [ty] Omit invalid keyword arguments from `TypedDict` signature (#24522)
  [ty] support super() in metaclass methods (#24483)
  [ty] Synthesize `__init__` for `TypedDict` (#24476)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants