diff options
author | Viicos <65306057+Viicos@users.noreply.github.com> | 2023-03-07 03:22:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-06 21:22:39 -0500 |
commit | 777efa2f51249f63b0f95804230117723eca5d09 (patch) | |
tree | f8d7db72d0806380daa91b37edde3c27c32eedea /jwt/api_jwt.py | |
parent | 5a2a6b640d9780c75817a626672da0b2d38f9e78 (diff) | |
download | pyjwt-777efa2f51249f63b0f95804230117723eca5d09.tar.gz |
Make `Algorithm` an abstract base class (#845)
* Make `Algorithm` an abstract base class
This also removes some tests that are not relevant anymore
Raise `NotImplementedError` for `NoneAlgorithm`
* Use `hasattr` instead of `getattr`
* Only allow `dict` in `encode`
Diffstat (limited to 'jwt/api_jwt.py')
-rw-r--r-- | jwt/api_jwt.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py index 5664949..d85f6e8 100644 --- a/jwt/api_jwt.py +++ b/jwt/api_jwt.py @@ -3,7 +3,7 @@ from __future__ import annotations import json import warnings from calendar import timegm -from collections.abc import Iterable, Mapping +from collections.abc import Iterable from datetime import datetime, timedelta, timezone from typing import Any, Dict, List, Optional, Type, Union @@ -47,10 +47,10 @@ class PyJWT: json_encoder: Optional[Type[json.JSONEncoder]] = None, sort_headers: bool = True, ) -> str: - # Check that we get a mapping - if not isinstance(payload, Mapping): + # Check that we get a dict + if not isinstance(payload, dict): raise TypeError( - "Expecting a mapping object, as JWT only supports " + "Expecting a dict object, as JWT only supports " "JSON objects as payloads." ) |