-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Travis CI: Add flake8 tests for syntax errors and undefined names #536
Changes from 16 commits
c25b0b7
9358b3f
77422ad
97dc93a
b88b6d4
c5edb67
849dc73
4c1cce5
43a5254
3476e0f
edb6aca
36ba37d
f7cc3e0
64a5875
1c388b1
9ca54a9
517dd4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,7 @@ def LOG (s): | |
|
||
white.do_move (move_black, 1) | ||
|
||
g.quit() | ||
|
||
|
||
try: | ||
g.quit() | ||
except NameError: | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# flake8: noqa This file is Python 3-only and async yield is a Py2 syntax error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any way to keep linting it on Python 3? |
||
# TODO: Remove these two lines when support for legacy Python is dropped. | ||
|
||
import asyncio | ||
import errno | ||
import signal | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,11 @@ | |
from .expect import Expecter, searcher_string, searcher_re | ||
|
||
PY3 = (sys.version_info[0] >= 3) | ||
text_type = str if PY3 else unicode | ||
try: | ||
text_type = unicode | ||
except NameError: | ||
text_type = str | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually prefer the explicit PY3 check here. It's frustrating if we have to make the code worse in my opinion just to satisfy an automated tool. As a compromise, we could add a dependency on |
||
|
||
|
||
class _NullCoder(object): | ||
"""Pass bytes through unchanged.""" | ||
|
@@ -88,7 +92,11 @@ def __init__(self, timeout=30, maxread=2000, searchwindowsize=None, | |
self.string_type = bytes | ||
self.buffer_type = BytesIO | ||
self.crlf = b'\r\n' | ||
if PY3: | ||
try: # Python 2 | ||
self.allowed_string_types = (basestring, ) | ||
self.linesep = os.linesep | ||
self.write_to_stdout = sys.stdout.write | ||
except NameError: # Python 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I strongly prefer the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify: I'd rather not use it automated in CI. It's still fine to run it manually and fix problems. |
||
self.allowed_string_types = (bytes, str) | ||
self.linesep = os.linesep.encode('ascii') | ||
def write_to_stdout(b): | ||
|
@@ -98,10 +106,7 @@ def write_to_stdout(b): | |
# If stdout has been replaced, it may not have .buffer | ||
return sys.stdout.write(b.decode('ascii', 'replace')) | ||
self.write_to_stdout = write_to_stdout | ||
else: | ||
self.allowed_string_types = (basestring,) # analysis:ignore | ||
self.linesep = os.linesep | ||
self.write_to_stdout = sys.stdout.write | ||
|
||
else: | ||
# unicode mode | ||
self._encoder = codecs.getincrementalencoder(encoding)(codec_errors) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
''' | ||
import pexpect | ||
import sys | ||
import unittest | ||
from . import PexpectTestCase | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the linter identified a real problem with the example here - this fix is just sweeping it under the carpet.