Set Flake8 encoding to UTF-8#11108
Conversation
|
@feerrenrut, sorry I did not yet know how to solve this one when I filed PR #11081. |
feerrenrut
left a comment
There was a problem hiding this comment.
Would it be less likely to bite us again if we add the # -*- coding: utf-8 -*- to the top of the file, we could then add an encoding check (like the flake8 linter) to ensure that all files have the expected encoding (and no bom marks etc)
I really don't think it would make a difference. |
feerrenrut
left a comment
There was a problem hiding this comment.
Thanks @JulienCochuyt
|
@feerrenrut What is the reason behind ApVeyor script not invoking tests using Sconscript? While you were aware of it, presumably because you've written the code, it is not obvious, and having only one code path seems less likely to introduce differences between what developers are using and what is used on AppVeyor. |
@lukaszgo1 I agree, it's not obvious or ideal when changing options! It's a trade-off with trying to reduce the build time. Scons takes a long time to initialize our buildscripts, and we do many more builds than edits to these files. Happy to hear about proposals to improve this! |
|
@feerrenrut wrote:
My first thought would be not to use Scons for these tests at all. It seems overkill. It should be possible to add additional parameters to scons.py to run specific tests. |
|
The support for running the tests via scons is to make it easier for developers to run the tests on their own machines. Hopefully this makes it more likely they do so. |
Link to issue number:
Follow-up of PR #11081
Summary of the issue:
Flake8 encodes its output with the default encoding.
Without further instruction, Python chooses the default encoding of the system to do so.
When a line of source code contains both a linting error and a non-ASCII character, it currently leads to either the line being wrongly encoded, or worse the line being replaced by the stack trace of an UnicodeEncodeError.
For an example of this behavior, edit
source/globalCommands.pyand set the copyright year to 2020, then runscons lint.Flake8 should complain about both the comment not starting with "# " and the line being too long.
If, like in my CP1252 Windows default encoding, the character "Ł" cannot be represented, you'll end up with the following output:
By the way, all apologies to @lukaszgo1: it seems I might have misspelled your first name in the past as I did not notice earlier its first letter wasn't "L", but rather "Ł".
Description of how this pull request fixes the issue:
Take advantage of the new UTF-8 Mode introduced by PEP 540 in Python 3.7: Add the
-Xutf8command-line argument.Testing performed:
Linted the above described edit with and without the proposed change.
Known issues with pull request:
Change log entry:
I don't think this deserves a change log entry.