vimalloc / flask-jwt-extended

An open source Flask extension that provides JWT support (with batteries included)!
http://flask-jwt-extended.readthedocs.io/en/stable/
MIT License
1.56k stars 239 forks source link

Failing type check with mypy #488

Closed decaz closed 2 years ago

decaz commented 2 years ago

Environment:

flask-jwt-extended==4.4.2
mypy==0.971

Example listing of check.py:

from flask_jwt_extended import current_user

current_user.id

Type checking error:

$ mypy check.py 
check.py:3: error: "LocalProxy[Any]" has no attribute "id"
Found 1 error in 1 file (checked 1 source file)

There is usually a lot of accessing attributes of the current_user variable so I've started to see a huge number of these errors in my codebase. Version 4.4.1 leads to the same errors but there is no such errors with version 4.4.0 so I guess it relates to #480. Also when I removed py.typed file from my local installation then errors disappeared.

vimalloc commented 2 years ago

As I understand it, without the py.typed it wont actually use the types from this extension, so that's probably why the you see the errors in 4.4.1 onwards.

It sounds like I have a bug in the types for current_user. Any chance you could throw together a quick example that demonstrates this error? Also, what version of python are you using? I noticed over the weekend that 3.10 is having mypy failures, so I wonder if that's related? Something I'm hoping to dig into over the next few days.

Cheers!

decaz commented 2 years ago

Any chance you could throw together a quick example that demonstrates this error?

How can my example be even simpler? :)

Also, what version of python are you using?

Python 3.10.5

vimalloc commented 2 years ago

How can my example be even simpler? :)

Oops! It was so simple that I glossed right over it, sorry! 🙃

Python 3.10.5

Sounds like it could be related. I'll keep you updated.

vimalloc commented 2 years ago

Fixed in 4.4.3. Cheers

decaz commented 2 years ago

Great, thank you!