vimalloc/flask-jwt-extended

Failing type check with mypy

decaz opened this issue ยท 5 comments

decaz commented

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.

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

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

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.

Fixed in 4.4.3. Cheers

decaz commented

Great, thank you!