🚨 fix ruff errors
This commit is contained in:
parent
b779bae6ca
commit
c19d34f336
@ -37,7 +37,7 @@ def index(request):
|
||||
|
||||
|
||||
@app.route("/example/<int:id>/<str:name>")
|
||||
def example(request, id, name):
|
||||
def example_with_multiple_values(request, id, name):
|
||||
return HttpResponse(body=f"Example with id {id} and name {name}")
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from peewee import Model, Field, SchemaManager, DatabaseProxy
|
||||
from peewee import Model, Field, SchemaManager
|
||||
|
||||
from spiderweb.constants import DATABASE_PROXY
|
||||
|
||||
@ -67,7 +67,7 @@ class SpiderwebModel(Model):
|
||||
)
|
||||
)
|
||||
if field_obj.__class__.__name__ == "BooleanField":
|
||||
if field_obj.default == False and db_version["default"] not in (
|
||||
if field_obj.default is False and db_version["default"] not in (
|
||||
False,
|
||||
None,
|
||||
0,
|
||||
@ -77,7 +77,7 @@ class SpiderwebModel(Model):
|
||||
f"BooleanField `{field_name}` has changed the default value."
|
||||
)
|
||||
)
|
||||
elif field_obj.default == True and db_version["default"] not in (
|
||||
elif field_obj.default is True and db_version["default"] not in (
|
||||
True,
|
||||
1,
|
||||
):
|
||||
|
@ -23,7 +23,13 @@ from spiderweb.constants import (
|
||||
DEFAULT_ALLOWED_METHODS,
|
||||
)
|
||||
from spiderweb.db import SpiderwebModel
|
||||
from spiderweb.default_views import * # noqa: F403
|
||||
from spiderweb.default_views import (
|
||||
http403, # noqa: F401
|
||||
http404, # noqa: F401
|
||||
http405, # noqa: F401
|
||||
http500, # noqa: F401
|
||||
send_file,
|
||||
)
|
||||
from spiderweb.exceptions import (
|
||||
ConfigError,
|
||||
NotFound,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import re
|
||||
from typing import Callable, Any, Optional, Sequence
|
||||
from typing import Callable, Any, Sequence
|
||||
|
||||
from spiderweb.constants import DEFAULT_ALLOWED_METHODS
|
||||
from spiderweb.converters import * # noqa: F403
|
||||
|
@ -1,4 +0,0 @@
|
||||
from spiderweb.tests.middleware import (
|
||||
ExplodingResponseMiddleware,
|
||||
ExplodingRequestMiddleware,
|
||||
)
|
@ -171,7 +171,7 @@ def test_csrf_middleware():
|
||||
assert "bob" in resp2
|
||||
|
||||
# test that it raises a CSRF error on wrong token
|
||||
formdata = f"name=bob&csrf_token=badtoken"
|
||||
formdata = "name=bob&csrf_token=badtoken"
|
||||
b_handle = BytesIO()
|
||||
b_handle.write(formdata.encode(DEFAULT_ENCODING))
|
||||
b_handle.seek(0)
|
||||
|
@ -104,7 +104,7 @@ def test_redirect_on_append_slash():
|
||||
def index(request):
|
||||
pass
|
||||
|
||||
environ["PATH_INFO"] = f"/hello"
|
||||
environ["PATH_INFO"] = "/hello"
|
||||
assert app(environ, start_response) == [b"None"]
|
||||
assert start_response.get_headers()["location"] == "/hello/"
|
||||
|
||||
@ -205,7 +205,7 @@ def test_view_can_be_reversed():
|
||||
def index(request): ...
|
||||
|
||||
@app.route("/<int:hi>", name="qwer")
|
||||
def index(request, hi): ...
|
||||
def index2(request, hi): ...
|
||||
|
||||
assert app.reverse("asdfasdf") == "/"
|
||||
assert app.reverse("asdfasdf", {"id": 1}) == "/"
|
||||
|
@ -1,17 +1,12 @@
|
||||
import pytest
|
||||
|
||||
from spiderweb import SpiderwebRouter
|
||||
from spiderweb.constants import DEFAULT_ENCODING
|
||||
from spiderweb.exceptions import ParseError, ConfigError
|
||||
from spiderweb.response import (
|
||||
HttpResponse,
|
||||
JsonResponse,
|
||||
TemplateResponse,
|
||||
RedirectResponse,
|
||||
)
|
||||
from hypothesis import given, strategies as st, assume
|
||||
|
||||
from peewee import SqliteDatabase
|
||||
|
||||
from spiderweb.tests.helpers import setup
|
||||
|
||||
|
40
test.py
40
test.py
@ -1,40 +0,0 @@
|
||||
from peewee import *
|
||||
from playhouse.migrate import SqliteMigrator, migrate
|
||||
|
||||
from spiderweb.db import SpiderwebModel
|
||||
|
||||
db = SqliteDatabase("people.db")
|
||||
migrator = SqliteMigrator(db)
|
||||
|
||||
|
||||
class Person(SpiderwebModel):
|
||||
name = CharField()
|
||||
birthday = DateField()
|
||||
|
||||
class Meta:
|
||||
database = db # This model uses the "people.db" database.
|
||||
|
||||
|
||||
class Pet(SpiderwebModel):
|
||||
owner = ForeignKeyField(Person, backref="pets")
|
||||
name = CharField(max_length=40)
|
||||
animal_type = CharField()
|
||||
age = IntegerField(null=True)
|
||||
favorite_color = CharField(null=True)
|
||||
|
||||
class Meta:
|
||||
database = db # this model uses the "people.db" database
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
db.connect()
|
||||
Pet.check_for_needed_migration()
|
||||
# try:
|
||||
# Pet.check_for_needed_migration()
|
||||
# except:
|
||||
# migrate(
|
||||
# migrator.add_column(
|
||||
# Pet._meta.table_name, 'favorite_color', CharField(null=True)
|
||||
# ),
|
||||
# )
|
||||
db.create_tables([Person, Pet])
|
Loading…
Reference in New Issue
Block a user