Skip to content

Conversation

Luunynliny
Copy link
Contributor

Summary

Fixes #19385.

Based on unnecessary-placeholder (PIE790) behavior, ellipsis-in-non-empty-class-body (PYI013) now safely preserve inline comment on ellipsis removal.

Test Plan

A new test class was added:

class NonEmptyChildWithInlineComment:
    value: int
    ... # preserve me

with the following expected fix:

class NonEmptyChildWithInlineComment:
    value: int
    # preserve me

@Luunynliny Luunynliny requested a review from AlexWaygood as a code owner July 17, 2025 14:11
@ntBre ntBre added bug Something isn't working fixes Related to suggested fixes for violations labels Jul 17, 2025
@ntBre ntBre self-requested a review July 24, 2025 13:08
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.

Very nice, thank you! And apologies for the delay in reviewing this.

I had a couple of small nits, but the overall fix looks perfect.

Copy link
Contributor

github-actions bot commented Jul 28, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre
Copy link
Contributor

ntBre commented Jul 28, 2025

Don't worry about the ecosystem changes yet. I think it's relative to main when the PR was opened rather than when it actually ran. After we push any changes I expect that to update to something more reasonable.

@AlexWaygood AlexWaygood removed their request for review July 28, 2025 23:12
@Luunynliny Luunynliny requested a review from ntBre July 28, 2025 23:51
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!

@ntBre ntBre changed the title [flake8-pyi] Preserve inline comment in ellipsis removal (PYI013) [flake8-pyi] Preserve inline comment in ellipsis removal (PYI013) Jul 29, 2025
@ntBre ntBre merged commit ae26fa0 into astral-sh:main Jul 29, 2025
35 checks passed
dcreager added a commit that referenced this pull request Aug 1, 2025
* main: (24 commits)
  Add `Checker::context` method, deduplicate Unicode checks (#19609)
  [`flake8-pyi`] Preserve inline comment in ellipsis removal (`PYI013`) (#19399)
  [ty] Add flow diagram for import resolution
  [ty] Add comments to some core resolver functions
  [ty] Add missing ticks and use consistent quoting
  [ty] Reflow some long lines
  [ty] Unexport helper function
  [ty] Remove offset from `CompletionTargetTokens::Unknown`
  [`pyupgrade`] Fix `UP030` to avoid modifying double curly braces in format strings (#19378)
  [ty] fix a typo  (#19621)
  [ty] synthesize `__replace__` for dataclasses (>=3.13) (#19545)
  [ty] Discard `Definition`s when normalizing `Signature`s (#19615)
  [ty] Fix empty spans following a line terminator and unprintable character spans in diagnostics (#19535)
  Add `LinterContext::settings` to avoid passing separate settings (#19608)
  Support `.pyi` files in ruff analyze graph (#19611)
  [ty] Sync vendored typeshed stubs (#19607)
  [ty] Bump docstring-adder pin (#19606)
  [`perflint`] Ignore rule if target is `global` or `nonlocal` (`PERF401`) (#19539)
  Add license classifier back to pyproject.toml (#19599)
  [ty] Add stub mapping support to signature help (#19570)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PYI013 fix deletes comments
2 participants