[openstack-dev] Add a hacking check to not use "Python Source Code Encodings" (PEP0263)

John Dennis jdennis at redhat.com
Tue Jul 22 19:50:06 UTC 2014


On 07/21/2014 04:45 AM, Christian Berendt wrote:
> Hello.
>
> There are some files using the Python source code encodings as the first
> line. That's normally not necessary and I want propose to introduce a
> hacking check to check for the absence of the source code encodings.
>

I assume you mean you want to prohibit the use of the source code
encoding declaration as opposed to mandating it's use in every file, if
so then ...

NAK. This is a very useful and essential feature, at least for the
specific case of UTF-8. Python 3 source files are defined to be UTF-8
encoded however the same is not true for Python 2 which requires an
explicit source coding for UTF-8. Properly handling
internationalization, especially in the unit tests is critical.
Embedding code points outside the ASCII range via obtuse notation is
both cumbersome and impossible to read without referring to a chart, a
definite drawback. OpenStack in general has not had a great track record
with respect to internationalization, let's not make it more difficult
instead let's embrace those features which promote better
internationalization support.

Given Python 3 has declared the source code encoding is UTF-8 I see no
justification for capriciously declaring Python 2 cannot share the same
encoding. Nor do we want to make it difficult for developers by forcing
them to use unnatural hexadecimal escapes in strings.

However my concerns are strictly limited to UTF-8, I do not think we
should allow any other source code encoding aside from UTF-8. I'd
advocate for a hacking rule to check for any encoding other than UTF-8
(no need to check for ASCII since it's a proper subset of UTF-8). For
example Latin-1 should be flagged as a definite problem.

Do you have a reason for advancing this restriction?

-- 
John




More information about the OpenStack-dev mailing list