mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00:00

## Summary Fixes https://github.com/astral-sh/ruff/issues/10039 The [recommendation for typing stub files](https://typing.readthedocs.io/en/latest/source/stubs.html#blank-lines) is to use **one** blank line to group related definitions and otherwise omit blank lines. The newly added blank line rules (`E3*`) didn't account for typing stub files and enforced two empty lines at the top level and one empty line otherwise, making it impossible to group related definitions. This PR implements the `E3*` rules to: * Not enforce blank lines. The use of blank lines in typing definitions is entirely up to the user. * Allow at most one empty line, including between top level statements. ## Test Plan Added unit tests (It may look odd that many snapshots are empty but the point is that the rule should no longer emit diagnostics)
50 lines
691 B
Python
50 lines
691 B
Python
import json
|
|
|
|
from typing import Any, Sequence
|
|
|
|
class MissingCommand(TypeError): ...
|
|
class AnoherClass: ...
|
|
|
|
def a(): ...
|
|
|
|
@overload
|
|
def a(arg: int): ...
|
|
|
|
@overload
|
|
def a(arg: int, name: str): ...
|
|
|
|
|
|
def grouped1(): ...
|
|
def grouped2(): ...
|
|
def grouped3( ): ...
|
|
|
|
|
|
class BackendProxy:
|
|
backend_module: str
|
|
backend_object: str | None
|
|
backend: Any
|
|
|
|
def grouped1(): ...
|
|
def grouped2(): ...
|
|
def grouped3( ): ...
|
|
@decorated
|
|
|
|
def with_blank_line(): ...
|
|
|
|
|
|
def ungrouped(): ...
|
|
a = "test"
|
|
|
|
def function_def():
|
|
pass
|
|
b = "test"
|
|
|
|
|
|
def outer():
|
|
def inner():
|
|
pass
|
|
def inner2():
|
|
pass
|
|
|
|
class Foo: ...
|
|
class Bar: ...
|