From 2367f1e248733566d9374af957cf3033478f4ae8 Mon Sep 17 00:00:00 2001 From: konstantin Date: Mon, 8 Mar 2021 12:31:49 +0100 Subject: [PATCH 01/32] add initial draft --- .github/workflows/black.yml | 16 ++++ .github/workflows/coverage.yml | 24 ++++++ .github/workflows/pythonlint.yml | 25 ++++++ .github/workflows/unittests.yml | 24 ++++++ .gitignore | 131 +++++++++++++++++++++++++++++++ README.md | 47 ++++++++++- myclass.py | 21 +++++ requirements.in | 0 requirements.txt | 6 ++ tox.ini | 43 ++++++++++ unittests/test_myclass.py | 11 +++ 11 files changed, 346 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/black.yml create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/pythonlint.yml create mode 100644 .github/workflows/unittests.yml create mode 100644 .gitignore create mode 100644 myclass.py create mode 100644 requirements.in create mode 100644 requirements.txt create mode 100644 tox.ini create mode 100644 unittests/test_myclass.py diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 0000000..a240e2c --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,16 @@ +name: "Black" + +on: [push] +jobs: + black: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.9] + os: [ubuntu-latest] + steps: + - uses: actions/checkout@v2 + - name: Black Code Formatter + uses: lgeiger/black-action@v1.0.1 + with: + args: ". --check --line-length 100" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..d5df786 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,24 @@ +name: "Coverage" + +on: [push] +jobs: + coverage: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.9] + os: [ubuntu-latest] + tox: [tests] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + - name: Run Tests and Record Coverage + run: | + tox -e coverage diff --git a/.github/workflows/pythonlint.yml b/.github/workflows/pythonlint.yml new file mode 100644 index 0000000..33b6210 --- /dev/null +++ b/.github/workflows/pythonlint.yml @@ -0,0 +1,25 @@ +name: "Pylint" + +on: [push] +jobs: + pylint: + name: Python Code Quality and Lint + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.9] + os: [ubuntu-latest] + tox: [linting] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install tox + - name: Run Pylint via Tox + run: | + tox -e ${{ matrix.tox }} diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml new file mode 100644 index 0000000..af77087 --- /dev/null +++ b/.github/workflows/unittests.yml @@ -0,0 +1,24 @@ +name: "Pytest" + +on: [push] +jobs: + pytest: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.9] + os: [ubuntu-latest] + tox: [tests] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install tox + - name: Run the Unit Tests via Tox + run: | + tox -e ${{ matrix.tox }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b97131e --- /dev/null +++ b/.gitignore @@ -0,0 +1,131 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +.idea/ diff --git a/README.md b/README.md index f99069f..f3eee2e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,45 @@ -# python_template_repository -A template repository that comes up with a pre-defined tox setup and CI actions. +# python_repo_template + +This is a template repository. It doesn't contain any actual code but only a basic setup for a Python project including: + ++ project structure with + + tox.ini + + requirements.in + + and a requirements.txt derived from it + + an example class + + an example unit test (using pytest) ++ separate Github Actions for + + [pytest](https://pytest.org) + + [code coverage measurement](https://coverage.readthedocs.io) (fails below 80% by default) + + [pylint](https://pylint.org/) (only accepts 10/10 code rating by default) + + [black](https://github.com/psf/black) code formatter check + using [lgeiger/black-action](https://github.com/lgeiger/black-action) + +By default it uses Python version 3.9. + +## How to use this Repository on Your Maschine + +This introduction assumes that you have tox installed already ( +see [installation instructions](https://tox.readthedocs.io/en/latest/install.html)) and that a `.toxbase` environment +has been created. + +If this is the case, clone this repository and create the `dev` environment on your maschine. + +```bash +tox -r dev +``` + +### How to use with PyCharm + +1. Create a new project using existing sources with your local working copy of this repository as root directory. Choose + the path `your_repo/.tox/dev/` as path of the "previously configured interpreter". +2. Set the + default [test runner of your project](https://www.jetbrains.com/help/pycharm/choosing-your-testing-framework.html) to + pytest. +3. Set + the [working directory of the unit tests](https://www.jetbrains.com/help/pycharm/creating-run-debug-configuration-for-tests.html) + to the project root (instead of the unittest directory) + +### How to user with VS Code + +_please add docs here_ \ No newline at end of file diff --git a/myclass.py b/myclass.py new file mode 100644 index 0000000..4d59db0 --- /dev/null +++ b/myclass.py @@ -0,0 +1,21 @@ +""" +This a docstring. +""" + + +class MyClass: # pylint: disable=too-few-public-methods + """ " + This class is just an example class. + """ + + def __init__(self): + """ + Initialize for the sake of initializing + """ + + def do_something(self) -> bool: # pylint: disable=no-self-use + """ + Actually does nothing + :return: + """ + return True diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9b60a9d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile requirements.in +# diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..6a94533 --- /dev/null +++ b/tox.ini @@ -0,0 +1,43 @@ +[tox] +skip_missing_interpreters = True +skipsdist = True + +[testenv] +commands = python -m pip install --upgrade pip + +[testenv:dev] +# the dev environment contains everything you need to start developing on your local machine. +deps = + black + pip-tools + pytest +commands = + python -m pip install --upgrade pip + pip-compile requirements.in + pip install -r requirements.txt + +[testenv:tests] +# the tests environment is called by the Github action that runs the unit tests +deps = + -rrequirements.txt + pytest +commands = python -m pytest --basetemp={envtmpdir} {posargs} + +[testenv:linting] +# the tests environment is called by the Github Action that runs the linter +deps = + -rrequirements.txt + pylint + # add your fixtures like e.g. pytest_datafiles here +commands = + pylint myclass.py + # add single files (ending with .py) or modules here + +[testenv:coverage] +# the coverage environment is called by the Github Action that runs the coverage measurement +deps = + {[testenv:tests]deps} + coverage +commands = + coverage run -m pytest --basetemp={envtmpdir} {posargs} + coverage report --fail-under 80 --omit .tox/*,unittests/* \ No newline at end of file diff --git a/unittests/test_myclass.py b/unittests/test_myclass.py new file mode 100644 index 0000000..b2634f2 --- /dev/null +++ b/unittests/test_myclass.py @@ -0,0 +1,11 @@ +from myclass import MyClass + + +class TestMyClass: + """ + A class with pytest unittests. + """ + + def test_something(self): + my_class = MyClass() + assert my_class.do_something() is True From 5e9ec0e028df93e89fb17d37dcee7ef56b0a3fdf Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 09:30:11 +0100 Subject: [PATCH 02/32] tox -e instead of tox -r on initial setup Co-authored-by: hf-krechan <68426071+hf-krechan@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f3eee2e..8460cf7 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ has been created. If this is the case, clone this repository and create the `dev` environment on your maschine. ```bash -tox -r dev +tox -e dev ``` ### How to use with PyCharm @@ -42,4 +42,4 @@ tox -r dev ### How to user with VS Code -_please add docs here_ \ No newline at end of file +_please add docs here_ From 4e07db689ad29e5633a578e94829f205e9411710 Mon Sep 17 00:00:00 2001 From: konstantin Date: Wed, 10 Mar 2021 09:54:39 +0100 Subject: [PATCH 03/32] add a distinction between class and module --- myclass.py => mymodule.py | 7 ++++--- tox.ini | 4 ++-- unittests/test_myclass.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) rename myclass.py => mymodule.py (78%) diff --git a/myclass.py b/mymodule.py similarity index 78% rename from myclass.py rename to mymodule.py index 4d59db0..50ca089 100644 --- a/myclass.py +++ b/mymodule.py @@ -1,17 +1,18 @@ """ -This a docstring. +This a docstring for the module. """ class MyClass: # pylint: disable=too-few-public-methods - """ " - This class is just an example class. + """ + This is a docstring for the class. """ def __init__(self): """ Initialize for the sake of initializing """ + pass def do_something(self) -> bool: # pylint: disable=no-self-use """ diff --git a/tox.ini b/tox.ini index 6a94533..f3cbd23 100644 --- a/tox.ini +++ b/tox.ini @@ -30,8 +30,8 @@ deps = pylint # add your fixtures like e.g. pytest_datafiles here commands = - pylint myclass.py - # add single files (ending with .py) or modules here + pylint mymodule.py + # add single files (ending with .py) or packages here [testenv:coverage] # the coverage environment is called by the Github Action that runs the coverage measurement diff --git a/unittests/test_myclass.py b/unittests/test_myclass.py index b2634f2..ad73164 100644 --- a/unittests/test_myclass.py +++ b/unittests/test_myclass.py @@ -1,4 +1,4 @@ -from myclass import MyClass +from mymodule import MyClass class TestMyClass: From 2e51298f51d3b9286f0eef981ed8e237a57a425b Mon Sep 17 00:00:00 2001 From: konstantin Date: Wed, 10 Mar 2021 09:58:19 +0100 Subject: [PATCH 04/32] make tests a bit more "interesting" and thus avoid pylint-warnings ;) --- mymodule.py | 10 +++++----- unittests/test_myclass.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mymodule.py b/mymodule.py index 50ca089..ae2a341 100644 --- a/mymodule.py +++ b/mymodule.py @@ -12,11 +12,11 @@ def __init__(self): """ Initialize for the sake of initializing """ - pass + self.foo = "foo" - def do_something(self) -> bool: # pylint: disable=no-self-use + def do_something(self) -> str: """ - Actually does nothing - :return: + Actually does nothing. + :return: the value of foo """ - return True + return self.foo diff --git a/unittests/test_myclass.py b/unittests/test_myclass.py index ad73164..2ae4359 100644 --- a/unittests/test_myclass.py +++ b/unittests/test_myclass.py @@ -8,4 +8,4 @@ class TestMyClass: def test_something(self): my_class = MyClass() - assert my_class.do_something() is True + assert my_class.do_something() == "foo" From 0f27cb049bece7481668f24c61ee45ab4217f9c9 Mon Sep 17 00:00:00 2001 From: konstantin Date: Wed, 10 Mar 2021 10:04:35 +0100 Subject: [PATCH 05/32] foo is blacklisted by pylint --- mymodule.py | 6 +++--- unittests/test_myclass.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mymodule.py b/mymodule.py index ae2a341..0628ccf 100644 --- a/mymodule.py +++ b/mymodule.py @@ -12,11 +12,11 @@ def __init__(self): """ Initialize for the sake of initializing """ - self.foo = "foo" + self.my_instance_var = "abc" def do_something(self) -> str: """ Actually does nothing. - :return: the value of foo + :return: the value of an instance variable """ - return self.foo + return self.my_instance_var diff --git a/unittests/test_myclass.py b/unittests/test_myclass.py index 2ae4359..f8ed1df 100644 --- a/unittests/test_myclass.py +++ b/unittests/test_myclass.py @@ -3,9 +3,9 @@ class TestMyClass: """ - A class with pytest unittests. + A class with pytest unit tests. """ def test_something(self): my_class = MyClass() - assert my_class.do_something() == "foo" + assert my_class.do_something() == "my_instance_var" From b1edfa8b932a48c8722f0083e6d032dcbf2d37e2 Mon Sep 17 00:00:00 2001 From: konstantin Date: Wed, 10 Mar 2021 10:05:44 +0100 Subject: [PATCH 06/32] q: how hard could it be to write a working example test? a: yes. --- unittests/test_myclass.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittests/test_myclass.py b/unittests/test_myclass.py index f8ed1df..75810cc 100644 --- a/unittests/test_myclass.py +++ b/unittests/test_myclass.py @@ -8,4 +8,4 @@ class TestMyClass: def test_something(self): my_class = MyClass() - assert my_class.do_something() == "my_instance_var" + assert my_class.do_something() == "abc" From fd824a65752bf287c892c25b94037eae72d9ae00 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 10:08:18 +0100 Subject: [PATCH 07/32] highlight the highlights --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8460cf7..ce581ac 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ This is a template repository. It doesn't contain any actual code but only a basic setup for a Python project including: -+ project structure with ++ a basic **project structure** with + tox.ini + requirements.in + and a requirements.txt derived from it + an example class + an example unit test (using pytest) -+ separate Github Actions for ++ ready to use **Github Actions** for + [pytest](https://pytest.org) + [code coverage measurement](https://coverage.readthedocs.io) (fails below 80% by default) + [pylint](https://pylint.org/) (only accepts 10/10 code rating by default) From ffbf77a25e6e1fda3a964098f6d78a52aa4d79d1 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 10:09:25 +0100 Subject: [PATCH 08/32] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce581ac..1cde851 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# python_repo_template +# Python Template Repository including Unittests and Linting Actions This is a template repository. It doesn't contain any actual code but only a basic setup for a Python project including: From 07672f4b5cab791add6c93275e8457817cab2210 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 10:12:48 +0100 Subject: [PATCH 09/32] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cde851..7611ce3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Python Template Repository including Unittests and Linting Actions -This is a template repository. It doesn't contain any actual code but only a basic setup for a Python project including: +This is a template repository. It doesn't contain any useful code but only a minimal working setup for a Python project including: + a basic **project structure** with + tox.ini @@ -43,3 +43,7 @@ tox -e dev ### How to user with VS Code _please add docs here_ + + +## Contribute +You are very welcome to contribute to this template repository by opening a pull request against the main branch. From 3e89c4eb52e3dd9a384c23677d801f4291a0dc45 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 10:23:15 +0100 Subject: [PATCH 10/32] add status badges --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7611ce3..adc3d15 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ # Python Template Repository including Unittests and Linting Actions + +![Pytest status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Pytest/badge.svg) +![Coverage status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Coverage/badge.svg) +![Pylint status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Pylint/badge.svg) +![Black status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Black/badge.svg) This is a template repository. It doesn't contain any useful code but only a minimal working setup for a Python project including: From a4c942b1e56f951deedcc5d98a2b5b24976c9101 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 10 Mar 2021 10:49:08 +0100 Subject: [PATCH 11/32] =?UTF-8?q?=F0=9F=99=88=20Ignore=20VS=20Code=20setti?= =?UTF-8?q?ngs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b97131e..69012da 100644 --- a/.gitignore +++ b/.gitignore @@ -129,3 +129,6 @@ dmypy.json .pyre/ .idea/ + +# vscode settings +.vscode/ \ No newline at end of file From e866670103281a50c6c0f9f61ac1588729fd4f55 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 10 Mar 2021 10:50:23 +0100 Subject: [PATCH 12/32] =?UTF-8?q?=F0=9F=93=9D=20Add=20manual=20for=20VS=20?= =?UTF-8?q?Code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8460cf7..3858d22 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,19 @@ tox -e dev the [working directory of the unit tests](https://www.jetbrains.com/help/pycharm/creating-run-debug-configuration-for-tests.html) to the project root (instead of the unittest directory) -### How to user with VS Code - -_please add docs here_ +### How to use with VS Code + +1. Open the folder with VS Code. +2. **Select the python interpreter** which is created by tox. Open the command pallett with `CTRL + P` and type `Python: Select Interpreter`. Select the interpreter which is placed in `.tox/dev/Scripts/python.exe` under Windows or `.tox/dev/bin/python` under Linux and macOS. +3. **Setup pytest and pylint**. Therefore we open the file `.vscode/settings.json` which should be automatically generated during the interpreter setup. Insert the following lines into the settings: +```json + "python.testing.unittestEnabled": false, + "python.testing.nosetestsEnabled": false, + "python.testing.pytestEnabled": true, + "pythonTestExplorer.testFramework": "pytest", + "python.testing.pytestArgs": [ + "unittests" + ], + "python.linting.pylintEnabled": true +``` +4. Enjoy 🤗 \ No newline at end of file From 3e63e3130ccf3eb2c050a757b38e2dd596de52e2 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 10 Mar 2021 11:17:01 +0100 Subject: [PATCH 13/32] =?UTF-8?q?=E2=9E=95=20Add=20pre-commit=20to=20templ?= =?UTF-8?q?ate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the actual pre-commit settings do: * check yaml format * fix end-of-file * remove trailing whitespace * check for black formatting style --- .pre-commit-config.yaml | 12 ++++++++++++ tox.ini | 1 + 2 files changed, 13 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7d3b08f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/psf/black + rev: 20.8b1 # Replace by any tag/version: https://github.com/psf/black/tags + hooks: + - id: black + language_version: python3 diff --git a/tox.ini b/tox.ini index f3cbd23..b558862 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ deps = black pip-tools pytest + pre-commit commands = python -m pip install --upgrade pip pip-compile requirements.in From bfbba7fcd29db047d2c6080df1751213dcca8670 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:20:02 +0100 Subject: [PATCH 14/32] Update tox.ini Co-authored-by: hf-aschloegl <73470827+hf-aschloegl@users.noreply.github.com> --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index b558862..5e6587d 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,7 @@ deps = commands = python -m pytest --basetemp={envtmpdir} {posargs} [testenv:linting] -# the tests environment is called by the Github Action that runs the linter +# the linting environment is called by the Github Action that runs the linter deps = -rrequirements.txt pylint @@ -41,4 +41,4 @@ deps = coverage commands = coverage run -m pytest --basetemp={envtmpdir} {posargs} - coverage report --fail-under 80 --omit .tox/*,unittests/* \ No newline at end of file + coverage report --fail-under 80 --omit .tox/*,unittests/* From 5050d7e428647fff0e8a2d5e61823c7ce28925f1 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:21:20 +0100 Subject: [PATCH 15/32] Update tox.ini Co-authored-by: hf-aschloegl <73470827+hf-aschloegl@users.noreply.github.com> --- tox.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tox.ini b/tox.ini index 5e6587d..8b4a41f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,8 @@ [tox] +envlist = + tests + linting + coverage skip_missing_interpreters = True skipsdist = True From aa0da030c06efb6eaf95ae36722df49797dd6806 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:21:37 +0100 Subject: [PATCH 16/32] Update tox.ini Co-authored-by: hf-aschloegl <73470827+hf-aschloegl@users.noreply.github.com> --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 8b4a41f..9e63579 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,7 @@ commands = python -m pip install --upgrade pip deps = black pip-tools + pylint pytest pre-commit commands = From 2ad80b1a26c3aea0b80b556b748329e91d0a7f38 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:21:46 +0100 Subject: [PATCH 17/32] Update README.md Co-authored-by: hf-aschloegl <73470827+hf-aschloegl@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5e0474..cf78988 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Python Template Repository including Unittests and Linting Actions +# Python Template Repository including Unittests, Linting Actions and Coverage measurements ![Pytest status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Pytest/badge.svg) ![Coverage status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Coverage/badge.svg) From 990019a3b6a3ff4f4aacc1cf541f36f31596cf32 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:22:08 +0100 Subject: [PATCH 18/32] Update README.md Co-authored-by: hf-aschloegl <73470827+hf-aschloegl@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf78988..0c71ddf 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This is a template repository. It doesn't contain any useful code but only a min By default it uses Python version 3.9. -## How to use this Repository on Your Maschine +## How to use this Repository on Your Machine This introduction assumes that you have tox installed already ( see [installation instructions](https://tox.readthedocs.io/en/latest/install.html)) and that a `.toxbase` environment From ca755e5c72c26ca1132d5ee1011fd019c7eafbe4 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:22:13 +0100 Subject: [PATCH 19/32] Update README.md Co-authored-by: hf-aschloegl <73470827+hf-aschloegl@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c71ddf..5828170 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This introduction assumes that you have tox installed already ( see [installation instructions](https://tox.readthedocs.io/en/latest/install.html)) and that a `.toxbase` environment has been created. -If this is the case, clone this repository and create the `dev` environment on your maschine. +If this is the case, clone this repository and create the `dev` environment on your machine. ```bash tox -e dev From 7caad6f6f2ddcba77cc01a30bae1bd2dc3864188 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:25:40 +0100 Subject: [PATCH 20/32] rename to "Linting" --- .github/workflows/pythonlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonlint.yml b/.github/workflows/pythonlint.yml index 33b6210..a080f3f 100644 --- a/.github/workflows/pythonlint.yml +++ b/.github/workflows/pythonlint.yml @@ -1,4 +1,4 @@ -name: "Pylint" +name: "Linting" on: [push] jobs: From b2b6f532c572440e77b7e3c2fc7b2d81682cea23 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:25:59 +0100 Subject: [PATCH 21/32] rename to "Unittests" --- .github/workflows/unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index af77087..486694d 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -1,4 +1,4 @@ -name: "Pytest" +name: "Unittests" on: [push] jobs: From 3fced6587005528fb449be2708ddde9463fa306f Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:26:38 +0100 Subject: [PATCH 22/32] reference the correct/renamed badge in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5828170..05bd540 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Python Template Repository including Unittests, Linting Actions and Coverage measurements -![Pytest status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Pytest/badge.svg) +![Unittests status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Unittests/badge.svg) ![Coverage status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Coverage/badge.svg) -![Pylint status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Pylint/badge.svg) +![Linting status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Linting/badge.svg) ![Black status badge](https://github.com/Hochfrequenz/python_template_repository/workflows/Black/badge.svg) This is a template repository. It doesn't contain any useful code but only a minimal working setup for a Python project including: From f94a6f5703bc26439367e7bc6695b7df81941195 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:44:23 +0100 Subject: [PATCH 23/32] Update .github/workflows/coverage.yml Co-authored-by: hf-krechan <68426071+hf-krechan@users.noreply.github.com> --- .github/workflows/coverage.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d5df786..76f07cb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -8,7 +8,6 @@ jobs: matrix: python-version: [3.9] os: [ubuntu-latest] - tox: [tests] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From b0c451e74e2ac13b9c2f0890503e5e2ce93c656e Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:44:40 +0100 Subject: [PATCH 24/32] Update .github/workflows/pythonlint.yml Co-authored-by: hf-krechan <68426071+hf-krechan@users.noreply.github.com> --- .github/workflows/pythonlint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pythonlint.yml b/.github/workflows/pythonlint.yml index a080f3f..d64318a 100644 --- a/.github/workflows/pythonlint.yml +++ b/.github/workflows/pythonlint.yml @@ -9,7 +9,6 @@ jobs: matrix: python-version: [3.9] os: [ubuntu-latest] - tox: [linting] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From f49f86828b6ac3a90f5366424d2d9496d60e1c68 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:44:46 +0100 Subject: [PATCH 25/32] Update .github/workflows/pythonlint.yml Co-authored-by: hf-krechan <68426071+hf-krechan@users.noreply.github.com> --- .github/workflows/pythonlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonlint.yml b/.github/workflows/pythonlint.yml index d64318a..cefb3c9 100644 --- a/.github/workflows/pythonlint.yml +++ b/.github/workflows/pythonlint.yml @@ -21,4 +21,4 @@ jobs: pip install tox - name: Run Pylint via Tox run: | - tox -e ${{ matrix.tox }} + tox -e linting From 6e78bc600a22956de6fb98fa215fdc29e2694310 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:44:52 +0100 Subject: [PATCH 26/32] Update .github/workflows/unittests.yml Co-authored-by: hf-krechan <68426071+hf-krechan@users.noreply.github.com> --- .github/workflows/unittests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 486694d..5d896ef 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -8,7 +8,6 @@ jobs: matrix: python-version: [3.9] os: [ubuntu-latest] - tox: [tests] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From a2763012acb72125e7af6abecca0fe97e1a507a1 Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:44:58 +0100 Subject: [PATCH 27/32] Update .github/workflows/unittests.yml Co-authored-by: hf-krechan <68426071+hf-krechan@users.noreply.github.com> --- .github/workflows/unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 5d896ef..0f25ca8 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -20,4 +20,4 @@ jobs: pip install tox - name: Run the Unit Tests via Tox run: | - tox -e ${{ matrix.tox }} + tox -e tests From 752f5ef4cf821adf8f2e74a14a1b3d4e5df8432b Mon Sep 17 00:00:00 2001 From: hf-kklein Date: Wed, 10 Mar 2021 11:45:13 +0100 Subject: [PATCH 28/32] Update .gitignore Co-authored-by: hf-krechan <68426071+hf-krechan@users.noreply.github.com> --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 69012da..c2d86e1 100644 --- a/.gitignore +++ b/.gitignore @@ -131,4 +131,4 @@ dmypy.json .idea/ # vscode settings -.vscode/ \ No newline at end of file +.vscode/ From 841687caab8b621dcf3bfebf5fd6e42ea85d9c43 Mon Sep 17 00:00:00 2001 From: konstantin Date: Thu, 25 Mar 2021 18:25:29 +0100 Subject: [PATCH 29/32] introduce a pyproject.toml --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c63e7f1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[tool.black] +line-length = 120 + +[tool.isort] +line_length = 120 From 9c2f455a4f9e5eabc2171b814223c79ac848bc72 Mon Sep 17 00:00:00 2001 From: konstantin Date: Thu, 25 Mar 2021 18:30:12 +0100 Subject: [PATCH 30/32] remove CLI argument of black action black will automatically use pyproject.toml --- .github/workflows/black.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index a240e2c..12235d3 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -13,4 +13,4 @@ jobs: - name: Black Code Formatter uses: lgeiger/black-action@v1.0.1 with: - args: ". --check --line-length 100" + args: ". --check" From 675dd3a4eee3d660f707e30951c6a73c1d9af539 Mon Sep 17 00:00:00 2001 From: konstantin Date: Fri, 26 Mar 2021 10:27:17 +0100 Subject: [PATCH 31/32] Update tox.ini Co-authored-by: Annika <73470827+hf-aschloegl@users.noreply.github.com> --- tox.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tox.ini b/tox.ini index 9e63579..fe79648 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,8 @@ [tox] +envlist = + tests + linting + coverage envlist = tests linting From c309d7418abdba3bdbe9bcc7fb9a863d0152ed56 Mon Sep 17 00:00:00 2001 From: konstantin Date: Fri, 26 Mar 2021 10:30:11 +0100 Subject: [PATCH 32/32] fix broken tox file --- tox.ini | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tox.ini b/tox.ini index fe79648..9e63579 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,4 @@ [tox] -envlist = - tests - linting - coverage envlist = tests linting