diff options
author | xNinjaKittyx <xNinjaKittyx@users.noreply.github.com> | 2020-12-15 17:21:33 -0800 |
---|---|---|
committer | xNinjaKittyx <xNinjaKittyx@users.noreply.github.com> | 2020-12-15 18:20:13 -0800 |
commit | 9aa54a5b27468d61337528cb1e1b5b9b11a80978 (patch) | |
tree | 567693115cc101efb9254a96d96d80e9f9ccd557 /examples/pirate.py | |
parent | 03c65c60b39e369958b056c5c844d36d515c8a63 (diff) | |
download | cmd2-git-ci_improvements.tar.gz |
Adds pre-commit config to run various lintersci_improvements
This ads black, isort, pyupgrade, and flake8 to pre-commit-config.yaml
There are also some small changes to travis.yml and tasks.py to reduce
some repeated configurations that should be consolidated into
setup.cfg. Most other changes are automated by the linter scripts.
Diffstat (limited to 'examples/pirate.py')
-rwxr-xr-x | examples/pirate.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/pirate.py b/examples/pirate.py index a50f9a51..ba5bc7d5 100755 --- a/examples/pirate.py +++ b/examples/pirate.py @@ -15,6 +15,7 @@ from cmd2.constants import MULTILINE_TERMINATOR class Pirate(cmd2.Cmd): """A piratical example cmd2 application involving looting and drinking.""" + def __init__(self): """Initialize the base class as well as this one""" shortcuts = dict(cmd2.DEFAULT_SHORTCUTS) @@ -40,7 +41,7 @@ class Pirate(cmd2.Cmd): def postcmd(self, stop, line): """Runs right before a command is about to return.""" if self.gold != self.initial_gold: - self.poutput('Now we gots {0} doubloons'.format(self.gold)) + self.poutput('Now we gots {} doubloons'.format(self.gold)) if self.gold < 0: self.poutput("Off to debtorrr's prison.") self.exit_code = -1 @@ -60,7 +61,7 @@ class Pirate(cmd2.Cmd): self.gold -= int(arg) except ValueError: if arg: - self.poutput('''What's "{0}"? I'll take rrrum.'''.format(arg)) + self.poutput('''What's "{}"? I'll take rrrum.'''.format(arg)) self.gold -= 1 def do_quit(self, arg): @@ -83,11 +84,12 @@ class Pirate(cmd2.Cmd): chant = ['yo'] + ['ho'] * args.ho separator = ', ' if args.commas else ' ' chant = separator.join(chant) - self.poutput('{0} and a bottle of {1}'.format(chant, args.beverage)) + self.poutput('{} and a bottle of {}'.format(chant, args.beverage)) if __name__ == '__main__': import sys + # Create an instance of the Pirate derived class and enter the REPL with cmdloop(). pirate = Pirate() sys_exit_code = pirate.cmdloop() |