@@ -1,5 +1,6 @@
from dataclasses import dataclass
+
@dataclass
class UserExists(Exception):
name: str
@@ -26,10 +26,7 @@ class User(Model):
def from_request(user: r.User) -> "User":
passhash = pwd.hash(user.password)
try:
- return User.create(
- name=user.name,
- passhash=passhash,
- )
+ return User.create(name=user.name, passhash=passhash,)
except peewee.IntegrityError:
raise e.UserExists(name=user.name)
@@ -1,6 +1,8 @@
class custom_app_context:
@staticmethod
- def hash(password: str) -> str: pass
+ def hash(password: str) -> str:
+ pass
- def verify(password: str, hash: str) -> bool: pass
+ def verify(password: str, hash: str) -> bool:
@@ -45,4 +45,6 @@ def BooleanField(unique: bool = False) -> Any:
def ForeignKeyField(key: object, null: bool = None, backref: str = "") -> Any:
pass
-class IntegrityError(Exception): pass
+class IntegrityError(Exception):
@@ -16,10 +16,7 @@ class TestDB:
c.DB.close()
def mk_user(self, name="gdritter", password="foo") -> m.User:
- return m.User.from_request(r.User(
- name=name,
- password=password,
- ))
+ return m.User.from_request(r.User(name=name, password=password,))
def test_create_user(self):
name = "gdritter"