SIGN IN SIGN UP
astral-sh / ruff UNCLAIMED

An extremely fast Python linter and code formatter, written in Rust.

0 0 36 Rust

[ty] Introduce opt-in `missing-override-decorator` rule. (#25111)

<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
  requests.)
- Does this pull request include references to any relevant issues?
- Does this PR follow our AI policy
(https://github.com/astral-sh/.github/blob/main/AI_POLICY.md)?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

This adds a new rule called `missing-override-decorator` that allows
users to opt into `@override` enforcement. The rule is ignored by
default.

When the rule is enabled, ty will report a missing override decorator on
an override of any method other than `__init__`, `__new__`,
`__init_subclass__` or `__post_init__`. This matches the general
strategy taken by other type checkers (see discussion starting
[here](https://github.com/astral-sh/ruff/pull/25111#issuecomment-4501847451)).

Closes https://github.com/astral-sh/ty/issues/155.

## Test Plan

Please see included tests.

Note that my approach to testing this feature departs from precedent in
that, unlike other rules, `missing-override-decorator` is not enabled by
default in our test suite. I think we can and should change this in
follow-ups, but for the moment that choice makes this PR easier to
review by eliminating churn in unrelated tests.
L
Lérè committed
f266e8f99d6e9f27380de3963b3d5c01f87a1150
Parent: 2110d32
Committed by GitHub <noreply@github.com> on 5/29/2026, 5:47:56 AM