Skip to content

Commit 6567662

Browse files
committed
[DEV] Better Code Architecture & More Tests
Release Cookiecutter Python Package v1.5.1
2 parents 6b82677 + 205df54 commit 6567662

27 files changed

+580
-228
lines changed

.github/biskotaki.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ default_context:
99
author_email: k.lampridis@hotmail.com
1010
github_username: boromir674
1111
project_short_description: Project generated from the https://github.com/boromir674/cookiecutter-python-package/tree/master/src/cookiecutter_python cookiecutter
12-
initialize_git_repo: no
12+
initialize_git_repo: yes
1313
add_cli: no
1414
interpreters: {"supported-interpreters": ["3.6", "3.7", "3.8", "3.9", "3.10"]}

.github/workflows/test.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ jobs:
5050
echo "PKG_VERSION=$A" >> $GITHUB_ENV
5151
5252
- name: Run Test Suite
53-
run: tox -vv -s false
53+
run: tox -vv -s false -- --run-network_bound
5454
env:
5555
PLATFORM: ${{ matrix.platform }}
56+
5657
- name: Check for compliance with Python Best Practices
5758
run: |
5859
DIST_DIR=dist

.pylintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ disable=print-statement,
153153
not-callable,
154154
unsubscriptable-object,
155155
protected-access,
156-
invalid-metaclass
156+
invalid-metaclass,
157+
catching-non-exception
157158

158159
# Enable the message, report, category or checker with the given id(s). You can
159160
# either give multiple identifier separated by comma (,) or put this option
@@ -254,7 +255,7 @@ ignore-on-opaque-inference=yes
254255

255256
# List of class names for which member attributes should not be checked (useful
256257
# for classes with dynamically set attributes). This supports the use of
257-
# qualified names.
258+
# qualified names. Solves `attr-defined` errors.
258259
ignored-classes=optparse.Values,
259260
thread._local,
260261
_thread._local,

CHANGELOG.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22
Changelog
33
=========
44

5+
1.5.1 (2022-06-20)
6+
==================
7+
8+
The Update includes improved code Architecture and better Test code Coverage!
9+
Features shorter Unites of Code, more DRY and more Tests.
10+
11+
Changes
12+
^^^^^^^
13+
14+
test
15+
""""
16+
- add bandit tox env for discovering common security issues
17+
- verify commit message, author and email are the expected ones
18+
- git init, increase test code coverage
19+
20+
refactor
21+
""""""""
22+
- reduce code
23+
- centralize subprocess run invocations
24+
25+
ci
26+
""
27+
- enable network-bound tests to trigger integration testing of the `check_pypi` feature
28+
29+
530
1.5.0 (2022-06-11)
631
==================
732

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ For more complex use cases, you can modify the Template and also leverage all of
196196

197197
.. Github Releases & Tags
198198
199-
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.5.0/master?color=blue&logo=github
199+
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.5.1/master?color=blue&logo=github
200200
:alt: GitHub commits since tagged version (branch)
201-
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.5.0..master
201+
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.5.1..master
202202

203203
.. |commits_since_latest_github_release| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/latest?color=blue&logo=semver&sort=semver
204204
:alt: GitHub commits since latest release (by SemVer)

pyproject.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-backend = "poetry.core.masonry.api"
1010
## Also renders on pypi as 'subtitle'
1111
[tool.poetry]
1212
name = "cookiecutter_python"
13-
version = "1.5.0"
13+
version = "1.5.1"
1414
description = "Yet another modern Python Package (pypi) with emphasis in CI/CD and automation."
1515
authors = ["Konstantinos Lampridis <k.lampridis@hotmail.com>"]
1616
maintainers = ["Konstantinos Lampridis <k.lampridis@hotmail.com>"]
@@ -97,9 +97,11 @@ software-patterns = "^1.3.0"
9797
requests-futures = "^1.0.0"
9898
PyInquirer = "^1.0.3"
9999
prompt-toolkit = "==1.0.14"
100+
gitpython = "^3.1"
100101

101102
# A list of all of the optional dependencies, some of which are included in the
102103
# below `extras`. They can be opted into by apps.
104+
# "^" is the more conservative compared to "~"
103105

104106
# Test: packages imported in test code and packages required for the "test runner"
105107
pytest = { version = ">= 6.2.4", optional = true }
@@ -128,6 +130,7 @@ test = [
128130
"pytest-explicit",
129131
"pytest-xdist",
130132
"pytest-object-getter",
133+
"gitpython",
131134
]
132135
docs = [
133136
"sphinx",
@@ -198,3 +201,12 @@ profile = 'black'
198201

199202
[tool.software-release]
200203
version_variable = "src/cookiecutter_python/__init__.py:__version__"
204+
205+
206+
# BANDIT
207+
208+
[tool.bandit]
209+
tests = []
210+
skips = [
211+
"B101",
212+
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.5.0'
1+
__version__ = '1.5.1'

src/cookiecutter_python/backend/check_pypi_handler.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
def _available_on_pypi(callback, package_name: str):
1010
try:
1111
res: bool = callback(package_name)
12-
except ImportError as error:
13-
print(error)
14-
print(
15-
"If you want to enable the 'check_pypi' feature, "
16-
"Please also install the [check_pypi] requirements (see setup.cfg)"
17-
)
1812
except ConnectionError as error:
1913
print(error, file=sys.stderr)
2014
print("Could not establish connection to pypi.")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .handler_builder import HandlerBuilder
2+
3+
__all__ = ['HandlerBuilder']
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
3+
import click
4+
from software_patterns import SubclassRegistry
5+
6+
7+
class HandlerBuilder(metaclass=SubclassRegistry):
8+
pass
9+
10+
11+
@HandlerBuilder.register_as_subclass('non-critical')
12+
class NonCriticalHandlerBuilder:
13+
def __call__(self, error):
14+
click.echo(error)
15+
16+
17+
@HandlerBuilder.register_as_subclass('critical')
18+
class CriticalHandlerBuilder:
19+
def __call__(self, error):
20+
click.echo('{}'.format(error.message))
21+
click.echo('Error message: {}'.format(error.error.message))
22+
23+
context_str = json.dumps(error.context, indent=4, sort_keys=True)
24+
click.echo('Context: {}'.format(context_str))

0 commit comments

Comments
 (0)