diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-12-06 01:24:19 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-12-06 01:24:19 -0500 |
commit | c689e74fed45bf1a7b2908defc343d35f31dff71 (patch) | |
tree | 3c1904debb429274d2fac316300a8b75b200a66c /cmd2/transcript.py | |
parent | 709af49a7f161c98260cc5ddda736987fb0f1f23 (diff) | |
download | cmd2-git-c689e74fed45bf1a7b2908defc343d35f31dff71.tar.gz |
Fix flake8 issues
This commit contains a very large number of trivial changes in order to fix flake8 errors and warnings. Predominantly these are whitespace changes.
Additionally, the build for Python 3.7 on TravisCI has been tweaked to fail if there are any flake8 errors using the following commandline:
* flake8 . --count --ignore=E252 --max-complexity=31 --max-line-length=127 --show-source --statistics
NOTE: In the future the max cyclomatic complexity should be lowered, but some improvements need to be made first.
One flake8 error is being ignored entirely:
* E252 missing whitespace around parameter equals
* ignored because it doesn't correctly deal with default argument values after a type hint
A few flake8 errors are being selectively ignored in certain files:
* C901 fuction is too complex
* ignored in argparse_completer.py because the complex code is an override of argparse complexity
* E302 expected 2 blank lines after ...
* ignored in all unit test files for convenience
* F401 module imported but unused
* ignored in cmd2/__init__.py because imports are for convenience of cmd2 developers and backwards compatibility
* F821 undefined name
* ignored in cmd2 script files which are intended to run only within cmd2 applications via pyscript where "app" and "cmd" are defined
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r-- | cmd2/transcript.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/cmd2/transcript.py b/cmd2/transcript.py index fe43188f..6a954bce 100644 --- a/cmd2/transcript.py +++ b/cmd2/transcript.py @@ -77,7 +77,8 @@ class Cmd2TestCase(unittest.TestCase): try: line = next(transcript) except StopIteration as exc: - msg = 'Transcript broke off while reading command beginning at line {} with\n{}'.format(line_num, command[0]) + msg = 'Transcript broke off while reading command beginning at line {} with\n{}'.format(line_num, + command[0]) raise StopIteration(msg) from exc line_num += 1 command = ''.join(command) @@ -138,7 +139,7 @@ class Cmd2TestCase(unittest.TestCase): # there is a slash, add everything we have found so far # add stuff before the first slash as plain text regex += re.escape(s[start:first_slash_pos]) - start = first_slash_pos+1 + start = first_slash_pos + 1 # and go find the next one (regex, second_slash_pos, start) = self._escaped_find(regex, s, start, True) if second_slash_pos > 0: @@ -151,7 +152,7 @@ class Cmd2TestCase(unittest.TestCase): else: # No closing slash, we have to add the first slash, # and the rest of the text - regex += re.escape(s[start-1:]) + regex += re.escape(s[start - 1:]) break return regex @@ -178,24 +179,24 @@ class Cmd2TestCase(unittest.TestCase): break else: # check if the slash is preceeded by a backslash - if s[pos-1:pos] == '\\': + if s[pos - 1:pos] == '\\': # it is. if in_regex: # add everything up to the backslash as a # regular expression - regex += s[start:pos-1] + regex += s[start:pos - 1] # skip the backslash, and add the slash regex += s[pos] else: # add everything up to the backslash as escaped # plain text - regex += re.escape(s[start:pos-1]) + regex += re.escape(s[start:pos - 1]) # and then add the slash as escaped # plain text regex += re.escape(s[pos]) # update start to show we have handled everything # before it - start = pos+1 + start = pos + 1 # and continue to look else: # slash is not escaped, this is what we are looking for |