Skip to content

Commit 191ff70

Browse files
author
ElLorans
committed
type hints
1 parent 37ee5fb commit 191ff70

File tree

165 files changed

+723
-476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+723
-476
lines changed

examples/__init__.py

Whitespace-only changes.

examples/auth/__init__.py

Whitespace-only changes.

examples/auth_flask_login/__init__.py

Whitespace-only changes.

examples/auth-flask-login/main.py renamed to examples/auth_flask_login/main.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
from flask_admin.theme import Bootstrap4Theme
1717
from flask_sqlalchemy import SQLAlchemy
1818
from flask_wtf import FlaskForm
19+
from sqlalchemy import Column
1920
from sqlalchemy import Integer
2021
from sqlalchemy import String
21-
from sqlalchemy.orm import Mapped
22-
from sqlalchemy.orm import mapped_column
2322
from werkzeug.security import check_password_hash
2423
from werkzeug.security import generate_password_hash
2524
from wtforms import fields
@@ -43,17 +42,17 @@ def index():
4342

4443
# inherit from flask_login.UserMixin so no need to define login methods
4544
class User(db.Model, flask_login.UserMixin):
46-
id: Mapped[int] = mapped_column(Integer, primary_key=True)
47-
username: Mapped[str] = mapped_column(
45+
id = Column(Integer, primary_key=True)
46+
username = Column(
4847
String(80),
4948
unique=True,
5049
index=True,
5150
)
5251
# having a _ will make the field hidden in flask-admin edit/create forms
53-
_password: Mapped[str] = mapped_column(String(128), nullable=True)
52+
_password = Column(String(128), nullable=True)
5453

5554
@property
56-
def password(self) -> str:
55+
def password(self):
5756
return self._password
5857

5958
@password.setter
@@ -67,7 +66,7 @@ def password(self, password: str) -> None:
6766
# on MacOS, default method="scrypt" gives AttributeError
6867
method="pbkdf2",
6968
)
70-
self.alternative_id = uuid4().hex
69+
self.alternative_id = uuid4().hex # type: ignore[assignment]
7170
# password.setter can be called even without any user logged in, e.g.
7271
# when creating db
7372
if flask_login.current_user and flask_login.current_user == self:
@@ -82,9 +81,7 @@ def check_password(self, password: t.Optional[str]) -> bool:
8281

8382
# security: https://flask-login.readthedocs.io/en/latest/#alternative-tokens
8483
# allows logout users
85-
alternative_id: Mapped[str] = mapped_column(
86-
String(32), default=uuid4().hex, index=True
87-
)
84+
alternative_id = Column(String(32), default=uuid4().hex, index=True)
8885

8986
def get_id(self):
9087
"""

0 commit comments

Comments
 (0)