Skip to content

Commit

Permalink
Merge branch 'main' into plw0603-global-statement
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Feb 26, 2023
2 parents 97ea3c8 + 0b7d6b9 commit 37b98ae
Show file tree
Hide file tree
Showing 52 changed files with 1,630 additions and 94 deletions.
21 changes: 21 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_django/DJ003.py
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 crates/ruff/resources/test/fixtures/flake8_django/DJ006.py
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 crates/ruff/resources/test/fixtures/flake8_django/DJ007.py
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"]
79 changes: 79 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_pyi/PYI011.py
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:
...
63 changes: 63 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_pyi/PYI011.pyi
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: ...
79 changes: 79 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_pyi/PYI014.py
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:
...
45 changes: 45 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_pyi/PYI014.pyi
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 crates/ruff/resources/test/fixtures/pylint/collapsible_else_if.py
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
Loading

0 comments on commit 37b98ae

Please sign in to comment.