-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into plw0603-global-statement
- Loading branch information
Showing
52 changed files
with
1,630 additions
and
94 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
crates/ruff/resources/test/fixtures/flake8_django/DJ003.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.shortcuts import render | ||
|
||
|
||
def test_view1(request): | ||
return render(request, "index.html", locals()) | ||
|
||
|
||
def test_view2(request): | ||
return render(request, "index.html", context=locals()) | ||
|
||
|
||
def test_view3(request): | ||
return render(request, "index.html") | ||
|
||
|
||
def test_view4(request): | ||
return render(request, "index.html", {}) | ||
|
||
|
||
def test_view5(request): | ||
return render(request, "index.html", context={}) |
11 changes: 11 additions & 0 deletions
11
crates/ruff/resources/test/fixtures/flake8_django/DJ006.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django import forms | ||
|
||
|
||
class TestModelForm1(forms.ModelForm): | ||
class Meta: | ||
exclude = ["bar"] | ||
|
||
|
||
class TestModelForm2(forms.ModelForm): | ||
class Meta: | ||
fields = ["foo"] |
16 changes: 16 additions & 0 deletions
16
crates/ruff/resources/test/fixtures/flake8_django/DJ007.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django import forms | ||
|
||
|
||
class TestModelForm1(forms.ModelForm): | ||
class Meta: | ||
fields = "__all__" | ||
|
||
|
||
class TestModelForm2(forms.ModelForm): | ||
class Meta: | ||
fields = b"__all__" | ||
|
||
|
||
class TestModelForm3(forms.ModelForm): | ||
class Meta: | ||
fields = ["foo"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
def f12( | ||
x, | ||
y: str = os.pathsep, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f11(*, x: str = "x") -> None: # OK | ||
... | ||
|
||
|
||
def f13( | ||
x: list[str] = [ | ||
"foo", | ||
"bar", | ||
"baz", | ||
] # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f14( | ||
x: tuple[str, ...] = ( | ||
"foo", | ||
"bar", | ||
"baz", | ||
) # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f15( | ||
x: set[str] = { | ||
"foo", | ||
"bar", | ||
"baz", | ||
} # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f16(x: frozenset[bytes] = frozenset({b"foo", b"bar", b"baz"})) -> None: # OK | ||
... | ||
|
||
|
||
def f17( | ||
x: str = "foo" + "bar", # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f18( | ||
x: str = b"foo" + b"bar", # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f19( | ||
x: object = "foo" + 4, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f20( | ||
x: int = 5 + 5, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f21( | ||
x: complex = 3j - 3j, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f22( | ||
x: complex = -42.5j + 4.3j, # OK | ||
) -> None: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
def f12( | ||
x, | ||
y: str = os.pathsep, # Error PYI011 Only simple default values allowed for typed arguments | ||
) -> None: ... | ||
def f11(*, x: str = "x") -> None: ... # OK | ||
def f13( | ||
x: list[ | ||
str | ||
] = [ # Error PYI011 Only simple default values allowed for typed arguments | ||
"foo", | ||
"bar", | ||
"baz", | ||
] | ||
) -> None: ... | ||
def f14( | ||
x: tuple[ | ||
str, ... | ||
] = ( # Error PYI011 Only simple default values allowed for typed arguments | ||
"foo", | ||
"bar", | ||
"baz", | ||
) | ||
) -> None: ... | ||
def f15( | ||
x: set[ | ||
str | ||
] = { # Error PYI011 Only simple default values allowed for typed arguments | ||
"foo", | ||
"bar", | ||
"baz", | ||
} | ||
) -> None: ... | ||
def f16( | ||
x: frozenset[ | ||
bytes | ||
] = frozenset( # Error PYI011 Only simple default values allowed for typed arguments | ||
{b"foo", b"bar", b"baz"} | ||
) | ||
) -> None: ... | ||
def f17( | ||
x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments | ||
+ "bar", | ||
) -> None: ... | ||
def f18( | ||
x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments | ||
+ b"bar", | ||
) -> None: ... | ||
def f19( | ||
x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments | ||
+ 4, | ||
) -> None: ... | ||
def f20( | ||
x: int = 5 | ||
+ 5, # Error PYI011 Only simple default values allowed for typed arguments | ||
) -> None: ... | ||
def f21( | ||
x: complex = 3j | ||
- 3j, # Error PYI011 Only simple default values allowed for typed arguments | ||
) -> None: ... | ||
def f22( | ||
x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments | ||
+ 4.3j, | ||
) -> None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
def f12( | ||
x, | ||
y=os.pathsep, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f11(*, x="x") -> None: | ||
... # OK | ||
|
||
|
||
def f13( | ||
x=[ # OK | ||
"foo", | ||
"bar", | ||
"baz", | ||
] | ||
) -> None: | ||
... | ||
|
||
|
||
def f14( | ||
x=( # OK | ||
"foo", | ||
"bar", | ||
"baz", | ||
) | ||
) -> None: | ||
... | ||
|
||
|
||
def f15( | ||
x={ # OK | ||
"foo", | ||
"bar", | ||
"baz", | ||
} | ||
) -> None: | ||
... | ||
|
||
|
||
def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: | ||
... # OK | ||
|
||
|
||
def f17( | ||
x="foo" + "bar", # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f18( | ||
x=b"foo" + b"bar", # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f19( | ||
x="foo" + 4, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f20( | ||
x=5 + 5, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f21( | ||
x=3j - 3j, # OK | ||
) -> None: | ||
... | ||
|
||
|
||
def f22( | ||
x=-42.5j + 4.3j, # OK | ||
) -> None: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
def f12( | ||
x, | ||
y=os.pathsep, # Error PYI014 | ||
) -> None: ... | ||
def f11(*, x="x") -> None: ... # OK | ||
def f13( | ||
x=[ # Error PYI014 | ||
"foo", | ||
"bar", | ||
"baz", | ||
] | ||
) -> None: ... | ||
def f14( | ||
x=( # Error PYI014 | ||
"foo", | ||
"bar", | ||
"baz", | ||
) | ||
) -> None: ... | ||
def f15( | ||
x={ # Error PYI014 | ||
"foo", | ||
"bar", | ||
"baz", | ||
} | ||
) -> None: ... | ||
def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 | ||
def f17( | ||
x="foo" + "bar", # Error PYI014 | ||
) -> None: ... | ||
def f18( | ||
x=b"foo" + b"bar", # Error PYI014 | ||
) -> None: ... | ||
def f19( | ||
x="foo" + 4, # Error PYI014 | ||
) -> None: ... | ||
def f20( | ||
x=5 + 5, # Error PYI014 | ||
) -> None: ... | ||
def f21( | ||
x=3j - 3j, # Error PYI014 | ||
) -> None: ... | ||
def f22( | ||
x=-42.5j + 4.3j, # Error PYI014 | ||
) -> None: ... |
49 changes: 49 additions & 0 deletions
49
crates/ruff/resources/test/fixtures/pylint/collapsible_else_if.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
Test for else-if-used | ||
""" | ||
|
||
|
||
def ok0(): | ||
"""Should not trigger on elif""" | ||
if 1: | ||
pass | ||
elif 2: | ||
pass | ||
|
||
|
||
def ok1(): | ||
"""If the orelse has more than 1 item in it, shouldn't trigger""" | ||
if 1: | ||
pass | ||
else: | ||
print() | ||
if 1: | ||
pass | ||
|
||
|
||
def ok2(): | ||
"""If the orelse has more than 1 item in it, shouldn't trigger""" | ||
if 1: | ||
pass | ||
else: | ||
if 1: | ||
pass | ||
print() | ||
|
||
|
||
def not_ok0(): | ||
if 1: | ||
pass | ||
else: | ||
if 2: | ||
pass | ||
|
||
|
||
def not_ok1(): | ||
if 1: | ||
pass | ||
else: | ||
if 2: | ||
pass | ||
else: | ||
pass |
Oops, something went wrong.