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 /examples/tab_autocomp_dynamic.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 'examples/tab_autocomp_dynamic.py')
-rwxr-xr-x | examples/tab_autocomp_dynamic.py | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/examples/tab_autocomp_dynamic.py b/examples/tab_autocomp_dynamic.py index af77b204..0c64d020 100755 --- a/examples/tab_autocomp_dynamic.py +++ b/examples/tab_autocomp_dynamic.py @@ -6,8 +6,6 @@ A example usage of AutoCompleter with delayed initialization of the argparse obj Copyright 2018 Eric Lin <anselor@gmail.com> Released under MIT license, see LICENSE file """ -import argparse -import itertools from typing import List import cmd2 @@ -87,18 +85,15 @@ class TabCompleteExample(cmd2.Cmd): # Add the 'movies' parser as a parent of sub-parser video_types_subparsers.add_parser('movies', parents=[vid_movies_parser], add_help=False) - - vid_shows_parser = argparse_completer.ACArgumentParser(prog='shows') vid_shows_parser.set_defaults(func=TabCompleteExample._do_vid_media_shows) vid_shows_commands_subparsers = vid_shows_parser.add_subparsers(title='Commands', dest='command') - vid_shows_list_parser = vid_shows_commands_subparsers.add_parser('list') + vid_shows_commands_subparsers.add_parser('list') video_types_subparsers.add_parser('shows', parents=[vid_shows_parser], add_help=False) - # For mocking a data source for the example commands ratings_types = ['G', 'PG', 'PG-13', 'R', 'NC-17'] show_ratings = ['TV-Y', 'TV-Y7', 'TV-G', 'TV-PG', 'TV-14', 'TV-MA'] @@ -126,10 +121,10 @@ class TabCompleteExample(cmd2.Cmd): 'Alec Guinness', 'Peter Mayhew', 'Anthony Daniels'] }, 'SW_EP1': {'title': 'Star Wars: Episode I - The Phantom Menace', - 'rating': 'PG', - 'director': ['George Lucas'], - 'actor': ['Liam Neeson', 'Ewan McGregor', 'Natalie Portman', 'Jake Lloyd'] - }, + 'rating': 'PG', + 'director': ['George Lucas'], + 'actor': ['Liam Neeson', 'Ewan McGregor', 'Natalie Portman', 'Jake Lloyd'] + }, 'SW_EP02': {'title': 'Star Wars: Episode II - Attack of the Clones', 'rating': 'PG', 'director': ['George Lucas'], @@ -146,21 +141,21 @@ class TabCompleteExample(cmd2.Cmd): } USER_SHOW_LIBRARY = {'SW_REB': ['S01E01', 'S02E02']} SHOW_DATABASE_IDS = ['SW_CW', 'SW_TCW', 'SW_REB'] - SHOW_DATABASE = {'SW_CW': {'title': 'Star Wars: Clone Wars', - 'rating': 'TV-Y7', - 'seasons': {1: ['S01E01', 'S01E02', 'S01E03'], - 2: ['S02E01', 'S02E02', 'S02E03']} - }, - 'SW_TCW': {'title': 'Star Wars: The Clone Wars', - 'rating': 'TV-PG', - 'seasons': {1: ['S01E01', 'S01E02', 'S01E03'], - 2: ['S02E01', 'S02E02', 'S02E03']} - }, - 'SW_REB': {'title': 'Star Wars: Rebels', - 'rating': 'TV-Y7', - 'seasons': {1: ['S01E01', 'S01E02', 'S01E03'], - 2: ['S02E01', 'S02E02', 'S02E03']} - }, + SHOW_DATABASE = {'SW_CW': {'title': 'Star Wars: Clone Wars', + 'rating': 'TV-Y7', + 'seasons': {1: ['S01E01', 'S01E02', 'S01E03'], + 2: ['S02E01', 'S02E02', 'S02E03']} + }, + 'SW_TCW': {'title': 'Star Wars: The Clone Wars', + 'rating': 'TV-PG', + 'seasons': {1: ['S01E01', 'S01E02', 'S01E03'], + 2: ['S02E01', 'S02E02', 'S02E03']} + }, + 'SW_REB': {'title': 'Star Wars: Rebels', + 'rating': 'TV-Y7', + 'seasons': {1: ['S01E01', 'S01E02', 'S01E03'], + 2: ['S02E01', 'S02E02', 'S02E03']} + }, } file_list = \ @@ -187,12 +182,10 @@ class TabCompleteExample(cmd2.Cmd): return completions_with_desc - ################################################################################### # The media command demonstrates a completer with multiple layers of subcommands # - This example demonstrates how to tag a completion attribute on each action, enabling argument # completion without implementing a complete_COMMAND function - def _do_vid_media_movies(self, args) -> None: if not args.command: self.do_help('video movies') |