Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pycodestyle] Whitespace after decorator (E204) #12140

Merged
merged 12 commits into from
Jul 4, 2024

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 enabled auto-merge (squash) July 4, 2024 23:23
@charliermarsh charliermarsh merged commit 1e07bfa into astral-sh:main Jul 4, 2024
18 checks passed
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