mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-31 12:05:57 +00:00 
			
		
		
		
	 1e07bfa373
			
		
	
	
		1e07bfa373
		
			
		
	
	
	
	
		
			
			## Summary <!-- What's the purpose of the change? What does it do, and why? --> 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 <!-- How was it tested? --> 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: ``` python 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. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
		
			
				
	
	
		
			34 lines
		
	
	
	
		
			384 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			384 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 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')
 | |
| 
 | |
| 
 | |
| # E204
 | |
| @ \
 | |
| foo
 | |
| def baz():
 | |
|     print('baz')
 |