markomirosavljev / fastapi-cognito

Basic Cognito-Auth library for Python and FastAPI.
MIT License
53 stars 17 forks source link

Error with type definition in settings_parser.py #17

Closed josephcaroe closed 6 months ago

josephcaroe commented 11 months ago

Hi creators,

thank you for the really easy and nice to use libraries in order to verify JWT tokens via Cognito. I've encountered an issue that probably relates to me using python 3.8 version.

Whenever I deploy the lambda function containing your libraries, i get this stack of exception:

[ERROR] TypeError: 'type' object is not subscriptableTraceback (most recent call last):  File "/var/lang/lib/python3.8/imp.py", line 234, in load_module    return load_source(name, filename, file)  File "/var/lang/lib/python3.8/imp.py", line 171, in load_source    module = _load(spec)  File "<frozen importlib._bootstrap>", line 702, in _load  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked  File "<frozen importlib._bootstrap_external>", line 843, in exec_module  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed  File "/var/task/app/main.py", line 1, in <module>    from app.api.api_v1.api import router as api_router  File "/var/task/app/api/api_v1/api.py", line 3, in <module>    from .endpoints import saveFeedback, varchatMainfunc, newsletter, authentication  File "/var/task/app/api/api_v1/endpoints/authentication.py", line 15, in <module>    from fastapi_cognito import CognitoAuth, CognitoSettings, CognitoToken  File "/var/task/fastapi_cognito/__init__.py", line 4, in <module>    from .settings_parsers import CognitoSettings  File "/var/task/fastapi_cognito/settings_parsers.py", line 8, in <module>    class CognitoSettings(BaseSettings):  File "/var/task/fastapi_cognito/settings_parsers.py", line 18, in CognitoSettings    userpools: dict[str, dict[str, Any]]

The problem being the follow line of code in settings_parser.py: userpools: dict[str, dict[str, Any]] Basically, this is incompatible with python 3.8 ( I am kinda guessing ) and my IntelliJ compiler suggested to change it to: userpools: Dict[str, Dict[str, Any]] Which is what I did, making it work immediately. But I feel like this is a problem that could affect other people so I thought about sharing it.

markomirosavljev commented 6 months ago

This will be resolved in next version.