Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jkauerl
Copy link
Contributor

@jkauerl jkauerl commented Jul 1, 2024

Summary

This is the implementation for the new rule of pycodestyle (E204). It follows the guidlines described in the contributing site, and as such it has a new file named whitespace_after_decorator.rs, a new test file called E204.py, and as such invokes the function in the AST statement checker for functions and functions in classes. Linking #2402 because it has all the pycodestyle rules.

Test Plan

The file E204.py, has a decorator defined called wrapper, and this decorator is used for 2 cases. The first one is when a function which has a decorator is called in the file, and the second one is when there is a class and 2 methods are defined for the class with a decorator attached it.

Test file:

def foo(fun):
    def wrapper():
        print('before')
        fun()
        print('after')
    return wrapper

# No error
@foo
def bar():
    print('bar')

# E204
@ foo
def baz():
    print('baz')

class Test:
    # No error
    @foo
    def bar(self):
        print('bar')

    # E204
    @ foo
    def baz(self):
        print('baz')

I am still new to rust and any suggestion is appreciated. Specially with the way im using native ruff utilities.

@jkauerl jkauerl marked this pull request as ready for review July 3, 2024 10:37
@jkauerl jkauerl changed the title [pycodestyle] Whitespace after decorator (E204) [pycodestyle] Whitespace after decorator (E204) Jul 4, 2024
@charliermarsh charliermarsh self-requested a review July 4, 2024 23:11
@charliermarsh charliermarsh added rule Implementing or modifying a lint rule preview Related to preview mode features labels Jul 4, 2024
Copy link
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.

Thanks! I added a fix too.

@charliermarsh charliermarsh force-pushed the whitespace-after-decorator branch from 306995a to 858ea10 Compare July 4, 2024 23:23
@charliermarsh charliermarsh enabled auto-merge (squash) July 4, 2024 23:23
@charliermarsh charliermarsh force-pushed the whitespace-after-decorator branch from 858ea10 to 0dfec9c Compare July 4, 2024 23:26
@charliermarsh charliermarsh merged commit 1e07bfa into astral-sh:main Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants