Skip to content

Commit 30be66a

Browse files
committed
Require cmd2>=0.10.0
Also: - Updated .gitignore - Added flake8 and tagging to invoke tasks - Fixed flake8 warnings - Added Pipfile for ease of use
1 parent ef8c90a commit 30be66a

File tree

9 files changed

+85
-8
lines changed

9 files changed

+85
-8
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,9 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# PyCharm / IntelliJ
107+
.idea
108+
109+
# Pipenv
110+
Pipfile.lock

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 1.1.0 (2020-02-21)
8+
- Because of a breaking change in `cmd2`, we now require `cmd2>=0.10.0`
9+
710
## 1.0.2 (2019-12-07)
811

912
### Added

Pipfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[packages]
7+
cmd2 = ">=0.10.0"
8+
9+
[dev-packages]
10+
cmd2-abbrev = {editable = true,path = "."}
11+
codecov = "*"
12+
flake8 = "*"
13+
gnureadline = {version = "*",sys_platform = "== 'darwin'"}
14+
invoke = "*"
15+
ipython = "*"
16+
mock = {version = "*",markers = "python_version < '3.6'"}
17+
pyreadline = {version = "*",sys_platform = "== 'win32'"}
18+
pytest = "*"
19+
pytest-cov = "*"
20+
pytest-mock = "*"
21+
twine = ">=1.11"

cmd2_abbrev/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#
22
# coding=utf-8
3+
# flake8: noqa F401
34
"""An abbreviation plugin for cmd2
45
56
Adds a user setting `abbrev` which defaults to false. When set to True
@@ -8,7 +9,6 @@
89
910
See examples/example.py
1011
"""
11-
1212
from pkg_resources import get_distribution, DistributionNotFound
1313

1414
from .abbrev import AbbrevMixin

cmd2_abbrev/abbrev.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import cmd2
66

7+
78
class AbbrevMixin:
89
"""A cmd2 plugin (mixin class) which adds support for abbreviated commands."""
910
def __init__(self, *args, **kwargs):

examples/example.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import cmd2
77
import cmd2_abbrev
88

9+
910
class AbbrevExample(cmd2_abbrev.AbbrevMixin, cmd2.Cmd):
1011
"""A cmd2 program to demonstrate the use of the cmd2_abbrev plugin"""
1112
def __init__(self, *args, **kwargs):
@@ -35,6 +36,7 @@ def do_speak(self, args):
3536
# .poutput handles newlines, and accommodates output redirection too
3637
self.poutput(' '.join(words))
3738

39+
3840
if __name__ == '__main__':
3941
app = AbbrevExample()
4042
app.cmdloop()

setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
packages=['cmd2_abbrev'],
2828

29-
python_requires='>=3.4',
30-
install_requires=['cmd2 >= 0.9.12, <=2'],
29+
python_requires='>=3.5',
30+
install_requires=['cmd2 >= 0.10.0, <=2'],
3131

3232
setup_requires=['setuptools_scm'],
3333

@@ -42,12 +42,13 @@
4242
'Programming Language :: Python :: 3.6',
4343
'Programming Language :: Python :: 3.7',
4444
'Programming Language :: Python :: 3.8',
45+
'Programming Language :: Python :: 3.9',
4546
],
4647

4748
# dependencies for development and testing
4849
# $ pip install -e .[dev]
4950
extras_require={
5051
'dev': ['setuptools_scm', 'pytest', 'codecov', 'pytest-cov',
51-
'pylint', 'invoke', 'wheel', 'twine']
52+
'flake8', 'invoke', 'wheel', 'twine']
5253
},
5354
)

tasks.py

+46-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
#
2-
# -*- coding: utf-8 -*-
3-
"""Development related tasks to be run with 'invoke'"""
4-
2+
# coding=utf-8
3+
# flake8: noqa E302
4+
"""Development related tasks to be run with 'invoke'.
5+
6+
Make sure you satisfy the following Python module requirements if you are trying to publish a release to PyPI:
7+
- twine >= 1.11.0
8+
- wheel >= 0.31.0
9+
- setuptools >= 39.1.0
10+
"""
511
import os
12+
import re
613
import shutil
14+
import sys
715

816
import invoke
917

@@ -135,6 +143,34 @@ def clean_all(context):
135143
pass
136144
namespace_clean.add_task(clean_all, 'all')
137145

146+
@invoke.task
147+
def tag(context, name, message=''):
148+
"Add a Git tag and push it to origin"
149+
# If a tag was provided on the command-line, then add a Git tag and push it to origin
150+
if name:
151+
context.run('git tag -a {} -m {!r}'.format(name, message))
152+
context.run('git push origin {}'.format(name))
153+
namespace.add_task(tag)
154+
155+
@invoke.task()
156+
def validatetag(context):
157+
"Check to make sure that a tag exists for the current HEAD and it looks like a valid version number"
158+
# Validate that a Git tag exists for the current commit HEAD
159+
result = context.run("git describe --exact-match --tags $(git log -n1 --pretty='%h')")
160+
tag = result.stdout.rstrip()
161+
162+
# Validate that the Git tag appears to be a valid version number
163+
ver_regex = re.compile(r'(\d+)\.(\d+)\.(\d+)')
164+
match = ver_regex.fullmatch(tag)
165+
if match is None:
166+
print('Tag {!r} does not appear to be a valid version number'.format(tag))
167+
sys.exit(-1)
168+
else:
169+
print('Tag {!r} appears to be a valid version number'.format(tag))
170+
171+
172+
namespace.add_task(validatetag)
173+
138174
@invoke.task(pre=[clean_all])
139175
def sdist(context):
140176
"Create a source distribution"
@@ -158,3 +194,10 @@ def pypi_test(context):
158194
"Build and upload a distribution to https://test.pypi.org"
159195
context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*')
160196
namespace.add_task(pypi_test)
197+
198+
# Flake8 - linter and tool for style guide enforcement and linting
199+
@invoke.task
200+
def flake8(context):
201+
"Run flake8 linter and tool for style guide enforcement"
202+
context.run("flake8 --ignore=E252,W503 --max-complexity=26 --max-line-length=127 --show-source --statistics --exclude=.git,__pycache__,.tox,.eggs,*.egg,.venv,.idea,.pytest_cache,.vscode,build,dist,htmlcov")
203+
namespace.add_task(flake8)

tests/test_abbrev.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#
21
# coding=utf-8
2+
# flake8: noqa E302
33

44
import argparse
55

0 commit comments

Comments
 (0)