Skip to content

E301 is inconsistent with flake8 #19752

@whitequark

Description

@whitequark

Summary

Playground link

In this snippet:

class foo:
    async def recv(self, *, length=65536):
        loop = asyncio.get_event_loop()
        def callback():
            loop.remove_reader(self._fd)
        loop.add_reader(self._fd, callback)

It appears that ruff applies E301 blank-line-between-methods to foo.recv.callback because it is "within" a class node, but flake8 (correctly) does not apply E301 to it because it is not "immediately within" a class node and is not actually a method.

(I do weird things within methods but not outside of them.)

Version

ruff 0.12.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions