question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove **kwargs from encode() and decode()

See original GitHub issue

I recently had a situation where I was passing algorithm instead of algorithms to jwt.decode(). Due to the **kwargs eating the algorithm parameter and the decode method looking at the encoded JWT to figure out what type of algorithm to use, everything appeared to be working the way you would expect, even though it wasn’t actually doing what I wanted it to.

If there wasn’t the **kwargs there, my code would have raised a TypeError instead and immediately let me know I wasn’t using the API correctly. Personally, I think that is very desirable.

Would you be interested in a patch to remove **kwargs and replace them all with named arguments instead?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mark-adamscommented, Nov 27, 2017

It looks like we don’t currently allow **kwargs on encode() but I do think we should definitely remove the **kwargs from decode().

This may be a non-trivial change to make since we currently have several arguments such as audience= and issuer= which are not currently explicitly enumerated in the function definitions for decode().

Give it a shot if you’d like. 👍

1reaction
github-actions[bot]commented, Jun 24, 2022

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing unusual characters, after decoding and encoding
You need to decode after the data is input, use it as unicode and encode it only for output. An UnicodeDecodeError is raised...
Read more >
json — JSON encoder and decoder — Python 3.11.1 ...
Serialize obj as a JSON formatted stream to fp (a .write() -supporting file-like object) using this conversion table. If skipkeys is true (default: ......
Read more >
Tokenizer - Hugging Face
When the tokenizer is loaded with from_pretrained(), this will be set to the value ... to False ) — Whether or not to...
Read more >
Changelog — PyJWT 2.4.0 documentation - Read the Docs
Changed¶. Remove arbitrary kwargs. ... Fix from_jwk() for all algorithms #598 ... Use jwt.decode(encoded, key, options={"verify_signature": False}) instead.
Read more >
URL Helpers — Werkzeug Documentation (2.2.x)
decode_query (*args, **kwargs)¶. Decodes the query part of the URL. Ths is a shortcut for calling url_decode() on the query argument.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found