I am formatting Python code using pylint and getting some unwanted warning messages which are given below.
C:204, 0: Invalid function name "sendPasswordViaEmail" (invalid-name)
C:207, 4: Invalid variable name "to" (invalid-name)
W:213, 4: Statement seems to have no effect (pointless-statement)
I am providing my code related to the above messages below.
if request.method == 'POST':
        name = request.POST.get('uname')
        email = request.POST.get('uemail')
        range_start = 10 ** (4 - 1)
        range_end = (10 ** 4) - 1
        password = randint(range_start, range_end)
        passw = User(
            uname=name,
            password=password,
            raw_password=password,
        )
        passw.save()
        sendPasswordViaEmail(str(password), email)
    return render(request, 'bookingservice/login.html')
def sendPasswordViaEmail(password, email):
    """ Send email to user"""
    to = email
    gmail_user = settings.EMAIL
    gmail_pwd = settings.PASSWORD
    smtpserver = smtplib.SMTP("smtp.gmail.com", 587)
    smtpserver.ehlo()
    smtpserver.starttls()
    smtpserver.ehlo
    smtpserver.login(gmail_user, gmail_pwd)
    header = 'To:' + to + '\n' + 'From: ' + \
        gmail_user + '\n' + 'Subject:password \n'
    msg = header + '\n Your password is\n\n' + password
    smtpserver.sendmail(gmail_user, to, msg)
    smtpserver.close()
                These messages are warnings (your code works), not errors.
sendPasswordViaEmail is a camel case name. Functions should be "snake case". Rename it send_password_via_email.
to is too short. Try recipient or something else meaningful in place.
The line containing smtpserver.ehlo whithout parentheses does nothing and is thus useless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With