mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2026-07-28 05:00:38 +03:00
refactor: add type hints to function signatures across multiple files
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ class Stuff(Base):
|
||||
|
||||
@classmethod
|
||||
@compile_sql_or_scalar
|
||||
async def get_by_name(cls, db_session: AsyncSession, name: str, compile_sql=False):
|
||||
async def get_by_name(cls, db_session: AsyncSession, name: str, compile_sql: bool=False):
|
||||
stmt = select(cls).options(joinedload(cls.nonsense)).where(cls.name == name)
|
||||
return stmt
|
||||
|
||||
|
||||
+3
-3
@@ -21,15 +21,15 @@ class User(Base):
|
||||
_password: bytes = Column(LargeBinary, nullable=False)
|
||||
|
||||
@property
|
||||
def password(self):
|
||||
def password(self) -> str:
|
||||
return self._password.decode("utf-8")
|
||||
|
||||
@password.setter
|
||||
def password(self, password: SecretStr):
|
||||
def password(self, password: SecretStr) -> None:
|
||||
_password_string = password.get_secret_value().encode("utf-8")
|
||||
self._password = bcrypt.hashpw(_password_string, bcrypt.gensalt())
|
||||
|
||||
def check_password(self, password: SecretStr):
|
||||
def check_password(self, password: SecretStr) -> bool:
|
||||
return bcrypt.checkpw(
|
||||
password.get_secret_value().encode("utf-8"), self._password
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user