Uniformize UTF-8 naming#1115
Uniformize UTF-8 naming#1115jkbrzt merged 5 commits intohttpie:masterfrom BoboTiG:impr-utf-8-naming-uniformization
Conversation
Replace `utf8` -> `utf-8` everywhere. It should have no impact, `utf8` is an alias of `utf-8` [1]. [1] https://github.com/python/cpython/blob/ee03bad25e83b00ba5fc2a0265b48c6286e6b3f7/Lib/encodings/aliases.py#L534
Codecov Report
@@ Coverage Diff @@
## master #1115 +/- ##
==========================================
+ Coverage 96.35% 96.84% +0.49%
==========================================
Files 64 65 +1
Lines 4137 4180 +43
==========================================
+ Hits 3986 4048 +62
+ Misses 151 132 -19
Continue to review full report at Codecov.
|
|
It is finally not needed for #1110 but I am still for such clean-up, if you are OK with that @jakubroztocil :) |
There was a problem hiding this comment.
We can remove the argument from .encode('utf-8') and .decode('utf-8') since it’s the default.
I’d also introduce a UTF8 = 'UTF-8' constant and use it instead of the string to avoid inconsistencies and to have a central place where we can talk about the encoding.
Let's be explicit over implicit. And prevent future warnings from PEP-597 [1]. [1] https://www.python.org/dev/peps/pep-0597/#using-the-default-encoding-is-a-common-mistake
|
Actually I did the exact opposite :) I think it is a good thing to explicitly set the encoding everywhere to prevent surprises. And the PEP-597 will eventually throw warnings in a near future. |
|
/packit copr-build |
|
/packit copr-build |
I believe the PEP only talks about str.encode(encoding="utf-8", errors="strict")
bytes.decode(encoding="utf-8", errors="strict")¶https://docs.python.org/3/library/stdtypes.html#str.encode |
|
Oh how did miss that?! I'll remove all encoding occurrences for those functions then 👍 |
Replace
utf8->utf-8everywhere.It should have no impact,
utf8is an alias ofutf-8[1].[1] https://github.com/python/cpython/blob/ee03bad25e83b00ba5fc2a0265b48c6286e6b3f7/Lib/encodings/aliases.py#L534
Full story: I kind of need such uniformization for #1110 where I am adding tests. And I have to deal with our naming (
utf8) and the one fromrequestsorcharset_normalizer(utf-8).Note that this is a one-time small clean-up, and I can live without that patch being merged.