mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 18:02:58 +00:00
Allow up to two empty lines after top-level imports (#6777)
## Summary For imports, we enforce that there's _at least_ one empty line after an import (assuming the next statement is _not_ an import), but allow up to two at the module level. Closes https://github.com/astral-sh/ruff/issues/6760. ## Test Plan `cargo test`
This commit is contained in:
parent
558b56f8a8
commit
cc278c24e2
3 changed files with 176 additions and 1 deletions
|
@ -1,3 +1,58 @@
|
|||
from a import aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
|
||||
from a import aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa, aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa
|
||||
from a import aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa as dfgsdfgsd, aksjdhflsakhdflkjsadlfajkslhfdkjsaldajlahflashdfljahlfksajlhfajfjfsaahflakjslhdfkjalhdskjfa as sdkjflsdjlahlfd
|
||||
|
||||
# At the top-level, force one empty line after an import, but allow up to two empty
|
||||
# lines.
|
||||
import os
|
||||
import sys
|
||||
x = 1
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
x = 1
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
x = 1
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
x = 1
|
||||
|
||||
|
||||
# In a nested scope, force one empty line after an import.
|
||||
def func():
|
||||
import os
|
||||
import sys
|
||||
x = 1
|
||||
|
||||
|
||||
def func():
|
||||
import os
|
||||
import sys
|
||||
|
||||
x = 1
|
||||
|
||||
|
||||
def func():
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
x = 1
|
||||
|
||||
|
||||
def func():
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
x = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue