| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
|
|
|
| |
Avoids building a list in memory unnecessarily. Generator expressions
are evaluated lazily.
|
|
|
|
|
|
|
| |
The lint stage of CI is already handled by pre-commit.ci. With it, the
extra run in GitHub action is redundant and only consumes time and
resources unnecessarily.
pre-commit.ci is also faster to respond with results.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Simplify black configuration to be closer to upstream defaults
Avoid extra configuration by simply going with Black defaults. This
allows removing some configuration options, thus simplifying the overall
configuration.
It also makes the code style closer to community conventions. As more
projects adopt black formatting, more code will look like the black
defaults.
Further, the default 88 tends to create more readable lines, IMO. The
black rationale is located at:
https://black.readthedocs.io/en/stable/the_black_code_style.html#line-length
* Update tests/test_api_jws.py
Co-authored-by: José Padilla <jpadilla@webapplicate.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update tests/test_api_jws.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: José Padilla <jpadilla@webapplicate.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
|
|
|
|
|
|
|
|
| |
- Fixed doctest which included incorrect output.
- Use intersphinx to allow linking to Python JSONEncoder class.
- Fix param types after previous str/bytes cleanups.
- Fix param syntax to avoid vertical bar.
The command `tox -e docs` now passes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Fix tox "manifest" environment to pass
The command `tox -e manifest` now passes.
Added missing files to the sdist:
- .pre-commit-config.yaml
- CODE_OF_CONDUCT.md
- jwt/py.typed
- docs/
Alphabetized MANIFEST.in
Moved .flake8 to setup.cfg to avoid the need to include yet another file
to MANIFEST.in.
Exclude codecov.yml. This is for CI only.
* Move check-manifest to a pre-commit hook
|
|
|
|
|
|
|
|
|
|
|
| |
ModuleNotFoundError was introduced in Python 3. It is raised when the
module does not exist. On the other hand, ImportError is raised during
any import failure. For example, a syntax error or other runtime error.
Using ModuleNotFoundError means that errors unrelated to a missing
package will be propagated to the user. PyJWT doesn't know how to handle
these.
This also allows more functions to always be available for import
|
|
|
|
| |
int.from_bytes() has been available since Python 3.2. Using it avoids
string formatting.
|
| |
|
| |
|
|
|
| |
https://pre-commit.com/#updating-hooks-automatically
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The class PyJWT was previously a subclass of PyJWS. However, this
combination does not follow the Liskov substitution principle. That is,
using PyJWT in place of a PyJWS would not produce correct results or
follow type contracts.
While these classes look to share a common interface it doesn't go
beyond the method names "encode" and "decode" and so is merely
superficial.
The classes have been split into two. PyJWT now uses composition instead
of inheritance to achieve the desired behavior. Splitting the classes in
this way allowed for precising the type interfaces.
The complete parameter to .decode() has been removed. This argument was
used to alter the return type of .decode(). Now, there are two different
methods with more explicit return types and values. The new method name
is .decode_complete(). This fills the previous role filled by
.decode(..., complete=True).
Closes #554, #396, #394
Co-authored-by: Sam Bull <git@sambull.org>
Co-authored-by: Sam Bull <git@sambull.org>
|
| |
|
|
|
|
| |
No need to create a fixture with a nested function. This can be a simple
utility function.
|
|
|
|
| |
When complete=True is passed to api_jwt.decode() (aliased as
decode_token()), the "header" key always exists.
|
|
|
| |
In Python 3, these values will always be str.
|
|
|
|
|
|
|
|
| |
Merging two dict is support since Python 3.5 using the ** syntax.
See:
- https://docs.python.org/3.9/whatsnew/3.5.html#whatsnew-pep-448
- https://www.python.org/dev/peps/pep-0448/
|
|
|
|
|
|
| |
Default options are set using PyJWT._get_default_options() therefore,
there should never be a KeyError when indexing options directly. Enforce
this expectation. Also avoids duplicating the default for the "require"
option.
|
|
|
|
| |
- Remove "noqa" comments that are unnecessary
- Remove unused imports from api_jwt.py
|
|
|
|
|
|
| |
Follows upstream cryptography commit:
https://github.com/pyca/cryptography/commit/5528a3182fdd6ed1c44c126d451a87bcf39e79de
Since Python 3.2, this bytes to an int is a native feature.
|
|
|
|
| |
Since Python 3, these two functions are functionally equivalent, so use
the builtin one.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that the project is Python 3 only, the boundaries between bytes and
Unicode strings is more explicit.
This allows removing several unnecessary force_bytes() and
force_unicode() calls that handled differences between Python 2 and
Python 3. All uses of force_unicode() have been removed.
For values that are known to be bytes, use `.decode()` instead. For
values are that known to be str, use `.encode()` instead. This strategy
makes the type explicit and reduces a function call.
Key handling continues to use force_bytes() to allow callers to pass
either bytes or str.
To help enforce bytes/str handling in the future, the `-b` option is
passed to Python when testing. This option will emit a warning if bytes
and str are improperly mixed together.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Update Python 2 syntax and drop Python-2-only examples.
Fix all Python console prompts to the full ">>> " for correct
highlighting.
Use "pycon" instead of "python" for interactive Python console session.
The "python" lexer is for Python scripts and doesn't interpret the ">>>"
prompt.
Fix all Python console code blocks to more accurately display what the
user will see. For example, when assigning a value to a variable, it
isn't also echoed.
Fix typo ".. code::" → ".. code-block::".
Use "console" instead of "sh" for shell sessions. The "sh" lexer is for
shell scripts. For a complete list of lexers, see:
https://pygments.org/docs/lexers/
Use blacken-docs to run black on code blocks. This is now included as a
pre-commit hook.
|
|
|
| |
Closes #505
|
|
|
|
| |
Now that Python 2 has been dropped, can safely use bytes
literals (b"abc") and string literals.
|
|
|
|
|
|
|
|
|
| |
Allows dropping a dependency that isn't very necessary.
The requests library was used for a single line of code. This same code
is just as easily expressible using the stdlib, thus alllows removing a
dependency.
Tests were adjusted to mock this new approach.
|
|
|
|
| |
They were removed from the code in
f690976596bb74221f5a81fc9afffd5609bc4e70.
|
| |
|
|
|
|
|
|
|
|
| |
Since Python 3.6, json.loads() accepts both Unicode and byte strings.
https://docs.python.org/3/library/json.html#json.loads
> Changed in version 3.6: s can now be of type bytes or bytearray. The
> input encoding should be UTF-8, UTF-16 or UTF-32.
|
|
|
|
|
|
|
|
|
| |
The first line of base64url_decode() is:
if isinstance(input, str):
input = input.encode("ascii")
It therefore accepts either str or bytes. Don't bother coercing to bytes
at the call site.
|
|
|
|
| |
The CLI entry point was removed in commit
8a14f087c285bbe2f6e85ba4818e6c620b708d5d.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
pyugrade is a command line tool to automatically update Python syntax to
modern usage and patterns. For additional details, see:
https://github.com/asottile/pyupgrade
Changes made by the tool:
- Use short Python3 super() syntax.
- Use f-strings when they are simple and more readable.
- Drop Python 2 u prefix from strings.
- Drop "r" argument from open(). It is the default and so specifying it is
unnecessary.
|
|
|
|
|
|
| |
Upgrade black to version 20.8b1 and specify that Python 3.6+ syntax
should be used.
Run it on all files to upgrade syntax.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that Python 2 is not supported, can move away from type comments to
type annotation 🎉.
The typing module is always available, so remove the guards.
Specify the supported Python in the mypy configuration.
Move other mypy configurations to one place. This way, whether tox is
used or not, the same mypy errors appear.
Distribute and install PEP-561 compliant py.typed file. When PyJWT is a
imported as a library, this tells mypy to use the provided type
annotations rather than going through typeshed. This way, the types are
always up to date when running mypy.
Remove outdated ignores since dropping Python 2.
|
|
|
|
|
|
|
|
| |
Fixes the warning when running tests:
.tox/.../lib/python3.9/site-packages/_pytest/config/__init__.py:1233
.../pyjwt/.tox/.../lib/python3.9/site-packages/_pytest/config/__init__.py:1233: PytestConfigWarning: Unknown config option: strict
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
|
|
|
|
| |
The method signature of PyJWT.decode() now matches the parent
PyJWS.decode().
|
|
|
|
|
|
|
|
|
|
|
| |
With isort 5, asottile/seed-isort-config is deprecated and unnecessary.
The official isort main repo now has a pre-commit hook file.
isort is now better at recognizing first party and third party packages.
isort can now handle imports inside blocks, files have been updated.
isort now supports "profiles" for simpler configuration.
|
|
|
| |
Removes a call to _load that was unused.
|
|
|
|
| |
Python 3.5 went end-of-life 2020-09-30. See:
https://devguide.python.org/devcycle/#end-of-life-branches
|
|
|
| |
https://github.com/jpadilla/pyjwt/pull/455
|
|
|
| |
The algorithms parameter for decode accepts list not a string.
|
| |
|
| |
|
| |
|
| |
|
| |
|