pallets-eco / flask-security

Quick and simple security for Flask applications
MIT License
648 stars 154 forks source link

User datastore initialisation triggers `reportArgumentType` #1001

Closed savchenko closed 4 months ago

savchenko commented 4 months ago

As per the quickstart:

class Base(DeclarativeBase):
    pass
db = SQLAlchemy(model_class=Base)

class User(db.Model, UserMixin):
    # [...]
class Role(db.Model, RoleMixin):
    # [...]

with app.app_context():
    Base.metadata.create_all(bind=db.engine)
    user_datastore = SQLAlchemySessionUserDatastore(db.session, User, Role)

Full output

Argument of type "type[User]" cannot be assigned to parameter "user_model" of type "type[User]" in function "__init__"
"myapp.models.users.User" is incompatible with "flask_security.datastore.User"
Type "type[myapp.models.users.User]" is incompatible with type "type[flask_security.datastore.User]"

and

Argument of type "type[Role]" cannot be assigned to parameter "role_model" of type "type[Role]" in function "__init__"
"myapp.models.users.Role" is incompatible with "flask_security.datastore.Role"
Type "type[myapp.models.users.Role]" is incompatible with type "type[flask_security.datastore.Role]"
jwag956 commented 4 months ago

I will look at this - however - I have no intention of trying to appease mypy/pyright - way too much effort for very little gain. If you have a PR - AND have tested it against ALL supported datastores and ALL supported python versions - please feel free to submit it.

savchenko commented 4 months ago

Roger that. Perhaps makes sense to add a label for such low-priority issues?