10

I am working on user authentication in Flask. I have my User class, which inherits from db.Model (SQLAlchemy) and UserMixins (flask-login):

class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(100), unique=True)
    password = db.Column(db.String(100))
    name = db.Column(db.String(1000))

and I create a new User object during registration:

        new_user = User(
            name=request.form["name"],
            password=generate_password_hash(password=request.form.get("password"),
                                            salt_length=8,
                                            method="pbkdf2:sha256"),
            email=request.form["email"])

Since I inherited from UserMixins, I started to get an "unexpected arguments" warning from pycharm when I create new_user. can someone explain to me why that is? If I don't inherit from UserMixins, the warning goes away.

top 2 comments
sorted by: hot top controversial new old
[-] OsrsNeedsF2P@lemmy.ml 2 points 1 year ago

Does User have it's own init? That would probably fix it

[-] expertmadman@sh.itjust.works 1 points 1 year ago
this post was submitted on 17 Sep 2023
10 points (100.0% liked)

Learn Programming

1625 readers
1 users here now

Posting Etiquette

  1. Ask the main part of your question in the title. This should be concise but informative.

  2. Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.

  3. Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.

  4. Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS