py3-plus: .encode('utf-8') → .encode() & .decode('utf-8') → .decode()
See original GitHub issueIn Python 3, the first positional argument to .encode()
and .decode()
defaults to 'utf-8'
. This was not the case with Python 2:
https://docs.python.org/3/library/stdtypes.html#str.encode https://docs.python.org/3/library/stdtypes.html#bytes.decode
As this is the most common value passed, there could be a transform to simplify the calls to just .encode()
or .decode()
(without the first positional argument). This could help clean up and simplify modern Python code by removing noise.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (9 by maintainers)
Top Results From Across the Web
utf 8 - How Python decodes UTF8 Encoding in String Format
Use ast.literal_eval() , it's not unsafe. Then you don't need to call bytes() , since it will return a byte string.
Read more >dart:convert library - Dart API
A Utf8Codec encodes strings to UTF-8 code units (bytes) and decodes UTF-8 code units to strings. The utf8 is the default implementation of...
Read more >utf8 | Yarn - Package Manager
Unlike many other JavaScript solutions, it is designed to be a proper UTF-8 encoder/decoder: it can encode/decode any scalar Unicode code point values,...
Read more >Encoding Standard
8.1.1 UTF-8 decoder; 8.1.2 UTF-8 encoder ... The encodeInto() method can be used to encode a string into an existing ArrayBuffer object.
Read more >Encode a String to UTF-8 in Java
How to do Base64 encoding and decoding in Java, using the new APIs introduced in Java 8 as well as Apache Commons. Read...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
it can, but like, who would write that
not yet, I want to finish up a PR first – you can try the latest from git however
pip install git+https://github.com/asottile/pyupgrade
(or via pre-commitpre-commit try-repo https://github.com/asottile/pyupgrade
(to just try) or if you have it already configuredpre-commit autoupdate --repo https://github.com/asottile/pyupgrade --bleeding-edge
)