From e3f4ee2c78b2e6f83721202a726aa6c7c29d3d10 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:15:17 +0200 Subject: [PATCH 001/144] rename project_name as directory_name --- README.md | 16 ++++++++-------- cookiecutter.json | 2 +- hooks/post_gen_project.py | 2 +- hooks/pre_gen_project.py | 6 +++--- setup.cfg | 2 +- tests/test_values.py | 8 ++++---- .../next_steps/01_sonarcloud_integration.md | 4 ++-- .../.github/next_steps/03_readthedocs.md | 4 ++-- {{cookiecutter.project_name}}/CITATION.cff | 2 +- {{cookiecutter.project_name}}/README.md | 14 +++++++------- {{cookiecutter.project_name}}/next_steps.md | 4 ++-- {{cookiecutter.project_name}}/project_setup.md | 2 +- .../sonar-project.properties | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 969fd961..4ac6f020 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ Use this [Cookiecutter](https://cookiecutter.readthedocs.io) template to generat an empty Python package. Features include: - Boilerplate tests and documentation, -- [Python setup configuration]({{cookiecutter.project_name}}/setup.py), +- [Python setup configuration]({{cookiecutter.directory_name}}/setup.py), - Open source software license, -- [Default Github actions]({{cookiecutter.project_name}}/.github/workflows) for building, testing and deployment +- [Default Github actions]({{cookiecutter.directory_name}}/.github/workflows) for building, testing and deployment - Code style checking, -- [Editorconfig]({{cookiecutter.project_name}}/.editorconfig), -- Miscellaneous files, such as [Change log]({{cookiecutter.project_name}}/CHANGELOG.md), [Code of Conduct]({{cookiecutter.project_name}}/CODE_OF_CONDUCT.md), and [Contributing guidelines]({{cookiecutter.project_name}}/CONTRIBUTING.md), -- A [README]({{cookiecutter.project_name}}/README.md) and [a separate document]({{cookiecutter.project_name}}/project_setup.md) with extensive documentation about project setup. +- [Editorconfig]({{cookiecutter.directory_name}}/.editorconfig), +- Miscellaneous files, such as [Change log]({{cookiecutter.directory_name}}/CHANGELOG.md), [Code of Conduct]({{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md), and [Contributing guidelines]({{cookiecutter.directory_name}}/CONTRIBUTING.md), +- A [README]({{cookiecutter.directory_name}}/README.md) and [a separate document]({{cookiecutter.directory_name}}/project_setup.md) with extensive documentation about project setup. - Continuous code quality and code coverage reporting using [Sonarcloud](https://sonarcloud.io/) ## Badges @@ -59,7 +59,7 @@ cookiecutter https://github.com/nlesc/python-template.git | Name | Default value | Explanation | | ------------------------- | ------------- | ----------- | | package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. | -| project_name | my-python-project | Name of the project that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. | +| directory_name | my-python-project | Name of the project that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. | | package_short_description |   | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. | | version | 0.1.0 |   | | github_organization | <my-github-organization> | GitHub organization that will contain this project's repository. This can also be your GitHub user name. | @@ -70,7 +70,7 @@ cookiecutter https://github.com/nlesc/python-template.git | code_of_conduct_email | yourname@esciencecenter.nl | Email address of the person who should be contacted in case of violations of the Code of Conduct. | Once the project files have been generated, follow the steps outlined in -[{{cookiecutter.project_name}}/next_steps.md]({{cookiecutter.project_name}}/next_steps.md). +[{{cookiecutter.directory_name}}/next_steps.md]({{cookiecutter.directory_name}}/next_steps.md). ### Step 3/3: Read about what was just generated @@ -106,7 +106,7 @@ my-python-project/ └── test_my_module.py ``` -For an explanation of what's there, read on in the [project_setup.md]({{cookiecutter.project_name}}/project_setup.md) file. +For an explanation of what's there, read on in the [project_setup.md]({{cookiecutter.directory_name}}/project_setup.md) file. ## Examples diff --git a/cookiecutter.json b/cookiecutter.json index 2d3db56f..53efd848 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,6 +1,6 @@ { "package_name": "my_python_package", - "project_name": "my-python-project", + "directory_name": "my-python-project", "_copy_without_render": [".github/workflows/*"], "package_short_description": "", "version": "0.1.0", diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 39960c13..f7ceaa80 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -1 +1 @@ -print("\nProject was successfully generated. For next steps, refer to file {{ cookiecutter.project_name }}/next_steps.md.\n") +print("\nProject was successfully generated. For next steps, refer to file {{ cookiecutter.directory_name }}/next_steps.md.\n") diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index c0e56fa3..1b8b598b 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -1,10 +1,10 @@ # Note: cookiecutter first makes the main level directory using -# project_name from cookiecutter.json before running this hook +# directory_name from cookiecutter.json before running this hook {{ cookiecutter.update({ "package_name": cookiecutter.package_name.lower().replace(" ", "_").replace("-", "_"), - "project_name": cookiecutter.project_name.lower().replace(" ", "-"), + "directory_name": cookiecutter.directory_name.lower().replace(" ", "-"), "full_name": cookiecutter.full_name.replace('\"', '\\\"'), - "repository": "https://github.com/" + cookiecutter.github_organization + "/" + cookiecutter.project_name.lower().replace(" ", "-"), + "repository": "https://github.com/" + cookiecutter.github_organization + "/" + cookiecutter.directory_name.lower().replace(" ", "-"), "package_short_description": cookiecutter.package_short_description.replace('\"', '\\\"') }) }} diff --git a/setup.cfg b/setup.cfg index e4f70cae..f9ad8c37 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,4 +47,4 @@ dev = [tool:pytest] testpaths = tests -norecursedirs = .git .github hooks {{cookiecutter.project_name}} +norecursedirs = .git .github hooks {{cookiecutter.directory_name}} diff --git a/tests/test_values.py b/tests/test_values.py index 22001147..d4b07ff2 100644 --- a/tests/test_values.py +++ b/tests/test_values.py @@ -21,18 +21,18 @@ def test_single_quotes_in_name_and_description(cookies): assert project.exit_code == 0 -def test_dash_in_project_name(cookies): +def test_dash_in_directory_name(cookies): ctx = { - "project_name": "my-python-project" + "directory_name": "my-python-project" } project = cookies.bake(extra_context=ctx) assert project.exit_code == 0 -def test_space_in_project_name(cookies): +def test_space_in_directory_name(cookies): ctx = { - "project_name": "my python project" + "directory_name": "my python project" } project = cookies.bake(extra_context=ctx) diff --git a/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md b/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md index 95c3a2c5..16e9db2c 100644 --- a/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md +++ b/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md @@ -10,7 +10,7 @@ In order to configure Sonarcloud analysis [GitHub Action workflow](.github/workf 1. login with your GitHub account 1. add Sonarcloud organization or reuse existing one 1. set up a repository -1. go to [new code definition administration page](https://sonarcloud.io/project/new_code?id={{cookiecutter.github_organization}}_{{cookiecutter.project_name}}) and select `Number of days` option +1. go to [new code definition administration page](https://sonarcloud.io/project/new_code?id={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}) and select `Number of days` option 1. To be able to run the analysis: 1. a token must be created at [Sonarcloud account](https://sonarcloud.io/account/security/) - 1. the created token must be added as `SONAR_TOKEN` to [secrets on GitHub](https://github.com/{{cookiecutter.github_organization}}/{{cookiecutter.project_name}}/settings/secrets/actions) + 1. the created token must be added as `SONAR_TOKEN` to [secrets on GitHub](https://github.com/{{cookiecutter.github_organization}}/{{cookiecutter.directory_name}}/settings/secrets/actions) diff --git a/{{cookiecutter.project_name}}/.github/next_steps/03_readthedocs.md b/{{cookiecutter.project_name}}/.github/next_steps/03_readthedocs.md index 1ad6bf26..30635cbb 100644 --- a/{{cookiecutter.project_name}}/.github/next_steps/03_readthedocs.md +++ b/{{cookiecutter.project_name}}/.github/next_steps/03_readthedocs.md @@ -9,12 +9,12 @@ To host the documentation of this repository please perform the following instru 1. go to [Read the Docs](https://readthedocs.org/dashboard/import/?) 1. log in with your GitHub account -1. find `{{ cookiecutter.github_organization }}/{{ cookiecutter.project_name }}` in list and press `+` button. +1. find `{{ cookiecutter.github_organization }}/{{ cookiecutter.directory_name }}` in list and press `+` button. * If repository is not listed, 1. go to [Read the Docs GitHub app](https://github.com/settings/connections/applications/fae83c942bc1d89609e2) 2. make sure {{ cookiecutter.github_organization }} has been granted access. 3. reload repository list on Read the Docs import page -1. wait for the first build to be completed at +1. wait for the first build to be completed at 1. check that the link of the documentation badge in the [README.md]({{ cookiecutter.repository }}) works See [README.dev.md#]({{cookiecutter.repository}}/blob/main/README.dev.md#generating-the-api-docs) how to build documentation site locally. diff --git a/{{cookiecutter.project_name}}/CITATION.cff b/{{cookiecutter.project_name}}/CITATION.cff index 797afddf..29f05b7e 100644 --- a/{{cookiecutter.project_name}}/CITATION.cff +++ b/{{cookiecutter.project_name}}/CITATION.cff @@ -1,7 +1,7 @@ # YAML 1.2 --- cff-version: "1.1.0" -title: "{{ cookiecutter.project_name }}" +title: "{{ cookiecutter.directory_name }}" authors: - family-names: {{ cookiecutter.full_name.split(' ')[-1] }} diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.project_name}}/README.md index 5f76a536..abead88a 100644 --- a/{{cookiecutter.project_name}}/README.md +++ b/{{cookiecutter.project_name}}/README.md @@ -5,15 +5,15 @@ | fair-software.eu recommendations | | | :-- | :-- | | (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)]({{cookiecutter.repository}}) | -| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{cookiecutter.github_organization}}/{{cookiecutter.project_name}})]({{cookiecutter.repository}}) | -| (3/5) community registry | [![RSD](https://img.shields.io/badge/rsd-{{cookiecutter.project_name}}-00a3e3.svg)](https://www.research-software.nl/software/{{cookiecutter.project_name}}) [![workflow pypi badge](https://img.shields.io/pypi/v/{{cookiecutter.project_name}}.svg?colorB=blue)](https://pypi.python.org/project/{{cookiecutter.project_name}}/) | +| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{cookiecutter.github_organization}}/{{cookiecutter.directory_name}})]({{cookiecutter.repository}}) | +| (3/5) community registry | [![RSD](https://img.shields.io/badge/rsd-{{cookiecutter.directory_name}}-00a3e3.svg)](https://www.research-software.nl/software/{{cookiecutter.directory_name}}) [![workflow pypi badge](https://img.shields.io/pypi/v/{{cookiecutter.directory_name}}.svg?colorB=blue)](https://pypi.python.org/project/{{cookiecutter.directory_name}}/) | | (4/5) citation | [![DOI](https://zenodo.org/badge/DOI/.svg)](https://doi.org/) | | (5/5) checklist | [![workflow cii badge](https://bestpractices.coreinfrastructure.org/projects//badge)](https://bestpractices.coreinfrastructure.org/projects/) | | howfairis | [![fair-software badge](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8B-yellow)](https://fair-software.eu) | | **Other best practices** |   | -| Static analysis | [![workflow scq badge](https://sonarcloud.io/api/project_badges/measure?project={{cookiecutter.github_organization}}_{{cookiecutter.project_name}}&metric=alert_status)](https://sonarcloud.io/dashboard?id={{cookiecutter.github_organization}}_{{cookiecutter.project_name}}) | -| Coverage | [![workflow scc badge](https://sonarcloud.io/api/project_badges/measure?project={{cookiecutter.github_organization}}_{{cookiecutter.project_name}}&metric=coverage)](https://sonarcloud.io/dashboard?id={{cookiecutter.github_organization}}_{{cookiecutter.project_name}}) | -| Documentation | [![Documentation Status](https://readthedocs.org/projects/{{cookiecutter.project_name}}/badge/?version=latest)](https://{{cookiecutter.project_name}}.readthedocs.io/en/latest/?badge=latest) | +| Static analysis | [![workflow scq badge](https://sonarcloud.io/api/project_badges/measure?project={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}&metric=alert_status)](https://sonarcloud.io/dashboard?id={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}) | +| Coverage | [![workflow scc badge](https://sonarcloud.io/api/project_badges/measure?project={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}&metric=coverage)](https://sonarcloud.io/dashboard?id={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}) | +| Documentation | [![Documentation Status](https://readthedocs.org/projects/{{cookiecutter.directory_name}}/badge/?version=latest)](https://{{cookiecutter.directory_name}}.readthedocs.io/en/latest/?badge=latest) | | **GitHub Actions** |   | | Build | [![build]({{cookiecutter.repository}}/actions/workflows/build.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/build.yml) | | Metadata consistency | [![cffconvert]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) | @@ -33,7 +33,7 @@ To install {{ cookiecutter.package_name }} from GitHub repository, do: ```console git clone {{ cookiecutter.repository }}.git -cd {{ cookiecutter.project_name }} +cd {{ cookiecutter.directory_name }} python3 -m pip install . ``` @@ -43,7 +43,7 @@ Include a link to your project's full documentation here. ## Contributing -If you want to contribute to the development of {{ cookiecutter.project_name }}, +If you want to contribute to the development of {{ cookiecutter.directory_name }}, have a look at the [contribution guidelines](CONTRIBUTING.md). ## Credits diff --git a/{{cookiecutter.project_name}}/next_steps.md b/{{cookiecutter.project_name}}/next_steps.md index dc10897b..66e38c6a 100644 --- a/{{cookiecutter.project_name}}/next_steps.md +++ b/{{cookiecutter.project_name}}/next_steps.md @@ -7,7 +7,7 @@ control](https://guide.esciencecenter.nl/#/best_practices/version_control) using [git](https://git-scm.com/) and [GitHub](https://github.com/). ```shell -cd {{ cookiecutter.project_name }} +cd {{ cookiecutter.directory_name }} git init git add --all git commit -m "first commit" @@ -19,7 +19,7 @@ git remote add origin {{ cookiecutter.repository }} Go to [https://github.com/organizations/{{cookiecutter.github_organization}}/repositories/new](https://github.com/organizations/{{cookiecutter.github_organization}}/repositories/new) -and create a new repository named `{{ cookiecutter.project_name }}` as an empty repository, then push your commits to GitHub: +and create a new repository named `{{ cookiecutter.directory_name }}` as an empty repository, then push your commits to GitHub: ```shell git push --set-upstream origin main diff --git a/{{cookiecutter.project_name}}/project_setup.md b/{{cookiecutter.project_name}}/project_setup.md index d9d50dfb..1977902e 100644 --- a/{{cookiecutter.project_name}}/project_setup.md +++ b/{{cookiecutter.project_name}}/project_setup.md @@ -77,7 +77,7 @@ help you decide which tool to use for packaging. ## Package version number - We recommend using [semantic versioning](https://guide.esciencecenter.nl/#/best_practices/releases?id=semantic-versioning). -- For convenience, the package version is stored in a single place: `{{ cookiecutter.project_name }}/.bumpversion.cfg`. +- For convenience, the package version is stored in a single place: `{{ cookiecutter.directory_name }}/.bumpversion.cfg`. For updating the version number, make sure the dev dependencies are installed and run `bumpversion patch`, `bumpversion minor`, or `bumpversion major` as appropriate. - Don't forget to update the version number before [making a release](https://guide.esciencecenter.nl/#/best_practices/releases)! diff --git a/{{cookiecutter.project_name}}/sonar-project.properties b/{{cookiecutter.project_name}}/sonar-project.properties index 5adf322d..c9c07032 100644 --- a/{{cookiecutter.project_name}}/sonar-project.properties +++ b/{{cookiecutter.project_name}}/sonar-project.properties @@ -1,5 +1,5 @@ sonar.organization={{ cookiecutter.github_organization }} -sonar.projectKey={{ cookiecutter.github_organization }}_{{ cookiecutter.project_name }} +sonar.projectKey={{ cookiecutter.github_organization }}_{{ cookiecutter.directory_name }} sonar.host.url=https://sonarcloud.io sonar.sources={{ cookiecutter.package_name }}/ sonar.tests=tests/ From acdbb3f7fcaeb614754b3e80828013244888ad85 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:18:19 +0200 Subject: [PATCH 002/144] change question order --- cookiecutter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index 53efd848..1d98a3c9 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,6 +1,6 @@ { - "package_name": "my_python_package", "directory_name": "my-python-project", + "package_name": "my_python_package", "_copy_without_render": [".github/workflows/*"], "package_short_description": "", "version": "0.1.0", From caeffd1b258267809a1c65b228a7375827501a4c Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:30:36 +0200 Subject: [PATCH 003/144] change the default value for directory name --- cookiecutter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index 1d98a3c9..a1c2a3de 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,5 +1,5 @@ { - "directory_name": "my-python-project", + "directory_name": "my-project-directory", "package_name": "my_python_package", "_copy_without_render": [".github/workflows/*"], "package_short_description": "", From fda26fa1ef5409e17d53160bb59a0e65216eeb7f Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:43:10 +0200 Subject: [PATCH 004/144] revert the default value for directory name --- cookiecutter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index a1c2a3de..1d98a3c9 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,5 +1,5 @@ { - "directory_name": "my-project-directory", + "directory_name": "my-python-project", "package_name": "my_python_package", "_copy_without_render": [".github/workflows/*"], "package_short_description": "", From b68cb609d4c962820645a22d88c8c98373bffd2f Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:44:21 +0200 Subject: [PATCH 005/144] Update README.md Co-authored-by: Jurriaan H. Spaaks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ac6f020..218bafae 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ cookiecutter https://github.com/nlesc/python-template.git | Name | Default value | Explanation | | ------------------------- | ------------- | ----------- | | package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. | -| directory_name | my-python-project | Name of the project that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. | +| directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. | | package_short_description |   | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. | | version | 0.1.0 |   | | github_organization | <my-github-organization> | GitHub organization that will contain this project's repository. This can also be your GitHub user name. | From 9e3c9cb4d2e227335eaec95d43196c2de0e2196b Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:47:41 +0200 Subject: [PATCH 006/144] update table of variable names --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 218bafae..38f87a48 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ cookiecutter https://github.com/nlesc/python-template.git | Name | Default value | Explanation | | ------------------------- | ------------- | ----------- | +| directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. See [here](https://github.com/NLeSC/python-template#step-33-read-about-what-was-just-generated) | | package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. | -| directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. | | package_short_description |   | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. | | version | 0.1.0 |   | | github_organization | <my-github-organization> | GitHub organization that will contain this project's repository. This can also be your GitHub user name. | From 28f1f17265aead5fc9d47182b814ea7344b0347f Mon Sep 17 00:00:00 2001 From: "Jurriaan H. Spaaks" Date: Mon, 3 May 2021 14:47:55 +0200 Subject: [PATCH 007/144] Update cookiecutter.json --- cookiecutter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index bdd74d59..1810b584 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -8,7 +8,7 @@ "version": "0.1.0", "github_organization": "", "license": ["Apache Software License 2.0", "MIT license", "BSD license", "ISC license", "GNU General Public License v3 or later", "Not open source"], - "full_name": "John Smith", + "full_name": "Jane Smith", "email": "yourname@esciencecenter.nl", "copyright_holder": "Netherlands eScience Center", "code_of_conduct_email": "{{ cookiecutter.email }}" From b53c1775b3b6e15d249a29d90a91b8c79c58855f Mon Sep 17 00:00:00 2001 From: "Jurriaan H. Spaaks" Date: Mon, 3 May 2021 14:48:31 +0200 Subject: [PATCH 008/144] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb6e5986..a50d58ee 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ cookiecutter https://github.com/nlesc/python-template.git | version | 0.1.0 |   | | github_organization | <my-github-organization> | GitHub organization that will contain this project's repository. This can also be your GitHub user name. | | license | Apache Software License 2.0 | The software license under which the code is made available. | -| full_name | John Smith | Your full name, e.g. _John Smith_. | +| full_name | Jane Smith | Your full name, e.g. _Jane Smith_. | | email | yourname@esciencecenter.nl | Your (work) email address. | | copyright_holder | Netherlands eScience Center | Name(s) of the organization(s) or person(s) who hold the copyright of the software. | | code_of_conduct_email | yourname@esciencecenter.nl | Email address of the person who should be contacted in case of violations of the Code of Conduct. | From fbe14d8a179c5a353b193d51db69a6c876979b7a Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:50:49 +0200 Subject: [PATCH 009/144] Update README.md Co-authored-by: Jurriaan H. Spaaks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38f87a48..e6d810d5 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ cookiecutter https://github.com/nlesc/python-template.git | Name | Default value | Explanation | | ------------------------- | ------------- | ----------- | -| directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. See [here](https://github.com/NLeSC/python-template#step-33-read-about-what-was-just-generated) | +| directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. To get an impression of what will be generated, see the directory tree [below](https://github.com/NLeSC/python-template#step-33-read-about-what-was-just-generated) | | package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. | | package_short_description |   | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. | | version | 0.1.0 |   | From 2d035b9242f0cd830cb493840fecf03e80743ccf Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 14:57:51 +0200 Subject: [PATCH 010/144] Update {{cookiecutter.project_name}}/README.md Co-authored-by: Jurriaan H. Spaaks --- {{cookiecutter.project_name}}/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.project_name}}/README.md index abead88a..2d22c255 100644 --- a/{{cookiecutter.project_name}}/README.md +++ b/{{cookiecutter.project_name}}/README.md @@ -43,7 +43,7 @@ Include a link to your project's full documentation here. ## Contributing -If you want to contribute to the development of {{ cookiecutter.directory_name }}, +If you want to contribute to the development of {{ cookiecutter.package_name }}, have a look at the [contribution guidelines](CONTRIBUTING.md). ## Credits From 45b944ff3c2e410b8010444568d2f9449806e943 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 15:27:18 +0200 Subject: [PATCH 011/144] Update {{cookiecutter.project_name}}/CITATION.cff Co-authored-by: Jurriaan H. Spaaks --- {{cookiecutter.project_name}}/CITATION.cff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/CITATION.cff b/{{cookiecutter.project_name}}/CITATION.cff index 29f05b7e..b9d084cd 100644 --- a/{{cookiecutter.project_name}}/CITATION.cff +++ b/{{cookiecutter.project_name}}/CITATION.cff @@ -1,7 +1,7 @@ # YAML 1.2 --- cff-version: "1.1.0" -title: "{{ cookiecutter.directory_name }}" +title: "{{ cookiecutter.package_name }}" authors: - family-names: {{ cookiecutter.full_name.split(' ')[-1] }} From 53797566cb91b104edcbf5230e675ffe06fa6cdf Mon Sep 17 00:00:00 2001 From: "Jurriaan H. Spaaks" Date: Mon, 3 May 2021 18:18:29 +0200 Subject: [PATCH 012/144] updated links in badges with package name --- {{cookiecutter.project_name}}/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.project_name}}/README.md index 2d22c255..e86e4bae 100644 --- a/{{cookiecutter.project_name}}/README.md +++ b/{{cookiecutter.project_name}}/README.md @@ -6,7 +6,7 @@ | :-- | :-- | | (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)]({{cookiecutter.repository}}) | | (2/5) license | [![github license badge](https://img.shields.io/github/license/{{cookiecutter.github_organization}}/{{cookiecutter.directory_name}})]({{cookiecutter.repository}}) | -| (3/5) community registry | [![RSD](https://img.shields.io/badge/rsd-{{cookiecutter.directory_name}}-00a3e3.svg)](https://www.research-software.nl/software/{{cookiecutter.directory_name}}) [![workflow pypi badge](https://img.shields.io/pypi/v/{{cookiecutter.directory_name}}.svg?colorB=blue)](https://pypi.python.org/project/{{cookiecutter.directory_name}}/) | +| (3/5) community registry | [![RSD](https://img.shields.io/badge/rsd-{{cookiecutter.package_name}}-00a3e3.svg)](https://www.research-software.nl/software/{{cookiecutter.package_name}}) [![workflow pypi badge](https://img.shields.io/pypi/v/{{cookiecutter.package_name}}.svg?colorB=blue)](https://pypi.python.org/project/{{cookiecutter.package_name}}/) | | (4/5) citation | [![DOI](https://zenodo.org/badge/DOI/.svg)](https://doi.org/) | | (5/5) checklist | [![workflow cii badge](https://bestpractices.coreinfrastructure.org/projects//badge)](https://bestpractices.coreinfrastructure.org/projects/) | | howfairis | [![fair-software badge](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8B-yellow)](https://fair-software.eu) | From 77de9b0e13f5ba83ded315b4eecdeda363c2c87d Mon Sep 17 00:00:00 2001 From: "Jurriaan H. Spaaks" Date: Mon, 3 May 2021 18:28:15 +0200 Subject: [PATCH 013/144] updated a few lingering project_name s --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f2352527..3f5ead10 100644 --- a/README.md +++ b/README.md @@ -8,23 +8,23 @@ Use this [Cookiecutter](https://cookiecutter.readthedocs.io) template to generat an empty Python package. Features include: - Boilerplate unit tests and documentation, -- [Python static setup configuration]({{cookiecutter.project_name}}/setup.cfg), +- [Python static setup configuration]({{cookiecutter.directory_name}}/setup.cfg), - Open source software license, -- Continuous integration with [GitHub action workflows]({{cookiecutter.project_name}}/.github/workflows) for building, testing, link checking and linting, +- Continuous integration with [GitHub action workflows]({{cookiecutter.directory_name}}/.github/workflows) for building, testing, link checking and linting, - Code style checking with [prospector](https://pypi.org/project/prospector/), -- [Editorconfig]({{cookiecutter.project_name}}/.editorconfig), +- [Editorconfig]({{cookiecutter.directory_name}}/.editorconfig), - Usage and contribution documents: - - [README.md]({{cookiecutter.project_name}}/README.md) for package users, - - [README.dev.md]({{cookiecutter.project_name}}/README.dev.md) for package developer, - - [project_setup.md]({{cookiecutter.project_name}}/project_setup.md) with extensive documentation about project setup, - - [Change log]({{cookiecutter.project_name}}/CHANGELOG.md), - - [Code of Conduct]({{cookiecutter.project_name}}/CODE_OF_CONDUCT.md), - - [Contributing guidelines]({{cookiecutter.project_name}}/CONTRIBUTING.md), + - [README.md]({{cookiecutter.directory_name}}/README.md) for package users, + - [README.dev.md]({{cookiecutter.directory_name}}/README.dev.md) for package developer, + - [project_setup.md]({{cookiecutter.directory_name}}/project_setup.md) with extensive documentation about project setup, + - [Change log]({{cookiecutter.directory_name}}/CHANGELOG.md), + - [Code of Conduct]({{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md), + - [Contributing guidelines]({{cookiecutter.directory_name}}/CONTRIBUTING.md), - Continuous code quality and code coverage reporting using [Sonarcloud](https://sonarcloud.io/), -- Automatic creation of [issues]({{cookiecutter.project_name}}/.github/next_steps) with instructions how to pass all GitHub action workflows and integrate with services like Zenodo and Read the Docs, -- Instructions how to make package [citable]({{cookiecutter.project_name}}/.github/next_steps/04_citation.md) +- Automatic creation of [issues]({{cookiecutter.directory_name}}/.github/next_steps) with instructions how to pass all GitHub action workflows and integrate with services like Zenodo and Read the Docs, +- Instructions how to make package [citable]({{cookiecutter.directory_name}}/.github/next_steps/04_citation.md) - FAIR software recommendation badge, -- Optional [pre commit hook](https://github.com/NLeSC/python-template/blob/main/%7B%7Bcookiecutter.project_name%7D%7D/README.dev.md#running-linters-locally) to catch lint errors early +- Optional [pre commit hook]({{cookiecutter.directory_name}}/README.dev.md#running-linters-locally) to catch lint errors early ## Badges @@ -144,7 +144,7 @@ my-python-project/ └── test_my_module.py ``` -For an explanation of what's there, read on in the [project_setup.md]({{cookiecutter.project_name}}/project_setup.md) file. +For an explanation of what's there, read on in the [project_setup.md]({{cookiecutter.directory_name}}/project_setup.md) file. There are also instructions on how to [apply the template to an existing Python package](ADD_TO_EXISTING_PACKAGE.md). ## Examples From 6b731d486ac22cfbd0568c397ecc0dac7b4d4d11 Mon Sep 17 00:00:00 2001 From: "Jurriaan H. Spaaks" Date: Mon, 3 May 2021 18:35:58 +0200 Subject: [PATCH 014/144] renamed template dir name --- .../.bumpversion.cfg | 0 .../.editorconfig | 0 .../.githooks/pre-commit | 0 .../.github/next_steps/01_sonarcloud_integration.md | 0 .../.github/next_steps/02_citation.md | 0 .../.github/next_steps/03_readthedocs.md | 0 .../.github/next_steps/04_zenodo_integration.md | 0 .../.github/next_steps/05_linting.md | 0 .../.github/workflows/build.yml | 0 .../.github/workflows/cffconvert.yml | 0 .../.github/workflows/lint.yml | 0 .../.github/workflows/markdown-link-check.yml | 0 .../.github/workflows/next_steps.yml | 0 .../.github/workflows/sonarcloud.yml | 0 .../.gitignore | 0 .../.mlc-config.json | 0 .../.prospector.yml | 0 .../.pylintrc | 0 .../CHANGELOG.md | 0 .../CITATION.cff | 0 .../CODE_OF_CONDUCT.md | 0 .../CONTRIBUTING.md | 0 .../LICENSE | 0 .../MANIFEST.in | 0 .../NOTICE | 0 .../README.dev.md | 0 .../README.md | 0 .../docs/Makefile | 0 .../docs/_static/theme_overrides.css | 0 .../docs/_templates/.gitignore | 0 .../docs/conf.py | 0 .../docs/index.rst | 0 .../docs/make.bat | 0 .../next_steps.md | 0 .../project_setup.md | 0 .../pyproject.toml | 0 .../setup.cfg | 0 .../setup.py | 0 .../sonar-project.properties | 0 .../tests/__init__.py | 0 .../tests/test_my_module.py | 0 .../{{cookiecutter.package_name}}/__init__.py | 0 .../{{cookiecutter.package_name}}/__version__.py | 0 .../{{cookiecutter.package_name}}/my_module.py | 0 44 files changed, 0 insertions(+), 0 deletions(-) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.bumpversion.cfg (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.editorconfig (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.githooks/pre-commit (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/next_steps/01_sonarcloud_integration.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/next_steps/02_citation.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/next_steps/03_readthedocs.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/next_steps/04_zenodo_integration.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/next_steps/05_linting.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/workflows/build.yml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/workflows/cffconvert.yml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/workflows/lint.yml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/workflows/markdown-link-check.yml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/workflows/next_steps.yml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.github/workflows/sonarcloud.yml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.gitignore (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.mlc-config.json (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.prospector.yml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/.pylintrc (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/CHANGELOG.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/CITATION.cff (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/CODE_OF_CONDUCT.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/CONTRIBUTING.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/LICENSE (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/MANIFEST.in (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/NOTICE (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/README.dev.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/README.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/docs/Makefile (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/docs/_static/theme_overrides.css (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/docs/_templates/.gitignore (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/docs/conf.py (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/docs/index.rst (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/docs/make.bat (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/next_steps.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/project_setup.md (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/pyproject.toml (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/setup.cfg (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/setup.py (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/sonar-project.properties (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/tests/__init__.py (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/tests/test_my_module.py (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/{{cookiecutter.package_name}}/__init__.py (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/{{cookiecutter.package_name}}/__version__.py (100%) rename {{{cookiecutter.project_name}} => {{cookiecutter.directory_name}}}/{{cookiecutter.package_name}}/my_module.py (100%) diff --git a/{{cookiecutter.project_name}}/.bumpversion.cfg b/{{cookiecutter.directory_name}}/.bumpversion.cfg similarity index 100% rename from {{cookiecutter.project_name}}/.bumpversion.cfg rename to {{cookiecutter.directory_name}}/.bumpversion.cfg diff --git a/{{cookiecutter.project_name}}/.editorconfig b/{{cookiecutter.directory_name}}/.editorconfig similarity index 100% rename from {{cookiecutter.project_name}}/.editorconfig rename to {{cookiecutter.directory_name}}/.editorconfig diff --git a/{{cookiecutter.project_name}}/.githooks/pre-commit b/{{cookiecutter.directory_name}}/.githooks/pre-commit similarity index 100% rename from {{cookiecutter.project_name}}/.githooks/pre-commit rename to {{cookiecutter.directory_name}}/.githooks/pre-commit diff --git a/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md b/{{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md similarity index 100% rename from {{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md rename to {{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md diff --git a/{{cookiecutter.project_name}}/.github/next_steps/02_citation.md b/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md similarity index 100% rename from {{cookiecutter.project_name}}/.github/next_steps/02_citation.md rename to {{cookiecutter.directory_name}}/.github/next_steps/02_citation.md diff --git a/{{cookiecutter.project_name}}/.github/next_steps/03_readthedocs.md b/{{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md similarity index 100% rename from {{cookiecutter.project_name}}/.github/next_steps/03_readthedocs.md rename to {{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md diff --git a/{{cookiecutter.project_name}}/.github/next_steps/04_zenodo_integration.md b/{{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md similarity index 100% rename from {{cookiecutter.project_name}}/.github/next_steps/04_zenodo_integration.md rename to {{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md diff --git a/{{cookiecutter.project_name}}/.github/next_steps/05_linting.md b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md similarity index 100% rename from {{cookiecutter.project_name}}/.github/next_steps/05_linting.md rename to {{cookiecutter.directory_name}}/.github/next_steps/05_linting.md diff --git a/{{cookiecutter.project_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml similarity index 100% rename from {{cookiecutter.project_name}}/.github/workflows/build.yml rename to {{cookiecutter.directory_name}}/.github/workflows/build.yml diff --git a/{{cookiecutter.project_name}}/.github/workflows/cffconvert.yml b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml similarity index 100% rename from {{cookiecutter.project_name}}/.github/workflows/cffconvert.yml rename to {{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml diff --git a/{{cookiecutter.project_name}}/.github/workflows/lint.yml b/{{cookiecutter.directory_name}}/.github/workflows/lint.yml similarity index 100% rename from {{cookiecutter.project_name}}/.github/workflows/lint.yml rename to {{cookiecutter.directory_name}}/.github/workflows/lint.yml diff --git a/{{cookiecutter.project_name}}/.github/workflows/markdown-link-check.yml b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml similarity index 100% rename from {{cookiecutter.project_name}}/.github/workflows/markdown-link-check.yml rename to {{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml diff --git a/{{cookiecutter.project_name}}/.github/workflows/next_steps.yml b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml similarity index 100% rename from {{cookiecutter.project_name}}/.github/workflows/next_steps.yml rename to {{cookiecutter.directory_name}}/.github/workflows/next_steps.yml diff --git a/{{cookiecutter.project_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml similarity index 100% rename from {{cookiecutter.project_name}}/.github/workflows/sonarcloud.yml rename to {{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml diff --git a/{{cookiecutter.project_name}}/.gitignore b/{{cookiecutter.directory_name}}/.gitignore similarity index 100% rename from {{cookiecutter.project_name}}/.gitignore rename to {{cookiecutter.directory_name}}/.gitignore diff --git a/{{cookiecutter.project_name}}/.mlc-config.json b/{{cookiecutter.directory_name}}/.mlc-config.json similarity index 100% rename from {{cookiecutter.project_name}}/.mlc-config.json rename to {{cookiecutter.directory_name}}/.mlc-config.json diff --git a/{{cookiecutter.project_name}}/.prospector.yml b/{{cookiecutter.directory_name}}/.prospector.yml similarity index 100% rename from {{cookiecutter.project_name}}/.prospector.yml rename to {{cookiecutter.directory_name}}/.prospector.yml diff --git a/{{cookiecutter.project_name}}/.pylintrc b/{{cookiecutter.directory_name}}/.pylintrc similarity index 100% rename from {{cookiecutter.project_name}}/.pylintrc rename to {{cookiecutter.directory_name}}/.pylintrc diff --git a/{{cookiecutter.project_name}}/CHANGELOG.md b/{{cookiecutter.directory_name}}/CHANGELOG.md similarity index 100% rename from {{cookiecutter.project_name}}/CHANGELOG.md rename to {{cookiecutter.directory_name}}/CHANGELOG.md diff --git a/{{cookiecutter.project_name}}/CITATION.cff b/{{cookiecutter.directory_name}}/CITATION.cff similarity index 100% rename from {{cookiecutter.project_name}}/CITATION.cff rename to {{cookiecutter.directory_name}}/CITATION.cff diff --git a/{{cookiecutter.project_name}}/CODE_OF_CONDUCT.md b/{{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md similarity index 100% rename from {{cookiecutter.project_name}}/CODE_OF_CONDUCT.md rename to {{cookiecutter.directory_name}}/CODE_OF_CONDUCT.md diff --git a/{{cookiecutter.project_name}}/CONTRIBUTING.md b/{{cookiecutter.directory_name}}/CONTRIBUTING.md similarity index 100% rename from {{cookiecutter.project_name}}/CONTRIBUTING.md rename to {{cookiecutter.directory_name}}/CONTRIBUTING.md diff --git a/{{cookiecutter.project_name}}/LICENSE b/{{cookiecutter.directory_name}}/LICENSE similarity index 100% rename from {{cookiecutter.project_name}}/LICENSE rename to {{cookiecutter.directory_name}}/LICENSE diff --git a/{{cookiecutter.project_name}}/MANIFEST.in b/{{cookiecutter.directory_name}}/MANIFEST.in similarity index 100% rename from {{cookiecutter.project_name}}/MANIFEST.in rename to {{cookiecutter.directory_name}}/MANIFEST.in diff --git a/{{cookiecutter.project_name}}/NOTICE b/{{cookiecutter.directory_name}}/NOTICE similarity index 100% rename from {{cookiecutter.project_name}}/NOTICE rename to {{cookiecutter.directory_name}}/NOTICE diff --git a/{{cookiecutter.project_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md similarity index 100% rename from {{cookiecutter.project_name}}/README.dev.md rename to {{cookiecutter.directory_name}}/README.dev.md diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.directory_name}}/README.md similarity index 100% rename from {{cookiecutter.project_name}}/README.md rename to {{cookiecutter.directory_name}}/README.md diff --git a/{{cookiecutter.project_name}}/docs/Makefile b/{{cookiecutter.directory_name}}/docs/Makefile similarity index 100% rename from {{cookiecutter.project_name}}/docs/Makefile rename to {{cookiecutter.directory_name}}/docs/Makefile diff --git a/{{cookiecutter.project_name}}/docs/_static/theme_overrides.css b/{{cookiecutter.directory_name}}/docs/_static/theme_overrides.css similarity index 100% rename from {{cookiecutter.project_name}}/docs/_static/theme_overrides.css rename to {{cookiecutter.directory_name}}/docs/_static/theme_overrides.css diff --git a/{{cookiecutter.project_name}}/docs/_templates/.gitignore b/{{cookiecutter.directory_name}}/docs/_templates/.gitignore similarity index 100% rename from {{cookiecutter.project_name}}/docs/_templates/.gitignore rename to {{cookiecutter.directory_name}}/docs/_templates/.gitignore diff --git a/{{cookiecutter.project_name}}/docs/conf.py b/{{cookiecutter.directory_name}}/docs/conf.py similarity index 100% rename from {{cookiecutter.project_name}}/docs/conf.py rename to {{cookiecutter.directory_name}}/docs/conf.py diff --git a/{{cookiecutter.project_name}}/docs/index.rst b/{{cookiecutter.directory_name}}/docs/index.rst similarity index 100% rename from {{cookiecutter.project_name}}/docs/index.rst rename to {{cookiecutter.directory_name}}/docs/index.rst diff --git a/{{cookiecutter.project_name}}/docs/make.bat b/{{cookiecutter.directory_name}}/docs/make.bat similarity index 100% rename from {{cookiecutter.project_name}}/docs/make.bat rename to {{cookiecutter.directory_name}}/docs/make.bat diff --git a/{{cookiecutter.project_name}}/next_steps.md b/{{cookiecutter.directory_name}}/next_steps.md similarity index 100% rename from {{cookiecutter.project_name}}/next_steps.md rename to {{cookiecutter.directory_name}}/next_steps.md diff --git a/{{cookiecutter.project_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md similarity index 100% rename from {{cookiecutter.project_name}}/project_setup.md rename to {{cookiecutter.directory_name}}/project_setup.md diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml similarity index 100% rename from {{cookiecutter.project_name}}/pyproject.toml rename to {{cookiecutter.directory_name}}/pyproject.toml diff --git a/{{cookiecutter.project_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg similarity index 100% rename from {{cookiecutter.project_name}}/setup.cfg rename to {{cookiecutter.directory_name}}/setup.cfg diff --git a/{{cookiecutter.project_name}}/setup.py b/{{cookiecutter.directory_name}}/setup.py similarity index 100% rename from {{cookiecutter.project_name}}/setup.py rename to {{cookiecutter.directory_name}}/setup.py diff --git a/{{cookiecutter.project_name}}/sonar-project.properties b/{{cookiecutter.directory_name}}/sonar-project.properties similarity index 100% rename from {{cookiecutter.project_name}}/sonar-project.properties rename to {{cookiecutter.directory_name}}/sonar-project.properties diff --git a/{{cookiecutter.project_name}}/tests/__init__.py b/{{cookiecutter.directory_name}}/tests/__init__.py similarity index 100% rename from {{cookiecutter.project_name}}/tests/__init__.py rename to {{cookiecutter.directory_name}}/tests/__init__.py diff --git a/{{cookiecutter.project_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py similarity index 100% rename from {{cookiecutter.project_name}}/tests/test_my_module.py rename to {{cookiecutter.directory_name}}/tests/test_my_module.py diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py similarity index 100% rename from {{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py rename to {{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__version__.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__version__.py similarity index 100% rename from {{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__version__.py rename to {{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__version__.py diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py similarity index 100% rename from {{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py rename to {{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py From 664e5c12bfd7b1ee8d16163633c0935936628521 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 18:46:54 +0200 Subject: [PATCH 015/144] fix sonarcloud link --- .../.github/next_steps/01_sonarcloud_integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md b/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md index 16e9db2c..01885e68 100644 --- a/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md +++ b/{{cookiecutter.project_name}}/.github/next_steps/01_sonarcloud_integration.md @@ -4,7 +4,7 @@ title: 'Next step: Sonarcloud integration' Continuous code quality can be handled by [Sonarcloud](https://sonarcloud.io/). This repository is configured to use Sonarcloud to perform quality analysis and code coverage report on each push. -In order to configure Sonarcloud analysis [GitHub Action workflow](.github/workflows/sonarcloud.yml) you must follow the steps below: +In order to configure Sonarcloud analysis [GitHub Action workflow]({{cookiecutter.repository}}/blob/main/.github/workflows/sonarcloud.yml) you must follow the steps below: 1. go to [Sonarcloud](https://sonarcloud.io/projects/create) to create a new Sonarcloud project 1. login with your GitHub account From 04dd76979e8f2ad0d395e9f55b73ed619ad58b62 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:23:28 +0200 Subject: [PATCH 016/144] Mave __version__ to __init__.py Solves lint error --- {{cookiecutter.directory_name}}/.bumpversion.cfg | 2 +- .../{{cookiecutter.package_name}}/__init__.py | 2 +- .../{{cookiecutter.package_name}}/__version__.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 {{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__version__.py diff --git a/{{cookiecutter.directory_name}}/.bumpversion.cfg b/{{cookiecutter.directory_name}}/.bumpversion.cfg index bb9563d4..5cd6327c 100644 --- a/{{cookiecutter.directory_name}}/.bumpversion.cfg +++ b/{{cookiecutter.directory_name}}/.bumpversion.cfg @@ -4,7 +4,7 @@ current_version = {{ cookiecutter.version }} [comment] comment = The contents of this file cannot be merged with that of setup.cfg until https://github.com/c4urself/bump2version/issues/185 is resolved -[bumpversion:file:{{ cookiecutter.package_name }}/__version__.py] +[bumpversion:file:{{ cookiecutter.package_name }}/__init__.py] search = __version__ = "{current_version}" replace = __version__ = "{new_version}" diff --git a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py index 418484ea..939ed008 100644 --- a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py +++ b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py @@ -1,9 +1,9 @@ """Documentation about {{ cookiecutter.package_name }}""" import logging -from .__version__ import __version__ logging.getLogger(__name__).addHandler(logging.NullHandler()) __author__ = "{{ cookiecutter.full_name }}" __email__ = "{{ cookiecutter.email }}" +__version__ = "{{ cookiecutter.version }}" diff --git a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__version__.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__version__.py deleted file mode 100644 index a955058c..00000000 --- a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__version__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "{{ cookiecutter.version }}" From 501bef528bd2b39fb40c275c08d6c1e38bbe4121 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:24:09 +0200 Subject: [PATCH 017/144] Removed `.pylintrc` file, was too strict, too soon --- {{cookiecutter.directory_name}}/.pylintrc | 597 ---------------------- 1 file changed, 597 deletions(-) delete mode 100644 {{cookiecutter.directory_name}}/.pylintrc diff --git a/{{cookiecutter.directory_name}}/.pylintrc b/{{cookiecutter.directory_name}}/.pylintrc deleted file mode 100644 index 659dd6e6..00000000 --- a/{{cookiecutter.directory_name}}/.pylintrc +++ /dev/null @@ -1,597 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code. -extension-pkg-whitelist= - -# Specify a score threshold to be exceeded before program exits with error. -fail-under=10 - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. -jobs=1 - -# Control the amount of potential inferred values when inferring a single -# object. This can help the performance when dealing with large functions or -# complex, nested conditions. -limit-inference-results=100 - -# List of plugins (as comma separated values of python module names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=apply-builtin, - backtick, - bad-inline-option, - bad-python3-import, - basestring-builtin, - buffer-builtin, - cmp-builtin, - cmp-method, - coerce-builtin, - coerce-method, - comprehension-escape, - delslice-method, - deprecated-itertools-function, - deprecated-operator-function, - deprecated-pragma, - deprecated-str-translate-call, - deprecated-string-function, - deprecated-sys-function, - deprecated-types-field, - deprecated-urllib-function, - dict-items-not-iterating, - dict-iter-method, - dict-keys-not-iterating, - dict-values-not-iterating, - dict-view-method, - div-method, - duplicate-code, - empty-docstring, - eq-without-hash, - exception-escape, - exception-message-attribute, - execfile-builtin, - file-builtin, - file-ignored, - filter-builtin-not-iterating, - getslice-method, - hex-method, - idiv-method, - import-star-module-level, - indexing-exception, - input-builtin, - intern-builtin, - invalid-str-codec, - locally-disabled, - long-builtin, - long-suffix, - map-builtin-not-iterating, - metaclass-assignment, - missing-module-docstring, - next-method-called, - next-method-defined, - no-absolute-import, - non-ascii-bytes-literal, - nonzero-method, - oct-method, - old-division, - old-ne-operator, - old-octal-literal, - old-raise-syntax, - parameter-unpacking, - print-statement, - raising-string, - range-builtin-not-iterating, - raw_input-builtin, - raw-checker-failed, - rdiv-method, - reduce-builtin, - reload-builtin, - round-builtin, - setslice-method, - standarderror-builtin, - suppressed-message, - sys-max-int, - unichr-builtin, - unicode-builtin, - unpacking-in-except, - unsubscriptable-object, - use-symbolic-message-instead, - useless-suppression, - using-cmp-argument, - xrange-builtin, - xreadlines-attribute, - zip-builtin-not-iterating - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member - - -[REPORTS] - -# Python expression which should return a score less than or equal to 10. You -# have access to the variables 'error', 'warning', 'refactor', and 'convention' -# which contain the number of messages in each category, as well as 'statement' -# which is the total number of statements analyzed. This score is used by the -# global evaluation report (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages. -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit - - -[BASIC] - -# Naming style matching correct argument names. -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style. -#argument-rgx= - -# Naming style matching correct attribute names. -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. -#attr-rgx= - -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Bad variable names regexes, separated by a comma. If names match any regex, -# they will always be refused -bad-names-rgxs= - -# Naming style matching correct class attribute names. -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. -#class-attribute-rgx= - -# Naming style matching correct class names. -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming- -# style. -#class-rgx= - -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style. -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names. -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style. -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - ex, - Run, - _ - -# Good variable names regexes, separated by a comma. If names match any regex, -# they will always be accepted -good-names-rgxs= - -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=no - -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. -#inlinevar-rgx= - -# Naming style matching correct method names. -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style. -#method-rgx= - -# Naming style matching correct module names. -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style. -#module-rgx= - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names. -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style. -#variable-rgx= - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains the private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to the private dictionary (see the -# --spelling-private-dict-file option) instead of raising a message. -spelling-store-unknown-words=no - - -[STRING] - -# This flag controls whether inconsistent-quotes generates a warning when the -# character used as a quote delimiter is used inconsistently within a module. -check-quote-consistency=yes - -# This flag controls whether the implicit-str-concat should generate a warning -# on implicit string concatenation in sequences defined over several lines. -check-str-concat-over-line-jumps=yes - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid defining new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expected to -# not be used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore. -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=yes - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[LOGGING] - -# The type of string formatting that logging methods do. `old` means using % -# formatting, `new` is for `{}` formatting. -logging-format-style=old - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - -# Regular expression of note tags to take in consideration. -#notes-rgx= - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis). It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - -# List of decorators that change the signature of a decorated function. -signature-mutators= - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=120 - -# Maximum number of lines in a module. -max-module-lines=1000 - -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma, - dict-separator - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[IMPORTS] - -# List of modules that can be imported at any level, not just the top level -# one. -allow-any-import-level= - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma. -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled). -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled). -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled). -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - -# Couples of modules and preferred modules, separated by a comma. -preferred-modules= - - -[DESIGN] - -# Maximum number of arguments for function / method. -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in an if statement (see R0916). -max-bool-expr=5 - -# Maximum number of branch for function / method body. -max-branches=12 - -# Maximum number of locals for function / method body. -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body. -max-returns=6 - -# Maximum number of statements in function / method body. -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp, - __post_init__ - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=cls - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception From fc5af0158fa54504e47d19d34bd49c98d95555b3 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:24:39 +0200 Subject: [PATCH 018/144] Added docstring --- .../{{cookiecutter.package_name}}/my_module.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py index 4ad555d4..c6435357 100644 --- a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py +++ b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py @@ -3,4 +3,14 @@ # FIXME: put actual code here def hello(name): + """Say hello + + Example docstring using Google docstring format. + + Args: + name (str): Name to say hello to + + Returns: + str: Hello message + """ return f'Hello {name}!' From d361f0afac1ebf5b3eff2d574140c21ff41ccb01 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:25:06 +0200 Subject: [PATCH 019/144] Remove unused import --- tests/test_values.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_values.py b/tests/test_values.py index d4b07ff2..01d748a9 100644 --- a/tests/test_values.py +++ b/tests/test_values.py @@ -1,6 +1,3 @@ -import pytest - - def test_double_quotes_in_name_and_description(cookies): ctx = { "project_short_description": '"double quotes"', From 15278228e94e3fe8b38ad855191011c215d8b6f5 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:26:04 +0200 Subject: [PATCH 020/144] Run prospector before sonarcloud analysis --- .../.github/workflows/sonarcloud.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index 1fde7d64..c24743eb 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -25,6 +25,8 @@ jobs: python3 --version - name: Install dependencies run: python3 -m pip install .[dev] + - name: Check style against standards using prospector + run: prospector --zero-exit --output-format grouped --output-format pylint:pylint-report.txt - name: Run unit tests with coverage run: pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/ - name: Correct coverage paths From fbac64ffca1553bbc5f8047ac3e9d9594c92d678 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:26:31 +0200 Subject: [PATCH 021/144] Added instructions how to build docs without make --- {{cookiecutter.directory_name}}/README.dev.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 61cf613d..285c9965 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -65,7 +65,13 @@ cd docs make html ``` -The documentation will be in `docs/_build/` +The documentation will be in `docs/_build/html` + +If you do not have `make` use + +```shell +sphinx-build -b html docs docs/_build/html +``` ## Versioning From 598ad36898cdaa6570b7d2c67225d13dddf8e22a Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:27:16 +0200 Subject: [PATCH 022/144] Remove test examples Goto pytest docs for examples. Only test own code --- .../tests/test_my_module.py | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/{{cookiecutter.directory_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py index 76922037..e8e9f81d 100644 --- a/{{cookiecutter.directory_name}}/tests/test_my_module.py +++ b/{{cookiecutter.directory_name}}/tests/test_my_module.py @@ -1,30 +1,7 @@ -#!/usr/bin/env python - """Tests for the {{ cookiecutter.package_name }}.my_module module. """ -import pytest from {{ cookiecutter.package_name }} import my_module def test_hello(): assert my_module.hello('nlesc') == 'Hello nlesc!' - - -def test_something(): - assert True - - -def test_with_error(): - with pytest.raises(ValueError): - # Do something that raises a ValueError - raise(ValueError) - - -# Fixture example -@pytest.fixture -def an_object(): - return {} - - -def test_my_module(an_object): - assert an_object == {} From 3a98f3dc06debcdf15e8d66c2da6f49deeaa3e8e Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:28:29 +0200 Subject: [PATCH 023/144] Remove statements in project_setup.md already mentioned in README.dev.md --- {{cookiecutter.directory_name}}/project_setup.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 1977902e..fd155197 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -43,8 +43,7 @@ help you decide which tool to use for packaging. - Example tests that you should replace with your own meaningful tests (file: `test_my_module.py`) - The testing framework used is [PyTest](https://pytest.org) - [PyTest introduction](http://pythontesting.net/framework/pytest/pytest-introduction/) - - PyTest is listed as a development dependency, and can thus be installed with `pip3 install --editable .[dev]` -- Tests can be run with `pytest` + - PyTest is listed as a development dependency - This is configured in `setup.cfg` - The project uses [GitHub action workflows](https://docs.github.com/en/actions) to automatically run tests on GitHub infrastructure against multiple Python versions - Workflows can be found in [`.github/workflows`](.github/workflows/) @@ -62,9 +61,6 @@ help you decide which tool to use for packaging. ## Coding style conventions and code quality -- Check your code style with `prospector` -- You may need run `pip install --editable .[dev]` first, to install the required dependencies -- You can use `yapf` to fix the readability of your code style and `isort` to format and group your imports - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=coding-style-conventions) ## Continuous code quality @@ -78,8 +74,6 @@ help you decide which tool to use for packaging. - We recommend using [semantic versioning](https://guide.esciencecenter.nl/#/best_practices/releases?id=semantic-versioning). - For convenience, the package version is stored in a single place: `{{ cookiecutter.directory_name }}/.bumpversion.cfg`. - For updating the version number, make sure the dev dependencies are installed and run `bumpversion patch`, - `bumpversion minor`, or `bumpversion major` as appropriate. - Don't forget to update the version number before [making a release](https://guide.esciencecenter.nl/#/best_practices/releases)! ## Logging From 20ed7225fef0198701cff214415d31b817fe2e5f Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:29:17 +0200 Subject: [PATCH 024/144] Remove unused development dependencies --- {{cookiecutter.directory_name}}/setup.cfg | 5 ----- 1 file changed, 5 deletions(-) diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg index d957df47..911007f0 100644 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ b/{{cookiecutter.directory_name}}/setup.cfg @@ -49,16 +49,11 @@ install_requires = dev = bump2version prospector[with_pyroma] - yapf isort pytest pytest-cov - pycodestyle - docutils - pytest-runner sphinx sphinx_rtd_theme - recommonmark publishing = twine wheel From e4b962f1cb08a54f5d48c903ba19d2078bce3255 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:29:33 +0200 Subject: [PATCH 025/144] Enforce isort configuration --- {{cookiecutter.directory_name}}/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg index 911007f0..477b3d4e 100644 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ b/{{cookiecutter.directory_name}}/setup.cfg @@ -65,7 +65,7 @@ include = {{ cookiecutter.package_name }}, {{ cookiecutter.package_name }}.* branch = True source = {{ cookiecutter.package_name }} -[tool:isort] +[isort] lines_after_imports = 2 force_single_line = 1 no_lines_before = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER From 96d3aafb1e29bc9e95301e1f4d781b05ad8a2d36 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:31:07 +0200 Subject: [PATCH 026/144] Added tests for linting and verion bumping --- tests/test_project.py | 50 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 53f8cc8c..c2781e42 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -34,6 +34,7 @@ def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProces @pytest.fixture def baked_with_development_dependencies(cookies): result = cookies.bake() + assert result.exit_code == 0 if IS_WINDOWS_CI: # Creating virtualenv does not work on Windows CI, # falling back to using current pip3 dir @@ -52,9 +53,9 @@ def baked_with_development_dependencies(cookies): def test_pytest(baked_with_development_dependencies): project_dir, bin_dir = baked_with_development_dependencies - pytest_output = run([f'{bin_dir}pytest'], project_dir) - assert pytest_output.returncode == 0 - assert '== 4 passed in' in pytest_output.stdout + result = run([f'{bin_dir}pytest'], project_dir) + assert result.returncode == 0 + assert '== 1 passed in' in result.stdout assert (project_dir / 'coverage.xml').exists() assert (project_dir / 'htmlcov/index.html').exists() @@ -72,8 +73,8 @@ def test_subpackage(baked_with_development_dependencies): if IS_WINDOWS_CI: # On Windows CI python and pip executable are in different paths bin_dir = '' - build_output = run([f'{bin_dir}python', 'setup.py', 'build'], project_dir) - assert build_output.returncode == 0 + result = run([f'{bin_dir}python', 'setup.py', 'build'], project_dir) + assert result.returncode == 0 assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / '__init__.py').exists() assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / 'mysub2' / '__init__.py').exists() @@ -81,7 +82,40 @@ def test_subpackage(baked_with_development_dependencies): def test_generate_api_docs(baked_with_development_dependencies): project_dir, bin_dir = baked_with_development_dependencies - build_output = run([f'{bin_dir}sphinx-build', '-b', 'html', 'docs', 'docs/_build/html'], project_dir) - assert build_output.returncode == 0 - assert 'build succeeded' in build_output.stdout + result = run([f'{bin_dir}sphinx-build', '-b', 'html', 'docs', 'docs/_build/html'], project_dir) + assert result.returncode == 0 + assert 'build succeeded' in result.stdout assert (project_dir / 'docs' / '_build' / 'html' / 'index.html').exists() + + +def test_prospector(baked_with_development_dependencies): + project_dir, bin_dir = baked_with_development_dependencies + + result = run([f'{bin_dir}prospector'], project_dir) + assert result.returncode == 0 + assert 'Messages Found: 0' in result.stdout + + +def test_isort_check(baked_with_development_dependencies): + project_dir, bin_dir = baked_with_development_dependencies + + result = run([f'{bin_dir}isort', '--recursive', '--check-only', 'my_python_package'], project_dir) + assert result.returncode == 0 + assert '' in result.stdout + + +def test_bumpversion(baked_with_development_dependencies): + project_dir, bin_dir = baked_with_development_dependencies + + original_version = '0.1.0' + assert original_version in (project_dir / 'setup.cfg').read_text('utf-8') + assert original_version in (project_dir / 'CITATION.cff').read_text('utf-8') + assert original_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8') + + result = run([f'{bin_dir}bumpversion', 'major'], project_dir) + assert result.returncode == 0 + assert '' in result.stdout + expected_version = '1.0.0' + assert expected_version in (project_dir / 'setup.cfg').read_text('utf-8') + assert expected_version in (project_dir / 'CITATION.cff').read_text('utf-8') + assert expected_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8') From f4e81eea79859ef27654724f7b32ad46d6699ac1 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:31:48 +0200 Subject: [PATCH 027/144] Consolidated test/lint/build into single matrix workflow Render workflows with escaped {{ --- cookiecutter.json | 3 +- .../.github/next_steps/05_linting.md | 2 +- .../.github/workflows/build.yml | 22 +++++++------ .../.github/workflows/lint.yml | 32 ------------------- .../.github/workflows/next_steps.yml | 20 ++++++------ .../.github/workflows/sonarcloud.yml | 4 +-- {{cookiecutter.directory_name}}/README.md | 3 +- 7 files changed, 28 insertions(+), 58 deletions(-) delete mode 100644 {{cookiecutter.directory_name}}/.github/workflows/lint.yml diff --git a/cookiecutter.json b/cookiecutter.json index ac197b6c..f45d92cb 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,8 +1,7 @@ { "directory_name": "my-python-project", "package_name": "my_python_package", - "_copy_without_render": [".github/workflows/*"], - "package_short_description": "", + "package_short_description": "Short description of package", "keyword1": "keyword1", "keyword2": "keyword2", "version": "0.1.0", diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md index 385fee66..e2b32c24 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md @@ -2,7 +2,7 @@ title: 'Next step: Linting' --- -Your repository has a [workflow]({{ cookiecutter.repository }}/blob/main/.github/workflows/lint.yml) which [lints](https://en.wikipedia.org/wiki/Lint_(software)) your code after every push and when creating a pull request. +Your repository has a [workflow]({{ cookiecutter.repository }}/blob/main/.github/workflows/build.yml) which [lints](https://en.wikipedia.org/wiki/Lint_(software)) your code after every push and when creating a pull request. Linter workflow may fail if `description` or `keywords` field in [setup.cfg]({{ cookiecutter.repository }}/blob/main/setup.cfg) is empty. Please update these fields. To validate your changes run: diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 3fdc9ebc..0a04be50 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -1,12 +1,12 @@ -name: build +name: Python package on: [push, pull_request] jobs: build: - name: Build for (${{ matrix.python-version }}, ${{ matrix.os }}) - runs-on: ${{ matrix.os }} + name: Build for (${{ '{{ ' -}} matrix.python-version }}, ${{ '{{ ' -}} matrix.os }}) + runs-on: ${{ '{{ ' -}} matrix.os }} strategy: fail-fast: false matrix: @@ -14,10 +14,10 @@ jobs: python-version: ['3.6', '3.7', '3.8', '3.9'] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python ${{ '{{ ' -}} matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ '{{ ' -}} matrix.python-version }} - name: Python info shell: bash -l {0} run: | @@ -26,8 +26,12 @@ jobs: - name: Upgrade pip and install dependencies run: | python3 -m pip install --upgrade pip setuptools - python3 -m pip install .[publishing] + python3 -m pip install .[dev,publishing] + - name: Check style against standards using prospector + run: prospector + - name: Check import order + run: isort --recursive --check-only {{ cookiecutter.package_name }} + - name: Run unit tests + run: pytest -v - name: Verify that we can build the package - shell: bash -l {0} - run: | - python3 setup.py sdist bdist_wheel + run: python3 setup.py sdist bdist_wheel diff --git a/{{cookiecutter.directory_name}}/.github/workflows/lint.yml b/{{cookiecutter.directory_name}}/.github/workflows/lint.yml deleted file mode 100644 index ab502e86..00000000 --- a/{{cookiecutter.directory_name}}/.github/workflows/lint.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: lint - -on: [push, pull_request] - -jobs: - - lint: - name: Lint for (${{ matrix.python-version }}, ${{ matrix.os }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.6', '3.7', '3.8', '3.9'] - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Python info - shell: bash -l {0} - run: | - which python3 - python3 --version - - name: Install package and its dependencies - run: | - python3 -m pip install --upgrade pip setuptools - python3 -m pip install .[dev] - - name: Check style against standards using prospector - shell: bash -l {0} - run: prospector --zero-exit --output-format grouped --output-format pylint:pylint-report.txt diff --git a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml index fbf0877b..02b9afb0 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml @@ -8,7 +8,7 @@ jobs: - name: Create Sonarcloud integration issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/01_sonarcloud_integration.md id: sonarcloud @@ -16,39 +16,39 @@ jobs: - name: Create citation data issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/02_citation.md id: citation - name: Create readthedocs issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/03_readthedocs.md id: readthedocs - name: Create Zenodo integration issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/04_zenodo_integration.md id: zenodo - name: Create linting issue uses: JasonEtco/create-an-issue@v2 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ '{{ ' -}} secrets.GITHUB_TOKEN }} with: filename: .github/next_steps/05_linting.md id: linting - name: List created issues run: | echo 'Created issues that must be completed to have fully working Python package: - * Sonarcloud integration ${{ steps.sonarcloud.outputs.url }} - * Zenodo integration ${{ steps.zenodo.outputs.url }} - * Read the Docs instructions ${{ steps.readthedocs.outputs.url }} - * Citation data ${{ steps.citation.outputs.url }} - * Linting fixes ${{ steps.linting.outputs.url }}' + * Sonarcloud integration ${{ '{{ ' -}} steps.sonarcloud.outputs.url }} + * Zenodo integration ${{ '{{ ' -}} steps.zenodo.outputs.url }} + * Read the Docs instructions ${{ '{{ ' -}} steps.readthedocs.outputs.url }} + * Citation data ${{ '{{ ' -}} steps.citation.outputs.url }} + * Linting fixes ${{ '{{ ' -}} steps.linting.outputs.url }}' - name: Cleanup files needed to create next steps issues run: | git config --global user.name 'NLeSC Python template' diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index c24743eb..61ca173d 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -34,5 +34,5 @@ jobs: - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ '{{' -}} secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ '{{' -}} secrets.SONAR_TOKEN }} diff --git a/{{cookiecutter.directory_name}}/README.md b/{{cookiecutter.directory_name}}/README.md index e86e4bae..c8dcc396 100644 --- a/{{cookiecutter.directory_name}}/README.md +++ b/{{cookiecutter.directory_name}}/README.md @@ -16,8 +16,7 @@ | Documentation | [![Documentation Status](https://readthedocs.org/projects/{{cookiecutter.directory_name}}/badge/?version=latest)](https://{{cookiecutter.directory_name}}.readthedocs.io/en/latest/?badge=latest) | | **GitHub Actions** |   | | Build | [![build]({{cookiecutter.repository}}/actions/workflows/build.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/build.yml) | -| Metadata consistency | [![cffconvert]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) | -| Lint | [![lint]({{cookiecutter.repository}}/actions/workflows/lint.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/lint.yml) | +| Citation consistency | [![cffconvert]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) | | SonarCloud | [![sonarcloud]({{cookiecutter.repository}}/actions/workflows/sonarcloud.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/sonarcloud.yml) | | MarkDown link checker | [![markdown-link-check]({{cookiecutter.repository}}/actions/workflows/markdown-link-check.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/markdown-link-check.yml) | From 047a5180f122a7aff4c132a29ca3fc29706d63ec Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:33:19 +0200 Subject: [PATCH 028/144] updated changelog --- CHANGELOG.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed2a8cf..72ecacc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,32 @@ ## Unreleased +### Added + +* Tests for linting and version bumping +* Docstring for function + +### Changed + +* Renamed `project_name` to `directory_name` in cookiecutter questionnaire +* Initial linting is error free +* Consolidated test/lint/build into single matrix workflow +* Enforce isort configuration +* Default for `package_short_description` in cookiecutter questionnaire + +### Removed + +* `.pylintrc` file, was too strict, too soon +* Unused development dependencies +* Statements in project_setup.md already mentioned in README.dev.md +* Removed example tests for pytest + ## 0.4.0 ### Added * Instructions to add your existing code to directory generated by the NLeSC Python template [#202](https://github.com/NLeSC/python-template/issues/202) -* Keywords to questionaire [#270](https://github.com/NLeSC/python-template/issues/270) +* Keywords to questionnaire [#270](https://github.com/NLeSC/python-template/issues/270) * Next step issue generation workflow [#228](https://github.com/NLeSC/python-template/issues/228) * Next step issue for SonarCloud integration [#234](https://github.com/NLeSC/python-template/issues/234) * Next step issue for Zenodo integration [#235](https://github.com/NLeSC/python-template/issues/235) From 85e80cd7b52a8e4810f68d8369b256c8da1d0c33 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 07:55:21 +0200 Subject: [PATCH 029/144] Linkup CHANGELOG --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ecacc1..fbc32df9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,15 +10,15 @@ ### Changed * Renamed `project_name` to `directory_name` in cookiecutter questionnaire -* Initial linting is error free -* Consolidated test/lint/build into single matrix workflow +* Initial linting is error free [#227](https://github.com/NLeSC/python-template/issues/227) +* Consolidated test/lint/build into single matrix workflow [@270](https://github.com/NLeSC/python-template/issues/276) * Enforce isort configuration * Default for `package_short_description` in cookiecutter questionnaire ### Removed * `.pylintrc` file, was too strict, too soon -* Unused development dependencies +* Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md * Removed example tests for pytest From bab5abad5e141be553061b887d03185c4877c0ba Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 08:06:31 +0200 Subject: [PATCH 030/144] Show package_short_description default in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f5ead10..7d2d70a7 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ cookiecutter https://github.com/nlesc/python-template.git | ------------------------- | ------------- | ----------- | | directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. To get an impression of what will be generated, see the directory tree [below](https://github.com/NLeSC/python-template#step-33-read-about-what-was-just-generated) | | package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. | -| package_short_description |   | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. | +| package_short_description | Short description of package | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. | | keyword1 | keyword1 | A term that describes your package. | | keyword2 | keyword2 | Another term that describes your package. | | version | 0.1.0 |   | From 30412f7d59deac148a2e32e9f279af6e4cc97f6a Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 08:31:09 +0200 Subject: [PATCH 031/144] Typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc32df9..766d2369 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ * Renamed `project_name` to `directory_name` in cookiecutter questionnaire * Initial linting is error free [#227](https://github.com/NLeSC/python-template/issues/227) -* Consolidated test/lint/build into single matrix workflow [@270](https://github.com/NLeSC/python-template/issues/276) +* Consolidated test/lint/build into single matrix workflow [#270](https://github.com/NLeSC/python-template/issues/276) * Enforce isort configuration * Default for `package_short_description` in cookiecutter questionnaire From 914b9a24c91bdb64aa5718f6120a7f6046ba81a3 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 08:54:41 +0200 Subject: [PATCH 032/144] Add link to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 766d2369..7787b4f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ ### Removed -* `.pylintrc` file, was too strict, too soon +* `.pylintrc` file, was too strict, too soon [#267](https://github.com/NLeSC/python-template/issues/267) * Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md * Removed example tests for pytest From 3614930f8acc3c473dfab1eed3ef70400b7f972c Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 09:17:44 +0200 Subject: [PATCH 033/144] Double remove --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7787b4f3..cd8bb973 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ * `.pylintrc` file, was too strict, too soon [#267](https://github.com/NLeSC/python-template/issues/267) * Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md -* Removed example tests for pytest +* Example tests to explain pytest ## 0.4.0 From 8c0fd9dc121595840e83f666f1cb25d3281217f8 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 09:30:00 +0200 Subject: [PATCH 034/144] Ignore link checks of GH settings page and test pypi --- {{cookiecutter.directory_name}}/.mlc-config.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/{{cookiecutter.directory_name}}/.mlc-config.json b/{{cookiecutter.directory_name}}/.mlc-config.json index 54d24dcb..80d0d1aa 100644 --- a/{{cookiecutter.directory_name}}/.mlc-config.json +++ b/{{cookiecutter.directory_name}}/.mlc-config.json @@ -7,6 +7,12 @@ { "pattern": "^https://doi.org/" }, + { + "pattern": "/settings/secrets/actions$" + }, + { + "pattern": "^https://test.pypi.org" + }, { "pattern": "^https://bestpractices.coreinfrastructure.org/projects/" } From cec26fd55b218635564beeaafa49886f00c4093e Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 09:31:19 +0200 Subject: [PATCH 035/144] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd8bb973..685c7539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Consolidated test/lint/build into single matrix workflow [#270](https://github.com/NLeSC/python-template/issues/276) * Enforce isort configuration * Default for `package_short_description` in cookiecutter questionnaire +* Link checker ignores GH settings page and test pypi site ### Removed From 7b4e96cedd5df891a2d56c0234b16c1476d254c2 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 09:41:57 +0200 Subject: [PATCH 036/144] Link checker ignores GH private pages --- CHANGELOG.md | 2 +- {{cookiecutter.directory_name}}/.mlc-config.json | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 685c7539..a8887f37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ * Consolidated test/lint/build into single matrix workflow [#270](https://github.com/NLeSC/python-template/issues/276) * Enforce isort configuration * Default for `package_short_description` in cookiecutter questionnaire -* Link checker ignores GH settings page and test pypi site +* Link checker ignores GH private pages and test pypi site [#288](https://github.com/NLeSC/python-template/issues/288) ### Removed diff --git a/{{cookiecutter.directory_name}}/.mlc-config.json b/{{cookiecutter.directory_name}}/.mlc-config.json index 80d0d1aa..214dad70 100644 --- a/{{cookiecutter.directory_name}}/.mlc-config.json +++ b/{{cookiecutter.directory_name}}/.mlc-config.json @@ -10,6 +10,9 @@ { "pattern": "/settings/secrets/actions$" }, + { + "pattern": "^https://github.com/organizations/.*/repositories/new" + }, { "pattern": "^https://test.pypi.org" }, From 374b294f4aabb4ea5aa73a2c142e5d733e030dde Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 10:17:05 +0200 Subject: [PATCH 037/144] Another issue fixed --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8887f37..4057f6b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * Enforce isort configuration * Default for `package_short_description` in cookiecutter questionnaire * Link checker ignores GH private pages and test pypi site [#288](https://github.com/NLeSC/python-template/issues/288) +* In CI build workflow make prospector die if there are errors [#275](https://github.com/NLeSC/python-template/issues/275) ### Removed From 2b4a31ed9fc7606e9246a58ea45d4e22c9bae00a Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 11:09:25 +0200 Subject: [PATCH 038/144] pytest.raises error --- CHANGELOG.md | 2 +- tests/test_project.py | 2 +- {{cookiecutter.directory_name}}/tests/test_my_module.py | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4057f6b1..f145c20e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,13 +16,13 @@ * Default for `package_short_description` in cookiecutter questionnaire * Link checker ignores GH private pages and test pypi site [#288](https://github.com/NLeSC/python-template/issues/288) * In CI build workflow make prospector die if there are errors [#275](https://github.com/NLeSC/python-template/issues/275) +* Explain pytest using package code ### Removed * `.pylintrc` file, was too strict, too soon [#267](https://github.com/NLeSC/python-template/issues/267) * Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md -* Example tests to explain pytest ## 0.4.0 diff --git a/tests/test_project.py b/tests/test_project.py index c2781e42..8bab8ef9 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -55,7 +55,7 @@ def test_pytest(baked_with_development_dependencies): project_dir, bin_dir = baked_with_development_dependencies result = run([f'{bin_dir}pytest'], project_dir) assert result.returncode == 0 - assert '== 1 passed in' in result.stdout + assert '== 2 passed in' in result.stdout assert (project_dir / 'coverage.xml').exists() assert (project_dir / 'htmlcov/index.html').exists() diff --git a/{{cookiecutter.directory_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py index e8e9f81d..a6ca650b 100644 --- a/{{cookiecutter.directory_name}}/tests/test_my_module.py +++ b/{{cookiecutter.directory_name}}/tests/test_my_module.py @@ -1,7 +1,14 @@ """Tests for the {{ cookiecutter.package_name }}.my_module module. """ +import pytest + from {{ cookiecutter.package_name }} import my_module def test_hello(): assert my_module.hello('nlesc') == 'Hello nlesc!' + + +def test_hello_without_arguments(): + with pytest.raises(TypeError): + my_module.hello() From a39740321c57a7ff208532859fac9935e8e13909 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Tue, 4 May 2021 11:34:13 +0200 Subject: [PATCH 039/144] Revert "pytest.raises error" This reverts commit 2b4a31ed9fc7606e9246a58ea45d4e22c9bae00a. --- CHANGELOG.md | 2 +- tests/test_project.py | 2 +- {{cookiecutter.directory_name}}/tests/test_my_module.py | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f145c20e..4057f6b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,13 +16,13 @@ * Default for `package_short_description` in cookiecutter questionnaire * Link checker ignores GH private pages and test pypi site [#288](https://github.com/NLeSC/python-template/issues/288) * In CI build workflow make prospector die if there are errors [#275](https://github.com/NLeSC/python-template/issues/275) -* Explain pytest using package code ### Removed * `.pylintrc` file, was too strict, too soon [#267](https://github.com/NLeSC/python-template/issues/267) * Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md +* Example tests to explain pytest ## 0.4.0 diff --git a/tests/test_project.py b/tests/test_project.py index 8bab8ef9..c2781e42 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -55,7 +55,7 @@ def test_pytest(baked_with_development_dependencies): project_dir, bin_dir = baked_with_development_dependencies result = run([f'{bin_dir}pytest'], project_dir) assert result.returncode == 0 - assert '== 2 passed in' in result.stdout + assert '== 1 passed in' in result.stdout assert (project_dir / 'coverage.xml').exists() assert (project_dir / 'htmlcov/index.html').exists() diff --git a/{{cookiecutter.directory_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py index a6ca650b..e8e9f81d 100644 --- a/{{cookiecutter.directory_name}}/tests/test_my_module.py +++ b/{{cookiecutter.directory_name}}/tests/test_my_module.py @@ -1,14 +1,7 @@ """Tests for the {{ cookiecutter.package_name }}.my_module module. """ -import pytest - from {{ cookiecutter.package_name }} import my_module def test_hello(): assert my_module.hello('nlesc') == 'Hello nlesc!' - - -def test_hello_without_arguments(): - with pytest.raises(TypeError): - my_module.hello() From b6452e0c2972641730e517a715d56cd3f7d2c559 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Wed, 5 May 2021 20:56:55 +0200 Subject: [PATCH 040/144] Only use example function in tests --- CHANGELOG.md | 2 +- tests/test_project.py | 2 +- .../tests/test_my_module.py | 17 +++++++++++++++++ .../{{cookiecutter.package_name}}/my_module.py | 8 +++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4057f6b1..ecc097da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,13 +16,13 @@ * Default for `package_short_description` in cookiecutter questionnaire * Link checker ignores GH private pages and test pypi site [#288](https://github.com/NLeSC/python-template/issues/288) * In CI build workflow make prospector die if there are errors [#275](https://github.com/NLeSC/python-template/issues/275) +* All example tests make use of example function ### Removed * `.pylintrc` file, was too strict, too soon [#267](https://github.com/NLeSC/python-template/issues/267) * Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md -* Example tests to explain pytest ## 0.4.0 diff --git a/tests/test_project.py b/tests/test_project.py index c2781e42..9abec498 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -55,7 +55,7 @@ def test_pytest(baked_with_development_dependencies): project_dir, bin_dir = baked_with_development_dependencies result = run([f'{bin_dir}pytest'], project_dir) assert result.returncode == 0 - assert '== 1 passed in' in result.stdout + assert '== 3 passed in' in result.stdout assert (project_dir / 'coverage.xml').exists() assert (project_dir / 'htmlcov/index.html').exists() diff --git a/{{cookiecutter.directory_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py index e8e9f81d..98ab7eff 100644 --- a/{{cookiecutter.directory_name}}/tests/test_my_module.py +++ b/{{cookiecutter.directory_name}}/tests/test_my_module.py @@ -1,7 +1,24 @@ """Tests for the {{ cookiecutter.package_name }}.my_module module. """ +import pytest + from {{ cookiecutter.package_name }} import my_module def test_hello(): assert my_module.hello('nlesc') == 'Hello nlesc!' + + +def test_hello_with_error(): + with pytest.raises(ValueError) as excinfo: + my_module.hello('nobody') + assert str(excinfo.value) == 'Can not say hello to nobody' + + +@pytest.fixture +def some_name(): + return 'Jane Smith' + + +def test_hello_with_fixture(some_name): + assert my_module.hello(some_name) == 'Hello Jane Smith!' diff --git a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py index c6435357..986bdbf5 100644 --- a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py +++ b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py @@ -5,12 +5,18 @@ def hello(name): """Say hello - Example docstring using Google docstring format. + Example docstring using Google docstring style. Args: name (str): Name to say hello to Returns: str: Hello message + + Raises: + ValueError: If `name` is equal to `nobody` + """ + if name == 'nobody': + raise ValueError('Can not say hello to nobody') return f'Hello {name}!' From 29e859b92d50eee587441ded58b63129ecccc2e0 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 6 May 2021 08:25:57 +0200 Subject: [PATCH 041/144] Import function instead of module --- .../tests/test_my_module.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.directory_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py index 98ab7eff..c78f5249 100644 --- a/{{cookiecutter.directory_name}}/tests/test_my_module.py +++ b/{{cookiecutter.directory_name}}/tests/test_my_module.py @@ -2,17 +2,17 @@ """ import pytest -from {{ cookiecutter.package_name }} import my_module +from {{ cookiecutter.package_name }}.my_module import hello def test_hello(): - assert my_module.hello('nlesc') == 'Hello nlesc!' + assert hello('nlesc') == 'Hello nlesc!' def test_hello_with_error(): with pytest.raises(ValueError) as excinfo: - my_module.hello('nobody') - assert str(excinfo.value) == 'Can not say hello to nobody' + hello('nobody') + assert 'Can not say hello to nobody' in str(excinfo.value) @pytest.fixture @@ -21,4 +21,4 @@ def some_name(): def test_hello_with_fixture(some_name): - assert my_module.hello(some_name) == 'Hello Jane Smith!' + assert hello(some_name) == 'Hello Jane Smith!' From e48587b361d83e506672268a516d088cbf6cf471 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 6 May 2021 08:46:29 +0200 Subject: [PATCH 042/144] Add example usage in docstring --- .../{{cookiecutter.package_name}}/my_module.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py index 986bdbf5..be0172d9 100644 --- a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py +++ b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py @@ -5,7 +5,7 @@ def hello(name): """Say hello - Example docstring using Google docstring style. + Function docstring using Google docstring style. Args: name (str): Name to say hello to @@ -16,6 +16,13 @@ def hello(name): Raises: ValueError: If `name` is equal to `nobody` + Example: + This function can be called with `Jane Smith` as argument using + + >>> from {{ cookiecutter.package_name }}.my_module import hello + >>> hello('Jane Smith') + 'Hello Jane Smith!' + """ if name == 'nobody': raise ValueError('Can not say hello to nobody') From 46dc16078a58cbdc8ab4e587515de2a11901c3bb Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 6 May 2021 08:48:37 +0200 Subject: [PATCH 043/144] Prep for Sphinx AutoAPI usage --- {{cookiecutter.directory_name}}/.gitignore | 1 - {{cookiecutter.directory_name}}/docs/index.rst | 16 ++++------------ {{cookiecutter.directory_name}}/project_setup.md | 1 + {{cookiecutter.directory_name}}/setup.cfg | 1 + 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.gitignore b/{{cookiecutter.directory_name}}/.gitignore index deeb37d8..22a58eb1 100644 --- a/{{cookiecutter.directory_name}}/.gitignore +++ b/{{cookiecutter.directory_name}}/.gitignore @@ -14,7 +14,6 @@ coverage.xml .pytest_cache docs/_build -docs/apidocs # ide .idea diff --git a/{{cookiecutter.directory_name}}/docs/index.rst b/{{cookiecutter.directory_name}}/docs/index.rst index d8ef571c..d4af697b 100644 --- a/{{cookiecutter.directory_name}}/docs/index.rst +++ b/{{cookiecutter.directory_name}}/docs/index.rst @@ -1,7 +1,7 @@ -.. {{ cookiecutter.package_name }} documentation main file, created by - sphinx-quickstart on Thu Jun 21 11:07:11 2018. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +.. {{ cookiecutter.package_name }} documentation master file, created by + sphinx-quickstart on Wed May 5 22:45:36 2021. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. Welcome to {{ cookiecutter.package_name }}'s documentation! ========================================================== @@ -10,14 +10,6 @@ Welcome to {{ cookiecutter.package_name }}'s documentation! :maxdepth: 2 :caption: Contents: -API Reference -============= - -.. toctree:: - :maxdepth: 2 - - {{ cookiecutter.package_name }} - Indices and tables ================== diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index fd155197..19b5768a 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -57,6 +57,7 @@ help you decide which tool to use for packaging. - [Google style docstring examples](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html). - The documentation is set up with the ReadTheDocs Sphinx theme. - Check out its [configuration options](https://sphinx-rtd-theme.readthedocs.io/en/latest/). +- [AutoAPI](https://sphinx-autoapi.readthedocs.io/) is used to generate documentation for the package Python objects. - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=writingdocumentation) ## Coding style conventions and code quality diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg index 477b3d4e..ad06d7ae 100644 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ b/{{cookiecutter.directory_name}}/setup.cfg @@ -54,6 +54,7 @@ dev = pytest-cov sphinx sphinx_rtd_theme + sphinx-autoapi publishing = twine wheel From ea72de2f17e9393c1d9e5ffae90c9f8258e1c99b Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 6 May 2021 08:49:40 +0200 Subject: [PATCH 044/144] Regenerated docs/conf.py Also * Use bumpversion for version in Sphinx config * Enable Sphinx built-in extensions * use Sphinx AutoAPI --- CHANGELOG.md | 9 +- tests/test_project.py | 79 +++++-- .../.bumpversion.cfg | 4 + .../.github/workflows/build.yml | 3 + {{cookiecutter.directory_name}}/README.dev.md | 27 ++- {{cookiecutter.directory_name}}/docs/conf.py | 201 ++++-------------- 6 files changed, 136 insertions(+), 187 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecc097da..592c0f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,19 +4,24 @@ ### Added -* Tests for linting and version bumping +* Template unit tests for documentation generation, linting and version bumping * Docstring for function +* Intersphinx to documentation +* Coverage and doctest commands for documentation ### Changed * Renamed `project_name` to `directory_name` in cookiecutter questionnaire * Initial linting is error free [#227](https://github.com/NLeSC/python-template/issues/227) -* Consolidated test/lint/build into single matrix workflow [#270](https://github.com/NLeSC/python-template/issues/276) +* Consolidated test/lint/build/docs into single matrix workflow [#270](https://github.com/NLeSC/python-template/issues/276) * Enforce isort configuration * Default for `package_short_description` in cookiecutter questionnaire * Link checker ignores GH private pages and test pypi site [#288](https://github.com/NLeSC/python-template/issues/288) * In CI build workflow make prospector die if there are errors [#275](https://github.com/NLeSC/python-template/issues/275) * All example tests make use of example function +* Use bumpversion for version in Sphinx config +* Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions +* Generate api rst files with 3rd party extension instead of custom function ### Removed diff --git a/tests/test_project.py b/tests/test_project.py index 9abec498..8ccaf6df 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -7,7 +7,7 @@ import pytest -IS_WINDOWS = platform.startswith("win") +IS_WINDOWS = platform.startswith('win') IS_WINDOWS_CI = IS_WINDOWS and os.environ.get('CI', False) @@ -25,43 +25,53 @@ def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProces stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=dirpath, - encoding="utf-8") + encoding='utf-8') print(completed_process.stdout) print(completed_process.stderr) return completed_process @pytest.fixture -def baked_with_development_dependencies(cookies): - result = cookies.bake() - assert result.exit_code == 0 +def project_env_bin_dir(tmp_path): if IS_WINDOWS_CI: # Creating virtualenv does not work on Windows CI, # falling back to using current pip3 dir pip = Path(which('pip3')) - bin_dir = str(pip.parent) + '\\' + bin_dir = pip.parent else: - env_output = run(['python3', '-m', 'venv', 'env'], result.project) + env_output = run(['python3', '-m', 'venv', 'env'], tmp_path) assert env_output.returncode == 0 - bin_dir = 'env/Scripts/' if IS_WINDOWS else 'env/bin/' + bin_dir = str(tmp_path / 'env' / 'bin') + if IS_WINDOWS: + bin_dir = str(tmp_path / 'env' / 'Scripts') + return str(bin_dir) + os.sep + + +@pytest.fixture +def baked_with_development_dependencies(cookies, project_env_bin_dir): + result = cookies.bake() + assert result.exit_code == 0 + bin_dir = project_env_bin_dir latest_pip_output = run([f'{bin_dir}pip3', 'install', '--upgrade', 'pip', 'setuptools'], result.project) assert latest_pip_output.returncode == 0 pip_output = run([f'{bin_dir}pip3', 'install', '--editable', '.[dev]'], result.project) assert pip_output.returncode == 0 - return result.project, bin_dir + return result.project -def test_pytest(baked_with_development_dependencies): - project_dir, bin_dir = baked_with_development_dependencies +def test_pytest(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir result = run([f'{bin_dir}pytest'], project_dir) assert result.returncode == 0 assert '== 3 passed in' in result.stdout assert (project_dir / 'coverage.xml').exists() - assert (project_dir / 'htmlcov/index.html').exists() + assert (project_dir / 'htmlcov' / 'index.html').exists() -def test_subpackage(baked_with_development_dependencies): - project_dir, bin_dir = baked_with_development_dependencies +def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir subpackage = (project_dir / 'my_python_package' / 'mysub') subpackage.mkdir() (subpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8") @@ -79,8 +89,9 @@ def test_subpackage(baked_with_development_dependencies): assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / 'mysub2' / '__init__.py').exists() -def test_generate_api_docs(baked_with_development_dependencies): - project_dir, bin_dir = baked_with_development_dependencies +def test_generate_api_docs(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir result = run([f'{bin_dir}sphinx-build', '-b', 'html', 'docs', 'docs/_build/html'], project_dir) assert result.returncode == 0 @@ -88,15 +99,38 @@ def test_generate_api_docs(baked_with_development_dependencies): assert (project_dir / 'docs' / '_build' / 'html' / 'index.html').exists() -def test_prospector(baked_with_development_dependencies): - project_dir, bin_dir = baked_with_development_dependencies +def test_coverage_api_docs(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir + + result = run([f'{bin_dir}sphinx-build', '-b', 'coverage', 'docs', 'docs/_build/coverage'], project_dir) + assert result.returncode == 0 + assert 'build succeeded' in result.stdout + coverage_file = project_dir / 'docs' / '_build' / 'coverage' / 'python.txt' + lines = coverage_file.readlines() + assert len(lines) == 2 + + +def test_doctest_api_docs(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir + + result = run([f'{bin_dir}sphinx-build', '-b', 'doctest', 'docs', 'docs/_build/doctest'], project_dir) + assert result.returncode == 0 + assert 'build succeeded' in result.stdout + assert (project_dir / 'docs' / '_build' / 'doctest' / 'output.txt').exists() + + +def test_prospector(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir result = run([f'{bin_dir}prospector'], project_dir) assert result.returncode == 0 assert 'Messages Found: 0' in result.stdout -def test_isort_check(baked_with_development_dependencies): +def test_isort_check(baked_with_development_dependencies, project_env_bin_dir): project_dir, bin_dir = baked_with_development_dependencies result = run([f'{bin_dir}isort', '--recursive', '--check-only', 'my_python_package'], project_dir) @@ -104,13 +138,15 @@ def test_isort_check(baked_with_development_dependencies): assert '' in result.stdout -def test_bumpversion(baked_with_development_dependencies): - project_dir, bin_dir = baked_with_development_dependencies +def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir original_version = '0.1.0' assert original_version in (project_dir / 'setup.cfg').read_text('utf-8') assert original_version in (project_dir / 'CITATION.cff').read_text('utf-8') assert original_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8') + assert original_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8') result = run([f'{bin_dir}bumpversion', 'major'], project_dir) assert result.returncode == 0 @@ -119,3 +155,4 @@ def test_bumpversion(baked_with_development_dependencies): assert expected_version in (project_dir / 'setup.cfg').read_text('utf-8') assert expected_version in (project_dir / 'CITATION.cff').read_text('utf-8') assert expected_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8') + assert expected_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8') diff --git a/{{cookiecutter.directory_name}}/.bumpversion.cfg b/{{cookiecutter.directory_name}}/.bumpversion.cfg index 5cd6327c..16899b5e 100644 --- a/{{cookiecutter.directory_name}}/.bumpversion.cfg +++ b/{{cookiecutter.directory_name}}/.bumpversion.cfg @@ -15,3 +15,7 @@ replace = version = {new_version} [bumpversion:file:CITATION.cff] search = version: "{current_version}" replace = version: "{new_version}" + +[bumpversion:file:docs/conf.py] +search = version = "{current_version}" +replace = version = "{new_version}" diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 0a04be50..ff8b80bf 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -35,3 +35,6 @@ jobs: run: pytest -v - name: Verify that we can build the package run: python3 setup.py sdist bdist_wheel + - name: Build documentation + run: make coverage doctest html + working-directory: docs diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 285c9965..40aa89b7 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -73,9 +73,24 @@ If you do not have `make` use sphinx-build -b html docs docs/_build/html ``` +To find undocumented Python objects run + +```shell +cd docs +make coverage +cat _build/coverage/python.txt +``` + +To [test snippets](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) in documentation run + +```shell +cd docs +make doctest +``` + ## Versioning -Bumping the version across all files is done with bumpversion, e.g. +Bumping the version across all files is done with [bumpversion](https://github.com/c4urself/bump2version), e.g. ```shell bumpversion major @@ -93,10 +108,10 @@ This section describes how to make a release in 3 parts: ### (1/3) Preparation -1. Update the `CHANGELOG.md` -2. Verify that the information in `CITATION.cff` is correct, and that `.zenodo.json` contains equivalent data -3. Make sure the version has been updated. -4. Run the unit tests with `pytest tests/` +1. Update the (don't forget to update links at bottom of page) +2. Verify that the information in `CITATION.cff` is correct, and that `.zenodo.json` contains equivalent data +3. Make sure the [version has been updated](#versioning). +4. Run the unit tests with `pytest -v` ### (2/3) PyPI @@ -165,4 +180,4 @@ twine upload dist/* ### (3/3) GitHub -Don't forget to also make a release on GitHub. If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it. +Don't forget to also make a [release on GitHub]({{cookiecutter.repository}}/releases/new). If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it. diff --git a/{{cookiecutter.directory_name}}/docs/conf.py b/{{cookiecutter.directory_name}}/docs/conf.py index d18ab35e..959ec776 100644 --- a/{{cookiecutter.directory_name}}/docs/conf.py +++ b/{{cookiecutter.directory_name}}/docs/conf.py @@ -1,52 +1,22 @@ -# {{ cookiecutter.package_name }} documentation build configuration file, created by -# sphinx-quickstart on {% now "local", "%a %b %d %H:%M:%S %Y" %}. +# Configuration file for the Sphinx documentation builder. # -# This file is execfile()d with the current directory set to its -# containing dir. +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html # -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. + +# -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import os -import sys - -here = os.path.dirname(__file__) -sys.path.insert(0, os.path.abspath(os.path.join(here, ".."))) - -import {{ cookiecutter.package_name }} +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) +# -- Project information ----------------------------------------------------- -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = "1.0" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named "sphinx.ext.*") or your custom -# ones. -extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = [".rst", ".md"] -source_suffix = ".rst" - -# The main toctree document. -main_doc = "index" - -# General information about the project. project = u"{{ cookiecutter.package_name }}" copyright = u"{% now "local", "%Y" %}, {{ cookiecutter.copyright_holder }}" author = u"{{ cookiecutter.full_name.replace('\"', '\\\"') }}" @@ -56,59 +26,41 @@ # built documents. # # The short X.Y version. -version = {{ cookiecutter.package_name }}.__version__ +version = "0.1.0" # The full version, including alpha/beta/rc tags. -release = {{ cookiecutter.package_name }}.__version__ +release = version -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None +# -- General configuration ------------------------------------------------ + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named "sphinx.ext.*") or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.coverage", + "sphinx.ext.doctest", + "sphinx.ext.intersphinx", + "sphinx.ext.mathjax", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", + "autoapi.extension", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False -# -- Run apidoc plug-in manually, as readthedocs doesn't support it ------- -# See https://github.com/rtfd/readthedocs.org/issues/1139 -def run_apidoc(_): - here = os.path.dirname(__file__) - out = os.path.abspath(os.path.join(here, "apidocs")) - src = os.path.abspath(os.path.join(here, "..", "{{ cookiecutter.package_name }}")) - - ignore_paths = [] - - argv = [ - "-f", - "-T", - "-e", - "-M", - "-o", out, - src - ] + ignore_paths - - try: - # Sphinx 1.7+ - from sphinx.ext import apidoc - apidoc.main(argv) - except ImportError: - # Sphinx 1.6 (and earlier) - from sphinx import apidoc - argv.insert(0, apidoc.__file__) - apidoc.main(argv) - - -def setup(app): - app.connect("builder-inited", run_apidoc) +# -- Use autoapi.extension to run sphinx-apidoc ------- + +autoapi_dirs = ['../{{ cookiecutter.package_name }}'] # -- Options for HTML output ---------------------------------------------- @@ -123,80 +75,13 @@ def setup(app): # # html_theme_options = {} -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] -html_context = { - "css_files": [ - "_static/theme_overrides.css" # override wide tables in RTD theme - ] -} - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# This is required for the alabaster theme -# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars -html_sidebars = { - "**": [ - "relations.html", # needs "show_related": True theme option to display - "searchbox.html" - ] -} - - -# -- Options for HTMLHelp output ------------------------------------------ - -# Output file base name for HTML help builder. -htmlhelp_basename = "{{ cookiecutter.package_name }}_doc" - - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ("letterpaper" or "a4paper"). - # - # "papersize": "letterpaper", +# -- Options for Intersphinx - # The font size ("10pt", "11pt" or "12pt"). - # - # "pointsize": "10pt", - - # Additional stuff for the LaTeX preamble. - # - # "preamble": "", - - # Latex figure (float) alignment - # - # "figure_align": "htbp", -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (main_doc, "{{ cookiecutter.package_name }}.tex", u"{{ cookiecutter.package_name }} Documentation", - u"{{ cookiecutter.full_name }}", "manual") -] - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (main_doc, "{{ cookiecutter.package_name }}", u"{{ cookiecutter.package_name }} Documentation", [author], 1) -] - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (main_doc, "{{ cookiecutter.package_name }}", u"{{ cookiecutter.package_name }} Documentation", - author, "{{ cookiecutter.package_name }}", "{{ cookiecutter.package_short_description }}", - "Miscellaneous") -] +intersphinx_mapping = {'python': ('https://docs.python.org/3', None), + # Commonly used libraries, uncomment when used in package + # 'numpy': ('http://docs.scipy.org/doc/numpy/', None), + # 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None), + # 'scikit-learn': ('https://scikit-learn.org/stable/', None), + # 'matplotlib': ('https://matplotlib.org/stable/', None), + # 'pandas': ('http://pandas.pydata.org/docs/', None), + } From faec90f26417c10b5a06b1f9422acc477d362b89 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 6 May 2021 09:04:07 +0200 Subject: [PATCH 045/144] Fix remnant --- tests/test_project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_project.py b/tests/test_project.py index 8ccaf6df..38fff80d 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -131,7 +131,8 @@ def test_prospector(baked_with_development_dependencies, project_env_bin_dir): def test_isort_check(baked_with_development_dependencies, project_env_bin_dir): - project_dir, bin_dir = baked_with_development_dependencies + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir result = run([f'{bin_dir}isort', '--recursive', '--check-only', 'my_python_package'], project_dir) assert result.returncode == 0 From 4815b82f5a3ca7e0d092ead77ff44f2358848abb Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 6 May 2021 09:04:15 +0200 Subject: [PATCH 046/144] Add issue urls to CHANGELOG --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 592c0f72..b5d2b48e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ * Template unit tests for documentation generation, linting and version bumping * Docstring for function * Intersphinx to documentation -* Coverage and doctest commands for documentation +* Coverage and doctest commands for documentation [#97](https://github.com/NLeSC/python-template/issues/97) ### Changed @@ -19,9 +19,9 @@ * Link checker ignores GH private pages and test pypi site [#288](https://github.com/NLeSC/python-template/issues/288) * In CI build workflow make prospector die if there are errors [#275](https://github.com/NLeSC/python-template/issues/275) * All example tests make use of example function -* Use bumpversion for version in Sphinx config -* Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions -* Generate api rst files with 3rd party extension instead of custom function +* Use bumpversion for version in Sphinx config [#44](https://github.com/NLeSC/python-template/issues/44) +* Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions [#44](https://github.com/NLeSC/python-template/issues/44) +* Generate api rst files with 3rd party extension instead of custom function [#95](https://github.com/NLeSC/python-template/issues/95) ### Removed From e4081dd6bc63ffec4f1daa96d7ad1fd4e9505e4b Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 6 May 2021 12:47:03 +0200 Subject: [PATCH 047/144] Need RTD config to render API docs with AutoAPI --- CHANGELOG.md | 8 ++++---- {{cookiecutter.directory_name}}/.readthedocs.yaml | 7 +++++++ {{cookiecutter.directory_name}}/project_setup.md | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 {{cookiecutter.directory_name}}/.readthedocs.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d2b48e..dacde367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ * All example tests make use of example function * Use bumpversion for version in Sphinx config [#44](https://github.com/NLeSC/python-template/issues/44) * Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions [#44](https://github.com/NLeSC/python-template/issues/44) -* Generate api rst files with 3rd party extension instead of custom function [#95](https://github.com/NLeSC/python-template/issues/95) +* Generate api rst files with extension instead of custom function [#95](https://github.com/NLeSC/python-template/issues/95) ### Removed @@ -36,7 +36,7 @@ * Instructions to add your existing code to directory generated by the NLeSC Python template [#202](https://github.com/NLeSC/python-template/issues/202) * Keywords to questionnaire [#270](https://github.com/NLeSC/python-template/issues/270) * Next step issue generation workflow [#228](https://github.com/NLeSC/python-template/issues/228) -* Next step issue for SonarCloud integration [#234](https://github.com/NLeSC/python-template/issues/234) +* Next step issue for SonarCloud integration [#234](https://github.com/NLeSC/python-template/issues/234) * Next step issue for Zenodo integration [#235](https://github.com/NLeSC/python-template/issues/235) * Next step issue for Read the Docs [#236](https://github.com/NLeSC/python-template/issues/236) * Next step issue for citation data [#237](https://github.com/NLeSC/python-template/issues/237) @@ -47,7 +47,7 @@ * CI Tests on Windows [#140](https://github.com/NLeSC/python-template/issues/140) [#223](https://github.com/NLeSC/python-template/issues/223) * `.pylintrc` file * Valid license name and first author name in `CITATION.cff` -* SonarCloud integration for code quality and coverage [#89](https://github.com/NLeSC/python-template/issues/89) +* SonarCloud integration for code quality and coverage [#89](https://github.com/NLeSC/python-template/issues/89) * Read the Docs [#78](https://github.com/NLeSC/python-template/issues/78) ### Changed @@ -94,7 +94,7 @@ * Dropped appveyor [#160](https://github.com/NLeSC/python-template/issues/160) * Dropped everything Conda related * Drop Python 3.5 support -* Removed unit tests doing the linting +* Removed unit tests doing the linting ## 0.2.0 diff --git a/{{cookiecutter.directory_name}}/.readthedocs.yaml b/{{cookiecutter.directory_name}}/.readthedocs.yaml new file mode 100644 index 00000000..544d704c --- /dev/null +++ b/{{cookiecutter.directory_name}}/.readthedocs.yaml @@ -0,0 +1,7 @@ +version: 2 +python: + install: + - method: pip + path: . + extra_requirements: + - dev diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 19b5768a..872f4994 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -58,6 +58,7 @@ help you decide which tool to use for packaging. - The documentation is set up with the ReadTheDocs Sphinx theme. - Check out its [configuration options](https://sphinx-rtd-theme.readthedocs.io/en/latest/). - [AutoAPI](https://sphinx-autoapi.readthedocs.io/) is used to generate documentation for the package Python objects. +- `.readthedocs.yaml` is the ReadTheDocs configuration file. When ReadTheDocs is building the documentation this package and its development dependencies are installed so the API reference can be rendered. - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=writingdocumentation) ## Coding style conventions and code quality From cf3d4bf3510c5c1632829046383e046b09ddbcce Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 11:19:28 +0200 Subject: [PATCH 048/144] Compare docs coverage with expected value --- tests/test_project.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 38fff80d..fcb95ddf 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -107,8 +107,10 @@ def test_coverage_api_docs(baked_with_development_dependencies, project_env_bin_ assert result.returncode == 0 assert 'build succeeded' in result.stdout coverage_file = project_dir / 'docs' / '_build' / 'coverage' / 'python.txt' - lines = coverage_file.readlines() - assert len(lines) == 2 + coverage_file_lines = coverage_file.read_text('utf8').splitlines() + expected = ['Undocumented Python objects', + '==========================='] + assert coverage_file_lines == expected def test_doctest_api_docs(baked_with_development_dependencies, project_env_bin_dir): From 3318139c2fb035f1241aa0c809f7da7745a923b0 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 11:24:14 +0200 Subject: [PATCH 049/144] Explain why build is used --- tests/test_project.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_project.py b/tests/test_project.py index fcb95ddf..34642647 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -70,6 +70,7 @@ def test_pytest(baked_with_development_dependencies, project_env_bin_dir): def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): + """Test if subpackages end up in sdist and bdist_wheel distributions""" project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir subpackage = (project_dir / 'my_python_package' / 'mysub') @@ -83,6 +84,8 @@ def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): if IS_WINDOWS_CI: # On Windows CI python and pip executable are in different paths bin_dir = '' + # sdist and bdist_wheel both call build command to create build/ dir + # So instead of looking in distribution archives we can look in build/ dir result = run([f'{bin_dir}python', 'setup.py', 'build'], project_dir) assert result.returncode == 0 assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / '__init__.py').exists() From 7b76c0f3b2c993e197c629a1e032d7b9e8a6e51b Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 11:51:45 +0200 Subject: [PATCH 050/144] Update {{cookiecutter.directory_name}}/README.md Co-authored-by: Faruk D. --- {{cookiecutter.directory_name}}/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/README.md b/{{cookiecutter.directory_name}}/README.md index c8dcc396..d95a2313 100644 --- a/{{cookiecutter.directory_name}}/README.md +++ b/{{cookiecutter.directory_name}}/README.md @@ -16,7 +16,7 @@ | Documentation | [![Documentation Status](https://readthedocs.org/projects/{{cookiecutter.directory_name}}/badge/?version=latest)](https://{{cookiecutter.directory_name}}.readthedocs.io/en/latest/?badge=latest) | | **GitHub Actions** |   | | Build | [![build]({{cookiecutter.repository}}/actions/workflows/build.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/build.yml) | -| Citation consistency | [![cffconvert]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) | +| Citation data consistency | [![cffconvert]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) | | SonarCloud | [![sonarcloud]({{cookiecutter.repository}}/actions/workflows/sonarcloud.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/sonarcloud.yml) | | MarkDown link checker | [![markdown-link-check]({{cookiecutter.repository}}/actions/workflows/markdown-link-check.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/markdown-link-check.yml) | From 7ade52050809eedc7ffe633dd18be799b78e9369 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 11:59:34 +0200 Subject: [PATCH 051/144] Link to README.dev.md from next_steps --- {{cookiecutter.directory_name}}/next_steps.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/{{cookiecutter.directory_name}}/next_steps.md b/{{cookiecutter.directory_name}}/next_steps.md index 66e38c6a..bfff064b 100644 --- a/{{cookiecutter.directory_name}}/next_steps.md +++ b/{{cookiecutter.directory_name}}/next_steps.md @@ -31,6 +31,10 @@ A short while after you push your commits to GitHub for the first time, a few is automatically ([here]({{cookiecutter.repository}}/issues?q=author%3Aapp%2Fgithub-actions)). Resolve them to complete the setup of your repository. +## Project development documentation + +The contains developer documentation. + ## Project layout explained For an explanation of what files are there, and what each of these do, please refer to [project_setup.md](project_setup.md). From 46824d82dcf48831c43194edbaa6c01f95cfbf0c Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 12:01:52 +0200 Subject: [PATCH 052/144] Use link syntax --- {{cookiecutter.directory_name}}/next_steps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/next_steps.md b/{{cookiecutter.directory_name}}/next_steps.md index bfff064b..4858fbbe 100644 --- a/{{cookiecutter.directory_name}}/next_steps.md +++ b/{{cookiecutter.directory_name}}/next_steps.md @@ -33,7 +33,7 @@ setup of your repository. ## Project development documentation -The contains developer documentation. +The [README.dev.md](README.dev.md) contains developer documentation. ## Project layout explained From 18f58f1877c6afc2d88452b276f0db321764b86f Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 12:05:03 +0200 Subject: [PATCH 053/144] Add yapf --- {{cookiecutter.directory_name}}/README.dev.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 40aa89b7..5bbea3ef 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -52,6 +52,8 @@ isort --recursive --check-only --diff {{ cookiecutter.package_name }} isort --recursive {{ cookiecutter.package_name }} ``` +To fix readability of your code style you can use [yapf](https://github.com/google/yapf). + You can enable automatic linting with `prospector` and `isort` on commit by enabling the git hook from `.githooks/pre-commit`, like so: ```shell From 8a88d1fd12862f5b98a79c8037ce98e9e42a8a34 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 12:07:27 +0200 Subject: [PATCH 054/144] Update {{cookiecutter.directory_name}}/project_setup.md Co-authored-by: Faruk D. --- {{cookiecutter.directory_name}}/project_setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 872f4994..858cac23 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -63,7 +63,7 @@ help you decide which tool to use for packaging. ## Coding style conventions and code quality -- [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=coding-style-conventions) +- [Relevant section in the NLeSC guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=coding-style-conventions) and [README.dev.md](README.dev.md). ## Continuous code quality From 69c08113aab8f959c718bd80c2f122e35d3db72c Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 12:17:58 +0200 Subject: [PATCH 055/144] Update {{cookiecutter.directory_name}}/.mlc-config.json Co-authored-by: Faruk D. --- {{cookiecutter.directory_name}}/.mlc-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.mlc-config.json b/{{cookiecutter.directory_name}}/.mlc-config.json index 214dad70..414b693f 100644 --- a/{{cookiecutter.directory_name}}/.mlc-config.json +++ b/{{cookiecutter.directory_name}}/.mlc-config.json @@ -8,7 +8,7 @@ "pattern": "^https://doi.org/" }, { - "pattern": "/settings/secrets/actions$" + "pattern": "^https://github.com/.*/settings/secrets/actions$" }, { "pattern": "^https://github.com/organizations/.*/repositories/new" From bfa11c8bd1a8455e11b726e9a2c46614aceb445e Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Fri, 7 May 2021 12:35:17 +0200 Subject: [PATCH 056/144] No more theme override --- .../docs/_static/theme_overrides.css | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 {{cookiecutter.directory_name}}/docs/_static/theme_overrides.css diff --git a/{{cookiecutter.directory_name}}/docs/_static/theme_overrides.css b/{{cookiecutter.directory_name}}/docs/_static/theme_overrides.css deleted file mode 100644 index 8194805c..00000000 --- a/{{cookiecutter.directory_name}}/docs/_static/theme_overrides.css +++ /dev/null @@ -1,12 +0,0 @@ -/* override table width restrictions */ -@media screen and (min-width: 767px) { - .wy-table-responsive table td { - /* !important prevents the common CSS stylesheets from overriding - this as on RTD they are loaded after this stylesheet */ - white-space: normal !important; - } - - .wy-table-responsive { - overflow: visible !important; - } -} From e22b7cfde3719f98b9ab95be43d30f4ce8ce00f6 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Thu, 7 Oct 2021 15:43:23 +0200 Subject: [PATCH 057/144] remove double CI build triggers --- .../.github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index ff8b80bf..aea85388 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -1,6 +1,12 @@ name: Python package -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: From 4fb2d01e49f87f036eb81f012b51d0f00bb0e8a8 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Thu, 7 Oct 2021 15:47:45 +0200 Subject: [PATCH 058/144] Update cffconvert.yml --- .../.github/workflows/cffconvert.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml index 0d2ac633..76603f3d 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml @@ -1,6 +1,12 @@ name: cffconvert -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: From 40784b648a1dca6ddfca9f1e481302730905a801 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Thu, 7 Oct 2021 15:47:59 +0200 Subject: [PATCH 059/144] Update markdown-link-check.yml --- .../.github/workflows/markdown-link-check.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml index 0afe69eb..2377c4c6 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml @@ -1,6 +1,12 @@ name: markdown-link-check -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: From d0f3fb4501dfb3ad32d42e6c278f4cf22585310b Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Thu, 7 Oct 2021 15:48:39 +0200 Subject: [PATCH 060/144] Update sonarcloud.yml --- .../.github/workflows/sonarcloud.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index 61ca173d..f9d37b55 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -2,8 +2,12 @@ name: sonarcloud on: push: + branches: + - main pull_request: types: [opened, synchronize, reopened] + branches: + - main jobs: From 8fd249ab146545cc7d6ee7019d27ed91148ceee5 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Thu, 7 Oct 2021 15:51:37 +0200 Subject: [PATCH 061/144] Make linting a separate job on CI --- .../.github/workflows/build.yml | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index ff8b80bf..2ff610b2 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -27,10 +27,6 @@ jobs: run: | python3 -m pip install --upgrade pip setuptools python3 -m pip install .[dev,publishing] - - name: Check style against standards using prospector - run: prospector - - name: Check import order - run: isort --recursive --check-only {{ cookiecutter.package_name }} - name: Run unit tests run: pytest -v - name: Verify that we can build the package @@ -38,3 +34,28 @@ jobs: - name: Build documentation run: make coverage doctest html working-directory: docs + + lint: + name: Linting build + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Python info + shell: bash -l {0} + run: | + which python3 + python3 --version + - name: Upgrade pip and install dependencies + run: | + python3 -m pip install --upgrade pip setuptools + python3 -m pip install .[dev,publishing] + - name: Check style against standards using prospector + run: prospector + - name: Check import order + run: isort --recursive --check-only dianna From e6166fdb25d5344d77866f09b57faae453e1ae81 Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 18 Oct 2021 17:15:21 +0200 Subject: [PATCH 062/144] Add readthedocs dashboard/import to markdown-link-check ignores --- .mlc-config.json | 3 +++ {{cookiecutter.directory_name}}/.mlc-config.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.mlc-config.json b/.mlc-config.json index 7b0dfb57..9c07c43a 100644 --- a/.mlc-config.json +++ b/.mlc-config.json @@ -15,6 +15,9 @@ }, { "pattern": "^.github/workflows/sonarcloud.yml$" + }, + { + "pattern": "^https://readthedocs.org/dashboard/import.*" } ], "replacementPatterns": [ diff --git a/{{cookiecutter.directory_name}}/.mlc-config.json b/{{cookiecutter.directory_name}}/.mlc-config.json index 414b693f..bf8a4834 100644 --- a/{{cookiecutter.directory_name}}/.mlc-config.json +++ b/{{cookiecutter.directory_name}}/.mlc-config.json @@ -18,6 +18,9 @@ }, { "pattern": "^https://bestpractices.coreinfrastructure.org/projects/" + }, + { + "pattern": "^https://readthedocs.org/dashboard/import.*" } ], "replacementPatterns": [ From 5c72ce6766d372dcea7fc559c1968cb09559bbb1 Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 18 Oct 2021 17:15:43 +0200 Subject: [PATCH 063/144] Update link to restructured text and sphinx cheatsheet --- {{cookiecutter.directory_name}}/project_setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 858cac23..c99b85ba 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -53,7 +53,7 @@ help you decide which tool to use for packaging. - Documentation should be put in the [`docs/`](docs/) directory. The contents have been generated using `sphinx-quickstart` (Sphinx version 1.6.5). - We recommend writing the documentation using Restructured Text (reST) and Google style docstrings. - - [Restructured Text (reST) and Sphinx CheatSheet](http://openalea.gforge.inria.fr/doc/openalea/doc/_build/html/source/sphinx/rest_syntax.html) + - [Restructured Text (reST) and Sphinx CheatSheet](https://thomas-cokelaer.info/tutorials/sphinx/rest_syntax.html) - [Google style docstring examples](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html). - The documentation is set up with the ReadTheDocs Sphinx theme. - Check out its [configuration options](https://sphinx-rtd-theme.readthedocs.io/en/latest/). From 847aa628c1a412de3dba147740e85d70f04acab1 Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 18 Oct 2021 17:31:27 +0200 Subject: [PATCH 064/144] Add retryOn429: true to markdown-link-check --- .mlc-config.json | 1 + {{cookiecutter.directory_name}}/.mlc-config.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.mlc-config.json b/.mlc-config.json index 9c07c43a..95443f7b 100644 --- a/.mlc-config.json +++ b/.mlc-config.json @@ -22,5 +22,6 @@ ], "replacementPatterns": [ ], + "retryOn429": true, "timeout": "20s" } diff --git a/{{cookiecutter.directory_name}}/.mlc-config.json b/{{cookiecutter.directory_name}}/.mlc-config.json index bf8a4834..1d388679 100644 --- a/{{cookiecutter.directory_name}}/.mlc-config.json +++ b/{{cookiecutter.directory_name}}/.mlc-config.json @@ -25,5 +25,6 @@ ], "replacementPatterns": [ ], + "retryOn429": true, "timeout": "20s" } From 3dfcb6f3a7d75605972f2e56814e83b6d62b2422 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Wed, 15 Dec 2021 12:17:01 +0100 Subject: [PATCH 065/144] Update {{cookiecutter.directory_name}}/.github/workflows/build.yml Co-authored-by: Abel Siqueira --- {{cookiecutter.directory_name}}/.github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 2ff610b2..ebad2266 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -58,4 +58,4 @@ jobs: - name: Check style against standards using prospector run: prospector - name: Check import order - run: isort --recursive --check-only dianna + run: isort --check-only {{ cookiecutter.package_name }} From 5e313eaa35d852806447b0e3e4cce6034f1b720a Mon Sep 17 00:00:00 2001 From: Abel Siqueira Date: Wed, 15 Dec 2021 08:25:23 -0300 Subject: [PATCH 066/144] Create Pull Request template --- .github/PULL_REQUEST_TEMPLATE.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..ee6df26d --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,28 @@ +**Description* + + + + + +**Instructions to review the pull request** + + +Create a `python-template-test` repo on GitHub (will be overwritten if existing) +``` +cd $(mktemp -d --tmpdir py-tmpl-XXXXXX) +cookiecutter -c https://github.com//python-template +# Fill with python-template-test info +cd python-template-test +git init +git add --all +git commit -m "First commit" +git remote add origin https://github.com//python-template-test +git push -u origin main -f +python -m venv env +source env/bin/activate +python -m pip install --upgrade pip setuptools +python -m pip install '.[dev,publishing]' +``` From bfbe1eb57514b55dd927f2298d87e1954d2d3ba2 Mon Sep 17 00:00:00 2001 From: Abel Siqueira Date: Wed, 2 Feb 2022 11:15:34 -0300 Subject: [PATCH 067/144] Update cffconvert.yml --- .github/workflows/cffconvert.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cffconvert.yml b/.github/workflows/cffconvert.yml index 0dba0b1c..707a71c4 100644 --- a/.github/workflows/cffconvert.yml +++ b/.github/workflows/cffconvert.yml @@ -1,15 +1,19 @@ name: cffconvert -on: push +on: + push: + paths: + - CITATION.cff jobs: - - cffconvert: - name: Verify citation metadata consistency + validate: + name: "validate" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - name: Check out a copy of the repository + - name: Check out a copy of the repository + uses: actions/checkout@v2 - - uses: citation-file-format/cffconvert-github-action@main - name: Check whether the citation metadata from CITATION.cff is equivalent to that in .zenodo.json + - name: Check whether the citation metadata from CITATION.cff is valid + uses: citation-file-format/cffconvert-github-action@2.0.0 + with: + args: "--validate" From 45da0a0b27f5eb0987a741c3e3f6781502b7e5a7 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Mon, 21 Feb 2022 12:28:39 +0100 Subject: [PATCH 068/144] add tox + remove coverage from pytest default config By making testing and coverage separate parts of the configuration, VSCode no longer chokes on discovering tests. This should also make test discovery easier in IDEs like PyCharm. The main problem was that coverage was being treated as default part of testing by always passing coverage flags to pytest (this was also noted in a comment in setup.cfg). Moving this to pyproject.toml may have been unnecessary in the end, but the resources I found online suggested this was the way to go. Adding tox provides a solution to #38. --- tests/test_project.py | 9 +++++++++ {{cookiecutter.directory_name}}/pyproject.toml | 18 ++++++++++++++++++ {{cookiecutter.directory_name}}/setup.cfg | 12 ++---------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 34642647..565d9e4d 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -69,6 +69,15 @@ def test_pytest(baked_with_development_dependencies, project_env_bin_dir): assert (project_dir / 'htmlcov' / 'index.html').exists() +def test_tox(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir + result = run([f'{bin_dir}tox'], project_dir) + assert result.returncode == 0 + assert '== 3 passed in' in result.stdout + assert (project_dir / '.tox' / 'dist' / 'my_python_package-0.1.0.zip').exists() + + def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): """Test if subpackages end up in sdist and bdist_wheel distributions""" project_dir = baked_with_development_dependencies diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 9787c3bd..3a71fd27 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -1,3 +1,21 @@ [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.coverage.run] +branch = true +source = ["{{ cookiecutter.package_name }}"] +command_line = "-m pytest" + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py37,py38,py39 +skip_missing_interpreters = true +[testenv] +commands = pytest +extras = dev +""" diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg index ad06d7ae..6572b8ec 100644 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ b/{{cookiecutter.directory_name}}/setup.cfg @@ -48,6 +48,7 @@ install_requires = [options.extras_require] dev = bump2version + coverage [toml] prospector[with_pyroma] isort pytest @@ -55,6 +56,7 @@ dev = sphinx sphinx_rtd_theme sphinx-autoapi + tox publishing = twine wheel @@ -62,10 +64,6 @@ publishing = [options.packages.find] include = {{ cookiecutter.package_name }}, {{ cookiecutter.package_name }}.* -[coverage:run] -branch = True -source = {{ cookiecutter.package_name }} - [isort] lines_after_imports = 2 force_single_line = 1 @@ -73,9 +71,3 @@ no_lines_before = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER known_first_party = {{ cookiecutter.package_name }} src_paths = {{ cookiecutter.package_name }},tests line_length = 120 - -[tool:pytest] -testpaths = tests -# Note that visual debugger in some editors like pycharm gets confused by coverage calculation. -# As a workaround, configure the test configuration in pycharm et al with a --no-cov argument -addopts = --cov --cov-report xml --cov-report term --cov-report html From 5d913c55f7b43520c830d70571377be682327e02 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Tue, 22 Feb 2022 11:20:33 +0100 Subject: [PATCH 069/144] test coverage separately from pytest --- setup.cfg | 1 + tests/test_project.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 1e627666..8a8e9120 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,6 +41,7 @@ install_requires = [options.extras_require] dev = + coverage [toml] pytest<5.0.0,>=3.3.0 pytest-cookies diff --git a/tests/test_project.py b/tests/test_project.py index 565d9e4d..d99e7f23 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -65,8 +65,15 @@ def test_pytest(baked_with_development_dependencies, project_env_bin_dir): result = run([f'{bin_dir}pytest'], project_dir) assert result.returncode == 0 assert '== 3 passed in' in result.stdout - assert (project_dir / 'coverage.xml').exists() - assert (project_dir / 'htmlcov' / 'index.html').exists() + + +def test_coverage(baked_with_development_dependencies, project_env_bin_dir): + project_dir = baked_with_development_dependencies + bin_dir = project_env_bin_dir + result = run([f'{bin_dir}coverage', 'run', '-m', 'pytest'], project_dir) + assert result.returncode == 0 + assert '== 3 passed in' in result.stdout + assert (project_dir / '.coverage').exists() def test_tox(baked_with_development_dependencies, project_env_bin_dir): From a1fbec9ce9262bc1fdd8208f87cffff990006007 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Tue, 22 Feb 2022 11:49:06 +0100 Subject: [PATCH 070/144] update pytest introduction URL --- {{cookiecutter.directory_name}}/project_setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index c99b85ba..4c174883 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -42,7 +42,7 @@ help you decide which tool to use for packaging. - The `tests` folder contains: - Example tests that you should replace with your own meaningful tests (file: `test_my_module.py`) - The testing framework used is [PyTest](https://pytest.org) - - [PyTest introduction](http://pythontesting.net/framework/pytest/pytest-introduction/) + - [PyTest introduction](https://pythontest.com/pytest-book/) - PyTest is listed as a development dependency - This is configured in `setup.cfg` - The project uses [GitHub action workflows](https://docs.github.com/en/actions) to automatically run tests on GitHub infrastructure against multiple Python versions From 6d78d07e069e1c031889aa08c17e93fd70ae3100 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Thu, 24 Feb 2022 14:25:38 +0100 Subject: [PATCH 071/144] document tox and coverage in README.dev.md --- {{cookiecutter.directory_name}}/README.dev.md | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 5bbea3ef..77b17497 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -25,12 +25,41 @@ Afterwards check that the install directory is present in the `PATH` environment ## Running the tests -Running the tests requires an activated virtual environment with the development tools installed. +There are two ways to run tests. + +The first way requires an activated virtual environment with the development tools installed: ```shell pytest -v ``` +The second is to use `tox`, which can be installed separately (e.g. with `pip install tox`), i.e. not necessarily inside the virtual environment you use for installing `{{ cookiecutter.package_name }}`, but then builds the necessary virtual environments itself by simply running: + +```shell +tox +``` + +Testing with `tox` allows for keeping the testing environment separate from your development environment. +The development environment will typically accumulate (old) packages during development that interfere with testing; this problem is avoided by testing with `tox`. + +### Test coverage + +In addition to just running the tests to see if they pass, they can be used for coverage statistics, i.e. to determine how much of the package's code is actually executed during tests. +In an activated virtual environment with the development tools installed, inside the package directory, run: + +```shell +coverage run +``` + +This runs tests and stores the result in a `.coverage` file. +To see the results on the command line, run + +```shell +coverage report +``` + +`coverage` can also generate output in HTML and other formats; see `coverage help` for more information. + ## Running linters locally For linting we will use [prospector](https://pypi.org/project/prospector/) and to sort imports we will use From 897f86da55cf9725e29fe65f06de59141338a7b5 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Wed, 16 Mar 2022 15:40:25 +0100 Subject: [PATCH 072/144] add separate documentation GA workflow --- .../.github/workflows/build.yml | 3 -- .../.github/workflows/documentation.yml | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 {{cookiecutter.directory_name}}/.github/workflows/documentation.yml diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 48612f94..bb0c464f 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -37,9 +37,6 @@ jobs: run: pytest -v - name: Verify that we can build the package run: python3 setup.py sdist bdist_wheel - - name: Build documentation - run: make coverage doctest html - working-directory: docs lint: name: Linting build diff --git a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml new file mode 100644 index 00000000..a9f7b367 --- /dev/null +++ b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml @@ -0,0 +1,36 @@ +name: documentation + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-documentation: + name: Build documentation + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Python info + shell: bash -l {0} + run: | + which python3 + python3 --version + - name: Upgrade pip and install dependencies + run: | + python3 -m pip install --upgrade pip setuptools + python3 -m pip install .[dev,publishing] + - name: Install pandoc using apt + run: sudo apt install pandoc + - name: Build documentation + run: make coverage doctest html + working-directory: docs \ No newline at end of file From a606da6e7ab860e17e91fa74f4544c93757f95dd Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Wed, 16 Mar 2022 15:49:21 +0100 Subject: [PATCH 073/144] =?UTF-8?q?fix=20CI:=20pep8=20/=20pep257=20?= =?UTF-8?q?=E2=86=92=20pycodestyle/pydocstyle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #313. --- {{cookiecutter.directory_name}}/.prospector.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.prospector.yml b/{{cookiecutter.directory_name}}/.prospector.yml index f7902836..a5000487 100644 --- a/{{cookiecutter.directory_name}}/.prospector.yml +++ b/{{cookiecutter.directory_name}}/.prospector.yml @@ -15,10 +15,10 @@ ignore-paths: pyroma: run: true -pep8: +pycodestyle: full: true -pep257: +pydocstyle: disable: [ # Disable because not part of PEP257 official convention: # see http://pep257.readthedocs.io/en/latest/error_codes.html From 19fc9c6bcdd87b8f339af8cb50f2904c2caec2e5 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Wed, 16 Mar 2022 15:55:42 +0100 Subject: [PATCH 074/144] add diff to isort so that the output actually tells you what to do instead of just complaining --- {{cookiecutter.directory_name}}/.github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 48612f94..32257886 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -64,4 +64,4 @@ jobs: - name: Check style against standards using prospector run: prospector - name: Check import order - run: isort --check-only {{ cookiecutter.package_name }} + run: isort --check-only {{ cookiecutter.package_name }} --diff From 1daa189298b1fd7480a7f5d77d3436b0f0b650b3 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Wed, 16 Mar 2022 16:27:30 +0100 Subject: [PATCH 075/144] add myst_parser to allow markdown files in toclist in docs --- {{cookiecutter.directory_name}}/docs/conf.py | 1 + {{cookiecutter.directory_name}}/setup.cfg | 1 + 2 files changed, 2 insertions(+) diff --git a/{{cookiecutter.directory_name}}/docs/conf.py b/{{cookiecutter.directory_name}}/docs/conf.py index 959ec776..e0f32f0b 100644 --- a/{{cookiecutter.directory_name}}/docs/conf.py +++ b/{{cookiecutter.directory_name}}/docs/conf.py @@ -45,6 +45,7 @@ "sphinx.ext.todo", "sphinx.ext.viewcode", "autoapi.extension", + "myst_parser", ] # Add any paths that contain templates here, relative to this directory. diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg index 6572b8ec..2aba8aee 100644 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ b/{{cookiecutter.directory_name}}/setup.cfg @@ -57,6 +57,7 @@ dev = sphinx_rtd_theme sphinx-autoapi tox + myst_parser publishing = twine wheel From 44e850de6a86800179fb8e7cc0690875c06bb771 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Fri, 18 Mar 2022 16:53:06 +0100 Subject: [PATCH 076/144] remove --tmpdir from mktemp in README.dev.md The --tmpdir option is unnecessary in Linux and is unsupported on macOS. --- {{cookiecutter.directory_name}}/README.dev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 77b17497..a72ef3f3 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -150,7 +150,7 @@ In a new terminal, without an activated virtual environment or an env directory: ```shell # prepare a new directory -cd $(mktemp -d --tmpdir {{ cookiecutter.package_name }}.XXXXXX) +cd $(mktemp -d {{ cookiecutter.package_name }}.XXXXXX) # fresh git clone ensures the release has the state of origin/main branch git clone {{ cookiecutter.repository }} . @@ -184,7 +184,7 @@ and verify that your package was uploaded successfully. Keep the terminal open, In a new terminal, without an activated virtual environment or an env directory: ```shell -cd $(mktemp -d --tmpdir {{ cookiecutter.package_name }}-test.XXXXXX) +cd $(mktemp -d {{ cookiecutter.package_name }}-test.XXXXXX) # prepare a clean virtual environment and activate it python3 -m venv env From 530677619e0aec5837dc1e06be86bb53c623f7df Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Sun, 20 Mar 2022 21:24:33 +0100 Subject: [PATCH 077/144] add .tox to .gitignore In #311, I forgot to add the .tox directory to .gitignore. Tox stores environments and logs and such there. --- {{cookiecutter.directory_name}}/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.directory_name}}/.gitignore b/{{cookiecutter.directory_name}}/.gitignore index 22a58eb1..57fb2ab9 100644 --- a/{{cookiecutter.directory_name}}/.gitignore +++ b/{{cookiecutter.directory_name}}/.gitignore @@ -12,6 +12,7 @@ htmlcov .coverage coverage.xml .pytest_cache +.tox docs/_build From bea5e50c620ac8c9415cb17c193f628fe8ecfe2c Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Tue, 29 Mar 2022 15:28:01 +0200 Subject: [PATCH 078/144] update checkout and setup-python github actions to v3 --- .github/workflows/cffconvert.yml | 2 +- .github/workflows/tests.yml | 4 ++-- .../.github/workflows/build.yml | 8 ++++---- .../.github/workflows/cffconvert.yml | 2 +- .../.github/workflows/next_steps.yml | 2 +- .../.github/workflows/sonarcloud.yml | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cffconvert.yml b/.github/workflows/cffconvert.yml index 707a71c4..6851c52d 100644 --- a/.github/workflows/cffconvert.yml +++ b/.github/workflows/cffconvert.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out a copy of the repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check whether the citation metadata from CITATION.cff is valid uses: citation-file-format/cffconvert-github-action@2.0.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d13da9a5..05b451f5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,9 +16,9 @@ jobs: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] python-version: ['3.6', '3.7', '3.8', '3.9'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - name: Python info diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 48612f94..5a831013 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -19,9 +19,9 @@ jobs: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] python-version: ['3.6', '3.7', '3.8', '3.9'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ '{{ ' -}} matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: ${{ '{{ ' -}} matrix.python-version }} - name: Python info @@ -47,9 +47,9 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python 3.9 - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.9 - name: Python info diff --git a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml index 76603f3d..015d9e3e 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml @@ -14,7 +14,7 @@ jobs: name: "cffconvert" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 name: Check out a copy of the repository - uses: citation-file-format/cffconvert-github-action@main diff --git a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml index 02b9afb0..7139327c 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml @@ -4,7 +4,7 @@ jobs: next_steps: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Create Sonarcloud integration issue uses: JasonEtco/create-an-issue@v2 env: diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index f9d37b55..9f7c945c 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -15,11 +15,11 @@ jobs: name: SonarCloud runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.9 - name: Python info From df9365f5bbdd50d9342d8c7216cfa977b7140a50 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Tue, 29 Mar 2022 15:33:17 +0200 Subject: [PATCH 079/144] fix workflow versions to v3 instead of main --- .github/workflows/markdown-link-check.yml | 2 +- .../.github/workflows/markdown-link-check.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml index 0afe69eb..1fe39a3a 100644 --- a/.github/workflows/markdown-link-check.yml +++ b/.github/workflows/markdown-link-check.yml @@ -8,7 +8,7 @@ jobs: name: Check markdown links runs-on: ubuntu-latest steps: - - uses: actions/checkout@main + - uses: actions/checkout@v3 - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: config-file: '.mlc-config.json' diff --git a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml index 2377c4c6..3cdbce01 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml @@ -14,7 +14,7 @@ jobs: name: Check markdown links runs-on: ubuntu-latest steps: - - uses: actions/checkout@main + - uses: actions/checkout@v3 - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: config-file: '.mlc-config.json' From b672a044dcdeef3c32f3a6a3a6a0b6f5ebce04d5 Mon Sep 17 00:00:00 2001 From: Artur Palha Date: Fri, 18 Nov 2022 09:33:44 +0100 Subject: [PATCH 080/144] Fixes authentication confusion Sets the default authentication to ssh. The user is informed of this choice and provides information on how to use other forms of authentication. --- hooks/pre_gen_project.py | 2 +- {{cookiecutter.directory_name}}/next_steps.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 1b8b598b..889268ff 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -5,6 +5,6 @@ "package_name": cookiecutter.package_name.lower().replace(" ", "_").replace("-", "_"), "directory_name": cookiecutter.directory_name.lower().replace(" ", "-"), "full_name": cookiecutter.full_name.replace('\"', '\\\"'), - "repository": "https://github.com/" + cookiecutter.github_organization + "/" + cookiecutter.directory_name.lower().replace(" ", "-"), + "repository": "git@github.com:" + cookiecutter.github_organization + "/" + cookiecutter.directory_name.lower().replace(" ", "-"), "package_short_description": cookiecutter.package_short_description.replace('\"', '\\\"') }) }} diff --git a/{{cookiecutter.directory_name}}/next_steps.md b/{{cookiecutter.directory_name}}/next_steps.md index 4858fbbe..253814d7 100644 --- a/{{cookiecutter.directory_name}}/next_steps.md +++ b/{{cookiecutter.directory_name}}/next_steps.md @@ -6,6 +6,13 @@ Once your Python package is created, put it under [version control](https://guide.esciencecenter.nl/#/best_practices/version_control) using [git](https://git-scm.com/) and [GitHub](https://github.com/). +Note that the next step assumes you have setup your connection to GitHub via SSH, +see [Connecting to GitHub with SSH](https://docs.github.com/en/github-ae@latest/authentication/connecting-to-github-with-ssh). + +Alternatively, you can also use a personal access token, see +[Creating a personal access token](https://docs.github.com/en/github-ae@latest/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). If you choose this option, below you will have to replace +`git@github.com:` by `https://github.com/`. + ```shell cd {{ cookiecutter.directory_name }} git init From 86b981ee40af3d0007bfc91b323c4dd7e4098e87 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Thu, 26 Jan 2023 10:41:05 +0100 Subject: [PATCH 081/144] Add python 3.10 and 3.11 to CI matrix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 05b451f5..b7bffadd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.6', '3.7', '3.8', '3.9'] + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From b6f94515a1bf75e306565c04ec441554c9d6945b Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Thu, 26 Jan 2023 13:49:44 +0100 Subject: [PATCH 082/144] Remove python3.6 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b7bffadd..6d539594 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 04747e6459e46c88288f0b55769b71b9ee68c68b Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Thu, 26 Jan 2023 14:48:39 +0100 Subject: [PATCH 083/144] Update python version in setup.cfg; remove pytest version pinning --- setup.cfg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 8a8e9120..44a4773c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,10 +12,11 @@ classifiers = License :: OSI Approved :: Apache Software License Natural Language :: English Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 description = Cookiecutter template to initialize Python projects in accordance with Netherlands eScience Center best practices long_description = file: README.md long_description_content_type = text/markdown @@ -29,6 +30,7 @@ version = 0.4.0 [options] zip_safe = False include_package_data = True +python_requires >= 3.7 packages = install_requires = cookiecutter==1.7.2 @@ -42,7 +44,7 @@ install_requires = [options.extras_require] dev = coverage [toml] - pytest<5.0.0,>=3.3.0 + pytest pytest-cookies From 742f2006ec4d0cf4372426a70bc324168d18c58a Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Thu, 26 Jan 2023 15:06:07 +0100 Subject: [PATCH 084/144] typo in python_requires option for setup.cfg --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 44a4773c..16dedae2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,7 +30,7 @@ version = 0.4.0 [options] zip_safe = False include_package_data = True -python_requires >= 3.7 +python_requires = >=3.7 packages = install_requires = cookiecutter==1.7.2 From 6298232439bd2e1b9472891f9492dbd18c4bacbb Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 30 Jan 2023 10:34:34 +0100 Subject: [PATCH 085/144] editing generated package's setup.cfg this time --- {{cookiecutter.directory_name}}/setup.cfg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg index 2aba8aee..33c72c7f 100644 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ b/{{cookiecutter.directory_name}}/setup.cfg @@ -18,10 +18,11 @@ classifiers = }[cookiecutter.license] }} Natural Language :: English Programming Language :: Python :: 3 - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 description = {{ cookiecutter.package_short_description }} keywords = {{ cookiecutter.keyword1 }} @@ -36,6 +37,7 @@ version = {{ cookiecutter.version }} [options] zip_safe = False +python_requires = >=3.7 include_package_data = True packages = find: install_requires = From 1b67b098e2842d73975257d372c2480e79abb26b Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 30 Jan 2023 11:56:38 +0100 Subject: [PATCH 086/144] trigger github build From a26cf87ce1309f4c9a981fb10a9b7c3d30831854 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 30 Jan 2023 14:14:13 +0100 Subject: [PATCH 087/144] update python versions in generated project build.yml and tox --- {{cookiecutter.directory_name}}/.github/workflows/build.yml | 2 +- {{cookiecutter.directory_name}}/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index eaca92cc..e202f1b6 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.6', '3.7', '3.8', '3.9'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ '{{ ' -}} matrix.python-version }} diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 3a71fd27..e929771d 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -13,7 +13,7 @@ command_line = "-m pytest" [tool.tox] legacy_tox_ini = """ [tox] -envlist = py37,py38,py39 +envlist = py37,py38,py39,py310,py311 skip_missing_interpreters = true [testenv] commands = pytest From 191c21534971c3478d3d35f2da409f837586b42c Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 30 Jan 2023 14:14:35 +0100 Subject: [PATCH 088/144] fix source dist installation result? --- tests/test_project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_project.py b/tests/test_project.py index d99e7f23..181782fe 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -82,7 +82,8 @@ def test_tox(baked_with_development_dependencies, project_env_bin_dir): result = run([f'{bin_dir}tox'], project_dir) assert result.returncode == 0 assert '== 3 passed in' in result.stdout - assert (project_dir / '.tox' / 'dist' / 'my_python_package-0.1.0.zip').exists() + # assert (project_dir / '.tox' / 'dist' / 'my_python_package-0.1.0.zip').exists() + assert (project_dir / '.tox' / '.pkg' / 'dist'/ 'my_python_package-0.1.0.tar.gz').exists() def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): From c2ee7dc6a269b34ea678a552b7b215a229d57f1e Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 30 Jan 2023 14:43:27 +0100 Subject: [PATCH 089/144] run CI only on push/PR to main --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 05b451f5..522c42f3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,9 +2,12 @@ name: tests on: push: + branches: + - main pull_request: types: [opened, synchronize, reopened] - + branches: + - main jobs: tests: From 879949d59d1939ddd59e509f916a4894851bfd99 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 31 Jan 2023 16:19:43 +0100 Subject: [PATCH 090/144] remove list of all default PR types from tests workflow --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 522c42f3..98c9e6f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,7 +5,6 @@ on: branches: - main pull_request: - types: [opened, synchronize, reopened] branches: - main jobs: From 66a88d13b04e3312027d4d60d35e6210efe2dfd5 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 31 Jan 2023 16:20:09 +0100 Subject: [PATCH 091/144] markdown check to only run on push/PR to main --- .github/workflows/markdown-link-check.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml index 1fe39a3a..3cdbce01 100644 --- a/.github/workflows/markdown-link-check.yml +++ b/.github/workflows/markdown-link-check.yml @@ -1,6 +1,12 @@ name: markdown-link-check -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: From 62dfe36a78d16cdb07db580f870944496210b83d Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 7 Feb 2023 12:56:35 +0100 Subject: [PATCH 092/144] include LPGLv3+ in template --- cookiecutter.json | 2 +- {{cookiecutter.directory_name}}/LICENSE | 166 ++++++++++++++++++++++++ 2 files changed, 167 insertions(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index f45d92cb..60d0b3f3 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -6,7 +6,7 @@ "keyword2": "keyword2", "version": "0.1.0", "github_organization": "", - "license": ["Apache Software License 2.0", "MIT license", "BSD license", "ISC license", "GNU General Public License v3 or later", "Not open source"], + "license": ["Apache Software License 2.0", "MIT license", "BSD license", "ISC license", "GNU General Public License v3 or later", "GNU Lesser General Public License v3 or later", "Not open source"], "full_name": "Jane Smith", "email": "yourname@esciencecenter.nl", "copyright_holder": "Netherlands eScience Center", diff --git a/{{cookiecutter.directory_name}}/LICENSE b/{{cookiecutter.directory_name}}/LICENSE index 00bfbf25..aa06a167 100644 --- a/{{cookiecutter.directory_name}}/LICENSE +++ b/{{cookiecutter.directory_name}}/LICENSE @@ -924,4 +924,170 @@ may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . +{% elif cookiecutter.license == 'GNU Lesser General Public License v3 or later' %} + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. {% endif %} From 89deadd2702aadd578edddd191be29ef33bfb656 Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 13 Feb 2023 12:58:47 +0100 Subject: [PATCH 093/144] Update cff-version to 1.2.0 --- CITATION.cff | 2 +- {{cookiecutter.directory_name}}/CITATION.cff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 40b191cc..045e0e43 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -68,7 +68,7 @@ authors: family-names: Tjong Kim Sang given-names: Erik orcid: "https://orcid.org/0000-0002-8431-081X" -cff-version: "1.1.0" +cff-version: "1.2.0" date-released: 2018-07-17 doi: 10.5281/zenodo.1310751 keywords: diff --git a/{{cookiecutter.directory_name}}/CITATION.cff b/{{cookiecutter.directory_name}}/CITATION.cff index 5c054a2e..6fa1c14a 100644 --- a/{{cookiecutter.directory_name}}/CITATION.cff +++ b/{{cookiecutter.directory_name}}/CITATION.cff @@ -1,6 +1,6 @@ # YAML 1.2 --- -cff-version: "1.1.0" +cff-version: "1.2.0" title: "{{ cookiecutter.package_name }}" authors: - From f89b04967cdd710a7f17c026e1c9d91dd59eefb0 Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 20 Feb 2023 11:32:34 +0100 Subject: [PATCH 094/144] Small fix to PR template --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ee6df26d..1ec1eac8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -**Description* +**Description** From c8948ba0d013d35af07f1883f033f0681f262acd Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 20 Feb 2023 13:40:43 +0100 Subject: [PATCH 095/144] Remove --recursive from isort in pre-commit --- {{cookiecutter.directory_name}}/.githooks/pre-commit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.githooks/pre-commit b/{{cookiecutter.directory_name}}/.githooks/pre-commit index 31ca5c16..2e38f129 100755 --- a/{{cookiecutter.directory_name}}/.githooks/pre-commit +++ b/{{cookiecutter.directory_name}}/.githooks/pre-commit @@ -22,8 +22,8 @@ isort --recursive --check-only {{ cookiecutter.package_name }} if [ $? != "0" ]; then echo "Commit aborted." - echo " Run 'isort --recursive --check-only --diff {{ cookiecutter.package_name }}' to see what's wrong." - echo " Run 'isort --recursive {{ cookiecutter.package_name }}' to let isort fix problems automatically." + echo " Run 'isort --check-only --diff {{ cookiecutter.package_name }}' to see what's wrong." + echo " Run 'isort {{ cookiecutter.package_name }}' to let isort fix problems automatically." exit 1 fi From 01706ebeb0acf5deb1f98bb95c22f7844bf6dc59 Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 20 Feb 2023 14:12:21 +0100 Subject: [PATCH 096/144] Remove --recursive from isort in README.dev.md --- {{cookiecutter.directory_name}}/README.dev.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index a72ef3f3..6277b263 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -71,14 +71,14 @@ development tools installed. prospector # recursively check import style for the {{ cookiecutter.package_name }} module only -isort --recursive --check-only {{ cookiecutter.package_name }} +isort --check-only {{ cookiecutter.package_name }} # recursively check import style for the {{ cookiecutter.package_name }} module only and show # any proposed changes as a diff -isort --recursive --check-only --diff {{ cookiecutter.package_name }} +isort --check-only --diff {{ cookiecutter.package_name }} # recursively fix import style for the {{ cookiecutter.package_name }} module only -isort --recursive {{ cookiecutter.package_name }} +isort {{ cookiecutter.package_name }} ``` To fix readability of your code style you can use [yapf](https://github.com/google/yapf). From cd559dc507d2a6db4f35f7afff9bba874576501f Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Mon, 20 Feb 2023 14:14:06 +0100 Subject: [PATCH 097/144] Remove --recursive from isort in test_project.py --- tests/test_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_project.py b/tests/test_project.py index 181782fe..1c377bf6 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -156,7 +156,7 @@ def test_isort_check(baked_with_development_dependencies, project_env_bin_dir): project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir - result = run([f'{bin_dir}isort', '--recursive', '--check-only', 'my_python_package'], project_dir) + result = run([f'{bin_dir}isort', '--check-only', 'my_python_package'], project_dir) assert result.returncode == 0 assert '' in result.stdout From 622bca5c9b952241d030aba66d1443ede93b775d Mon Sep 17 00:00:00 2001 From: Barbara Vreede Date: Fri, 7 Apr 2023 11:03:43 +0200 Subject: [PATCH 098/144] add read/write permissions to allow issue creation --- .../.github/workflows/next_steps.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml index 7139327c..af46a2bf 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml @@ -1,4 +1,7 @@ on: [push] +permissions: + contents: read + issues: write name: Create issues for next steps jobs: next_steps: From 015de21e4035a2172d16f90a929cb77b92db83ba Mon Sep 17 00:00:00 2001 From: Barbara Vreede Date: Fri, 7 Apr 2023 17:37:05 +0200 Subject: [PATCH 099/144] give write permission to content --- .../.github/workflows/next_steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml index af46a2bf..6c83c90d 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml @@ -1,6 +1,6 @@ on: [push] permissions: - contents: read + contents: write issues: write name: Create issues for next steps jobs: From 70c3d8c7536f451dd694e10cfe1d205485d227cd Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Thu, 8 Jun 2023 15:09:56 +0200 Subject: [PATCH 100/144] Python info steps: switch bash -l to bash -e Fixes #219. --- .github/workflows/tests.yml | 2 +- {{cookiecutter.directory_name}}/.github/workflows/build.yml | 4 ++-- .../.github/workflows/documentation.yml | 2 +- .../.github/workflows/sonarcloud.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6d51f183..76a512b1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Python info - shell: bash -l {0} + shell: bash -e {0} run: | which python3 python3 --version diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index e202f1b6..d7584f07 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: with: python-version: ${{ '{{ ' -}} matrix.python-version }} - name: Python info - shell: bash -l {0} + shell: bash -e {0} run: | which python3 python3 --version @@ -50,7 +50,7 @@ jobs: with: python-version: 3.9 - name: Python info - shell: bash -l {0} + shell: bash -e {0} run: | which python3 python3 --version diff --git a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml index a9f7b367..de9417ee 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml @@ -21,7 +21,7 @@ jobs: with: python-version: 3.9 - name: Python info - shell: bash -l {0} + shell: bash -e {0} run: | which python3 python3 --version diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index 9f7c945c..943af204 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -23,7 +23,7 @@ jobs: with: python-version: 3.9 - name: Python info - shell: bash -l {0} + shell: bash -e {0} run: | which python3 python3 --version From 9686cf7272f148c7692bd97107cad1c7dea4bad8 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Thu, 8 Jun 2023 18:53:41 +0200 Subject: [PATCH 101/144] use python instead of python3 everywhere Everywhere: on CI, in tests, in docs. Also, we replace bare pip/pip3 and pytest calls with python -m pip and python -m pytest respectively, to make sure we always use the same python executable everywhere. This fixes #326 (failing Windows tests on CI), because the `python3` executable causes issues (it is not properly copied into the venv directory by venv, which is a CPython bug, see https://github.com/python/cpython/issues/87915), while the python executable does work; see e.g. here https://stackoverflow.com/questions/61669873/python-venv-env-fails-winerror-2-the-system-cannot-find-the-file-specified. `python` should be the same executable under the hood as `python3`, if the setup-python action works as expected, at least. It also allows us to remove the IS_WINDOWS_CI special case. Failed attempts at fixing #326 included: - Setting the shells (assuming something went wrong with environment variables) - Using full paths for both the executable and the venv directory in the template test suite. --- .github/workflows/tests.yml | 10 +++---- README.dev.md | 8 +++--- tests/test_project.py | 28 ++++++------------- .../.github/workflows/build.yml | 20 ++++++------- .../.github/workflows/documentation.yml | 8 +++--- .../.github/workflows/sonarcloud.yml | 8 +++--- {{cookiecutter.directory_name}}/README.dev.md | 24 ++++++++-------- 7 files changed, 47 insertions(+), 59 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6d51f183..e1f078ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,12 +26,12 @@ jobs: - name: Python info shell: bash -l {0} run: | - which python3 - python3 --version + which python + python --version - name: Install dependencies run: | - python3 -m pip install --upgrade pip setuptools - python3 -m pip install .[dev] + python -m pip install --upgrade pip setuptools + python -m pip install .[dev] - name: Run pytest run: | - pytest -v + python -m pytest -v diff --git a/README.dev.md b/README.dev.md index f2debd1c..c7bc7c99 100644 --- a/README.dev.md +++ b/README.dev.md @@ -10,7 +10,7 @@ We recommend installing `cookiecutter` in user space as per `cookiecutter`'s ins install `cookiecutter` for every new project. ```shell -python3 -m pip install --user --upgrade cookiecutter +python -m pip install --user --upgrade cookiecutter ``` ### Get your own copy of the repository @@ -30,17 +30,17 @@ run the tests later. ```shell # Create a virtual environment, e.g. with -python3 -m venv env +python -m venv env # activate virtual environment source env/bin/activate # make sure to have a recent version of pip and setuptools -python3 -m pip install --upgrade pip setuptools +python -m pip install --upgrade pip setuptools # (from the project root directory) # install development dependencies -python3 -m pip install --no-cache-dir .[dev] +python -m pip install --no-cache-dir .[dev] ``` ## Running the tests diff --git a/tests/test_project.py b/tests/test_project.py index 1c377bf6..c1b56c73 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1,14 +1,11 @@ import os import subprocess -from pathlib import Path -from shutil import which from sys import platform from typing import Sequence import pytest IS_WINDOWS = platform.startswith('win') -IS_WINDOWS_CI = IS_WINDOWS and os.environ.get('CI', False) def test_project_folder(cookies): @@ -33,17 +30,11 @@ def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProces @pytest.fixture def project_env_bin_dir(tmp_path): - if IS_WINDOWS_CI: - # Creating virtualenv does not work on Windows CI, - # falling back to using current pip3 dir - pip = Path(which('pip3')) - bin_dir = pip.parent - else: - env_output = run(['python3', '-m', 'venv', 'env'], tmp_path) - assert env_output.returncode == 0 - bin_dir = str(tmp_path / 'env' / 'bin') - if IS_WINDOWS: - bin_dir = str(tmp_path / 'env' / 'Scripts') + env_output = run(['python', '-m', 'venv', 'env'], tmp_path) + assert env_output.returncode == 0 + bin_dir = str(tmp_path / 'env' / 'bin') + if IS_WINDOWS: + bin_dir = str(tmp_path / 'env' / 'Scripts') return str(bin_dir) + os.sep @@ -52,9 +43,9 @@ def baked_with_development_dependencies(cookies, project_env_bin_dir): result = cookies.bake() assert result.exit_code == 0 bin_dir = project_env_bin_dir - latest_pip_output = run([f'{bin_dir}pip3', 'install', '--upgrade', 'pip', 'setuptools'], result.project) + latest_pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], result.project) assert latest_pip_output.returncode == 0 - pip_output = run([f'{bin_dir}pip3', 'install', '--editable', '.[dev]'], result.project) + pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.[dev]'], result.project) assert pip_output.returncode == 0 return result.project @@ -62,7 +53,7 @@ def baked_with_development_dependencies(cookies, project_env_bin_dir): def test_pytest(baked_with_development_dependencies, project_env_bin_dir): project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir - result = run([f'{bin_dir}pytest'], project_dir) + result = run([f'{bin_dir}python', '-m', 'pytest'], project_dir) assert result.returncode == 0 assert '== 3 passed in' in result.stdout @@ -98,9 +89,6 @@ def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): subsubpackage.mkdir() (subsubpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8") - if IS_WINDOWS_CI: - # On Windows CI python and pip executable are in different paths - bin_dir = '' # sdist and bdist_wheel both call build command to create build/ dir # So instead of looking in distribution archives we can look in build/ dir result = run([f'{bin_dir}python', 'setup.py', 'build'], project_dir) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index e202f1b6..cda7e41a 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -27,16 +27,16 @@ jobs: - name: Python info shell: bash -l {0} run: | - which python3 - python3 --version + which python + python --version - name: Upgrade pip and install dependencies run: | - python3 -m pip install --upgrade pip setuptools - python3 -m pip install .[dev,publishing] + python -m pip install --upgrade pip setuptools + python -m pip install .[dev,publishing] - name: Run unit tests - run: pytest -v + run: python -m pytest -v - name: Verify that we can build the package - run: python3 setup.py sdist bdist_wheel + run: python setup.py sdist bdist_wheel lint: name: Linting build @@ -52,12 +52,12 @@ jobs: - name: Python info shell: bash -l {0} run: | - which python3 - python3 --version + which python + python --version - name: Upgrade pip and install dependencies run: | - python3 -m pip install --upgrade pip setuptools - python3 -m pip install .[dev,publishing] + python -m pip install --upgrade pip setuptools + python -m pip install .[dev,publishing] - name: Check style against standards using prospector run: prospector - name: Check import order diff --git a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml index a9f7b367..09bb41f8 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml @@ -23,12 +23,12 @@ jobs: - name: Python info shell: bash -l {0} run: | - which python3 - python3 --version + which python + python --version - name: Upgrade pip and install dependencies run: | - python3 -m pip install --upgrade pip setuptools - python3 -m pip install .[dev,publishing] + python -m pip install --upgrade pip setuptools + python -m pip install .[dev,publishing] - name: Install pandoc using apt run: sudo apt install pandoc - name: Build documentation diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index 9f7c945c..59aeb90e 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -25,14 +25,14 @@ jobs: - name: Python info shell: bash -l {0} run: | - which python3 - python3 --version + which python + python --version - name: Install dependencies - run: python3 -m pip install .[dev] + run: python -m pip install .[dev] - name: Check style against standards using prospector run: prospector --zero-exit --output-format grouped --output-format pylint:pylint-report.txt - name: Run unit tests with coverage - run: pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/ + run: python -m pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/ - name: Correct coverage paths run: sed -i "s+$PWD/++g" coverage.xml - name: SonarCloud Scan diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 6277b263..9b48b4e4 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -6,19 +6,19 @@ If you're looking for user documentation, go [here](README.md). ```shell # Create a virtual environment, e.g. with -python3 -m venv env +python -m venv env # activate virtual environment source env/bin/activate # make sure to have a recent version of pip and setuptools -python3 -m pip install --upgrade pip setuptools +python -m pip install --upgrade pip setuptools # (from the project root directory) # install {{ cookiecutter.package_name }} as an editable package -python3 -m pip install --no-cache-dir --editable . +python -m pip install --no-cache-dir --editable . # install development dependencies -python3 -m pip install --no-cache-dir --editable .[dev] +python -m pip install --no-cache-dir --editable .[dev] ``` Afterwards check that the install directory is present in the `PATH` environment variable. @@ -156,22 +156,22 @@ cd $(mktemp -d {{ cookiecutter.package_name }}.XXXXXX) git clone {{ cookiecutter.repository }} . # prepare a clean virtual environment and activate it -python3 -m venv env +python -m venv env source env/bin/activate # make sure to have a recent version of pip and setuptools -python3 -m pip install --upgrade pip setuptools +python -m pip install --upgrade pip setuptools # install runtime dependencies and publishing dependencies -python3 -m pip install --no-cache-dir . -python3 -m pip install --no-cache-dir .[publishing] +python -m pip install --no-cache-dir . +python -m pip install --no-cache-dir .[publishing] # clean up any previously generated artefacts rm -rf {{ cookiecutter.package_name }}.egg-info rm -rf dist # create the source distribution and the wheel -python3 setup.py sdist bdist_wheel +python setup.py sdist bdist_wheel # upload to test pypi instance (requires credentials) twine upload --repository-url https://test.pypi.org/legacy/ dist/* @@ -187,14 +187,14 @@ In a new terminal, without an activated virtual environment or an env directory: cd $(mktemp -d {{ cookiecutter.package_name }}-test.XXXXXX) # prepare a clean virtual environment and activate it -python3 -m venv env +python -m venv env source env/bin/activate # make sure to have a recent version of pip and setuptools -pip install --upgrade pip setuptools +python -m pip install --upgrade pip setuptools # install from test pypi instance: -python3 -m pip -v install --no-cache-dir \ +python -m pip -v install --no-cache-dir \ --index-url https://test.pypi.org/simple/ \ --extra-index-url https://pypi.org/simple {{ cookiecutter.package_name }} ``` From 3a1f3e5525c7ee4fe7a5dd92c8880b96c4350d0a Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Tue, 11 Jul 2023 17:34:50 +0200 Subject: [PATCH 102/144] remove more python3/pip3 command from docs A few remaining python3/pip3 mentions are now replaced by python/pip. This should have been done in 9686cf7272f148c7692bd97107cad1c7dea4bad8. --- CONTRIBUTING.md | 4 ++-- README.md | 2 +- {{cookiecutter.directory_name}}/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70f2da13..e8059802 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,8 +30,8 @@ The sections below outline the steps in each case. 1. (**important**) announce your plan to the rest of the community _before you start working_. This announcement should be in the form of a (new) issue; 1. (**important**) wait until some kind of consensus is reached about your idea being a good idea; 1. if needed, fork the repository to your own Github profile and create your own feature branch off of the latest main commit. While working on your feature branch, make sure to stay up to date with the main branch by pulling in changes, possibly from the 'upstream' repository (follow the instructions [here](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and [here](https://help.github.com/articles/syncing-a-fork/)); -1. Install dependencies with `pip3 install -r requirements.txt`; -1. make sure the existing tests still work by running ``pytest``. If project tests fails use ``pytest --keep-baked-projects`` to keep generated project in /tmp/pytest-* and investigate; +1. install dependencies (see the [development documentation](README.dev.md#create-a-virtual-environment)); +1. make sure the existing tests still work by running ``pytest``. If project tests fail use ``pytest --keep-baked-projects`` to keep generated project files in `/tmp/pytest-*` and investigate; 1. add your own tests (if necessary); 1. update or expand the documentation; 1. push your feature branch to (your fork of) the Python Template repository on GitHub; diff --git a/README.md b/README.md index 7d2d70a7..c2cb63b0 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ We recommend installing `cookiecutter` in user space as per `cookiecutter`'s ins install `cookiecutter` for every new project. ```shell -python3 -m pip install --user --upgrade cookiecutter +python -m pip install --user --upgrade cookiecutter ``` ### Step 2/3: Generate the files and directory structure diff --git a/{{cookiecutter.directory_name}}/README.md b/{{cookiecutter.directory_name}}/README.md index d95a2313..30d5ce1e 100644 --- a/{{cookiecutter.directory_name}}/README.md +++ b/{{cookiecutter.directory_name}}/README.md @@ -33,7 +33,7 @@ To install {{ cookiecutter.package_name }} from GitHub repository, do: ```console git clone {{ cookiecutter.repository }}.git cd {{ cookiecutter.directory_name }} -python3 -m pip install . +python -m pip install . ``` ## Documentation From c288cba0ae5271a77762e4cb5993e30c5ce4dd0f Mon Sep 17 00:00:00 2001 From: Christiaan Meijer Date: Thu, 3 Aug 2023 17:23:11 +0200 Subject: [PATCH 103/144] Update project_setup.md sync python versions with those in setup.cfg --- {{cookiecutter.directory_name}}/project_setup.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 4c174883..127d86a6 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -11,10 +11,11 @@ checklist](https://guide.esciencecenter.nl/#/best_practices/checklist). This repository is set up with Python versions: -- 3.6 - 3.7 - 3.8 - 3.9 +- 3.10 +- 3.11 Add or remove Python versions based on project requirements. See [the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python) for more information about Python From 99748f849eb48b05c2344f993ca28d21581751e9 Mon Sep 17 00:00:00 2001 From: Christiaan Meijer Date: Mon, 11 Sep 2023 11:35:31 +0200 Subject: [PATCH 104/144] update test to expect the output of a new version of sphinx See https://github.com/NLeSC/python-template/pull/347#issuecomment-1710684574 --- tests/test_project.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index c1b56c73..76a1ae26 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1,5 +1,6 @@ import os import subprocess +import sys from sys import platform from typing import Sequence @@ -107,6 +108,8 @@ def test_generate_api_docs(baked_with_development_dependencies, project_env_bin_ assert (project_dir / 'docs' / '_build' / 'html' / 'index.html').exists() +@pytest.mark.skipif(sys.version_info < (3, 9), reason= +"requires python 3.9 or higher, see https://github.com/NLeSC/python-template/pull/347#issuecomment-1710684574") def test_coverage_api_docs(baked_with_development_dependencies, project_env_bin_dir): project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir @@ -116,9 +119,28 @@ def test_coverage_api_docs(baked_with_development_dependencies, project_env_bin_ assert 'build succeeded' in result.stdout coverage_file = project_dir / 'docs' / '_build' / 'coverage' / 'python.txt' coverage_file_lines = coverage_file.read_text('utf8').splitlines() - expected = ['Undocumented Python objects', - '==========================='] - assert coverage_file_lines == expected + # Coverage file lines should look globally like: + # ['Undocumented Python objects', + # '===========================', + # '', + # 'Statistics', + # '----------', + # '', + # '+-----------------------------+----------+--------------+', + # '| Module | Coverage | Undocumented |', + # '+=============================+==========+==============+', + # '| my_python_package | 100.00% | 0 |', + # '+-----------------------------+----------+--------------+', + # '| my_python_package.my_module | 100.00% | 0 |', + # '+-----------------------------+----------+--------------+', + # '| TOTAL | 100.00% | 0 |', + # '+-----------------------------+----------+--------------+', + # '' + # ] + # The package coverage lines change order between runs, so we test for each data row individually: + assert '| my_python_package | 100.00% | 0 |' in coverage_file_lines + assert '| my_python_package.my_module | 100.00% | 0 |' in coverage_file_lines + assert '| TOTAL | 100.00% | 0 |' in coverage_file_lines def test_doctest_api_docs(baked_with_development_dependencies, project_env_bin_dir): From 50b19b36f6177ad076a23bcaf1a83f5790e66bb2 Mon Sep 17 00:00:00 2001 From: Christiaan Meijer Date: Wed, 6 Sep 2023 14:30:07 +0200 Subject: [PATCH 105/144] use ruff instead of prospector and isort (Refs #336) --- CHANGELOG.md | 1 + README.md | 3 +- tests/test_project.py | 13 +--- .../.githooks/pre-commit | 20 +---- .../.github/next_steps/05_linting.md | 2 +- .../.github/workflows/build.yml | 6 +- .../.github/workflows/sonarcloud.yml | 2 - .../.prospector.yml | 29 -------- {{cookiecutter.directory_name}}/README.dev.md | 20 ++--- .../pyproject.toml | 74 +++++++++++++++++++ {{cookiecutter.directory_name}}/setup.cfg | 11 +-- 11 files changed, 92 insertions(+), 89 deletions(-) delete mode 100644 {{cookiecutter.directory_name}}/.prospector.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index dacde367..c686fe0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Changed +* Moved from prospector to ruff [#336](https://github.com/NLeSC/python-template/issues/336) * Renamed `project_name` to `directory_name` in cookiecutter questionnaire * Initial linting is error free [#227](https://github.com/NLeSC/python-template/issues/227) * Consolidated test/lint/build/docs into single matrix workflow [#270](https://github.com/NLeSC/python-template/issues/276) diff --git a/README.md b/README.md index c2cb63b0..df725406 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ an empty Python package. Features include: - [Python static setup configuration]({{cookiecutter.directory_name}}/setup.cfg), - Open source software license, - Continuous integration with [GitHub action workflows]({{cookiecutter.directory_name}}/.github/workflows) for building, testing, link checking and linting, -- Code style checking with [prospector](https://pypi.org/project/prospector/), +- Code style checking with [ruff](https://beta.ruff.rs/), - [Editorconfig]({{cookiecutter.directory_name}}/.editorconfig), - Usage and contribution documents: - [README.md]({{cookiecutter.directory_name}}/README.md) for package users, @@ -131,7 +131,6 @@ my-python-project/ ├── next_steps.md ├── NOTICE ├── project_setup.md -├── .prospector.yml ├── .pylintrc ├── pyproject.toml ├── README.dev.md diff --git a/tests/test_project.py b/tests/test_project.py index 76a1ae26..a47d3f9b 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -153,20 +153,11 @@ def test_doctest_api_docs(baked_with_development_dependencies, project_env_bin_d assert (project_dir / 'docs' / '_build' / 'doctest' / 'output.txt').exists() -def test_prospector(baked_with_development_dependencies, project_env_bin_dir): +def test_ruff_check(baked_with_development_dependencies, project_env_bin_dir): project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir - result = run([f'{bin_dir}prospector'], project_dir) - assert result.returncode == 0 - assert 'Messages Found: 0' in result.stdout - - -def test_isort_check(baked_with_development_dependencies, project_env_bin_dir): - project_dir = baked_with_development_dependencies - bin_dir = project_env_bin_dir - - result = run([f'{bin_dir}isort', '--check-only', 'my_python_package'], project_dir) + result = run([f'{bin_dir}ruff', '.'], project_dir) assert result.returncode == 0 assert '' in result.stdout diff --git a/{{cookiecutter.directory_name}}/.githooks/pre-commit b/{{cookiecutter.directory_name}}/.githooks/pre-commit index 2e38f129..a0f9c2e0 100755 --- a/{{cookiecutter.directory_name}}/.githooks/pre-commit +++ b/{{cookiecutter.directory_name}}/.githooks/pre-commit @@ -3,29 +3,17 @@ echo "Script $0 triggered ..." # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -echo "Starting prospector analysis using configuration from .prospector.yml..." +echo "Starting ruff analysis..." -# quietly run prospector -prospector 1>/dev/null +# quietly run ruff +ruff . --fix # use return code to abort commit if necessary if [ $? != "0" ]; then - echo "Commit aborted. Run 'prospector' to see the errors." + echo "Commit aborted. Fix linter issues found by ruff before committing." exit 1 fi # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -echo "Starting isort analysis using configuration from setup.cfg..." - -# recursively run isort on {{ cookiecutter.package_name }}/ directory, don't try to automatically fix anything -isort --recursive --check-only {{ cookiecutter.package_name }} - -if [ $? != "0" ]; then - echo "Commit aborted." - echo " Run 'isort --check-only --diff {{ cookiecutter.package_name }}' to see what's wrong." - echo " Run 'isort {{ cookiecutter.package_name }}' to let isort fix problems automatically." - exit 1 -fi - echo "Pre-commit checks completed successfully." exit 0 diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md index e2b32c24..471a09b4 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md @@ -7,7 +7,7 @@ Your repository has a [workflow]({{ cookiecutter.repository }}/blob/main/.github Linter workflow may fail if `description` or `keywords` field in [setup.cfg]({{ cookiecutter.repository }}/blob/main/setup.cfg) is empty. Please update these fields. To validate your changes run: ```shell -prospector +ruff . ``` Enabling [githook](https://git-scm.com/docs/githooks) will automatically lint your code in every commit. You can enable it by running the command below. diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 666b6930..80ec495f 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -58,7 +58,5 @@ jobs: run: | python -m pip install --upgrade pip setuptools python -m pip install .[dev,publishing] - - name: Check style against standards using prospector - run: prospector - - name: Check import order - run: isort --check-only {{ cookiecutter.package_name }} --diff + - name: Check style against standards using ruff + run: ruff . diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index 1067aa92..dc4f8672 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -29,8 +29,6 @@ jobs: python --version - name: Install dependencies run: python -m pip install .[dev] - - name: Check style against standards using prospector - run: prospector --zero-exit --output-format grouped --output-format pylint:pylint-report.txt - name: Run unit tests with coverage run: python -m pytest --cov --cov-report term --cov-report xml --junitxml=xunit-result.xml tests/ - name: Correct coverage paths diff --git a/{{cookiecutter.directory_name}}/.prospector.yml b/{{cookiecutter.directory_name}}/.prospector.yml deleted file mode 100644 index a5000487..00000000 --- a/{{cookiecutter.directory_name}}/.prospector.yml +++ /dev/null @@ -1,29 +0,0 @@ -# prospector configuration file - ---- - -output-format: grouped - -strictness: medium -doc-warnings: false -test-warnings: true -member-warnings: false - -ignore-paths: - - docs - -pyroma: - run: true - -pycodestyle: - full: true - -pydocstyle: - disable: [ - # Disable because not part of PEP257 official convention: - # see http://pep257.readthedocs.io/en/latest/error_codes.html - D203, # 1 blank line required before class docstring - D212, # Multi-line docstring summary should start at the first line - D213, # Multi-line docstring summary should start at the second line - D404, # First word of the docstring should not be This - ] diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 9b48b4e4..839a4a0f 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -62,28 +62,20 @@ coverage report ## Running linters locally -For linting we will use [prospector](https://pypi.org/project/prospector/) and to sort imports we will use -[isort](https://pycqa.github.io/isort/). Running the linters requires an activated virtual environment with the -development tools installed. +For linting and sorting imports we will use [ruff](https://beta.ruff.rs/docs/). Running the linters requires an +activated virtual environment with the development tools installed. ```shell # linter -prospector +ruff . -# recursively check import style for the {{ cookiecutter.package_name }} module only -isort --check-only {{ cookiecutter.package_name }} - -# recursively check import style for the {{ cookiecutter.package_name }} module only and show -# any proposed changes as a diff -isort --check-only --diff {{ cookiecutter.package_name }} - -# recursively fix import style for the {{ cookiecutter.package_name }} module only -isort {{ cookiecutter.package_name }} +# linter with automatic fixing +ruff . --fix ``` To fix readability of your code style you can use [yapf](https://github.com/google/yapf). -You can enable automatic linting with `prospector` and `isort` on commit by enabling the git hook from `.githooks/pre-commit`, like so: +You can enable automatic linting with `ruff` on commit by enabling the git hook from `.githooks/pre-commit`, like so: ```shell git config --local core.hooksPath .githooks diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index e929771d..cee016dc 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -19,3 +19,77 @@ skip_missing_interpreters = true commands = pytest extras = dev """ + +[tool.ruff] +# Enable Pyflakes `E` and `F` codes by default. +select = [ + "F", # Pyflakes + "E", # pycodestyle (error) + "W", # pycodestyle (warning) + # "C90", # mccabe + "I", # isort + "D", # pydocstyle + # "PL", # Pylint + # "PLC", # Convention + # "PLE", # Error + # "PLR", # Refactor + # "PLW", # Warning + +] +ignore = [ + 'D100', # Missing module docstring + # The following list excludes rules irrelevant to the Google style + 'D203', + 'D204', + 'D213', + 'D215', + 'D400', + 'D401', + 'D404', + 'D406', + 'D407', + 'D408', + 'D409', + 'D413', +] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "I"] +unfixable = [] + +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", + ".venv", + "scripts", +] +per-file-ignores = {} + + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +target-version = "py39" +line-length = 120 + +[tool.ruff.isort] +known-first-party = ["{{ cookiecutter.package_name }}"] +force-single-line = true +no-lines-before = ["future","standard-library","third-party","first-party","local-folder"] diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg index 33c72c7f..d623faa8 100644 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ b/{{cookiecutter.directory_name}}/setup.cfg @@ -51,8 +51,7 @@ install_requires = dev = bump2version coverage [toml] - prospector[with_pyroma] - isort + ruff pytest pytest-cov sphinx @@ -66,11 +65,3 @@ publishing = [options.packages.find] include = {{ cookiecutter.package_name }}, {{ cookiecutter.package_name }}.* - -[isort] -lines_after_imports = 2 -force_single_line = 1 -no_lines_before = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -known_first_party = {{ cookiecutter.package_name }} -src_paths = {{ cookiecutter.package_name }},tests -line_length = 120 From e3d127554cd2e0d40a21f9b5478e8c8a7d80ed49 Mon Sep 17 00:00:00 2001 From: Christiaan Meijer Date: Wed, 6 Sep 2023 16:40:06 +0200 Subject: [PATCH 106/144] bring template code and ruff config in sync (Refs #336) --- {{cookiecutter.directory_name}}/pyproject.toml | 1 + {{cookiecutter.directory_name}}/setup.py | 2 -- {{cookiecutter.directory_name}}/tests/test_my_module.py | 8 +++++--- .../{{cookiecutter.package_name}}/__init__.py | 3 +-- .../{{cookiecutter.package_name}}/my_module.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index cee016dc..4e50c29d 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -38,6 +38,7 @@ select = [ ] ignore = [ 'D100', # Missing module docstring + 'D104', # Missing public package docstring # The following list excludes rules irrelevant to the Google style 'D203', 'D204', diff --git a/{{cookiecutter.directory_name}}/setup.py b/{{cookiecutter.directory_name}}/setup.py index 64c3869b..3bac968b 100644 --- a/{{cookiecutter.directory_name}}/setup.py +++ b/{{cookiecutter.directory_name}}/setup.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -import os from setuptools import setup - # see setup.cfg setup() diff --git a/{{cookiecutter.directory_name}}/tests/test_my_module.py b/{{cookiecutter.directory_name}}/tests/test_my_module.py index c78f5249..ad6481d6 100644 --- a/{{cookiecutter.directory_name}}/tests/test_my_module.py +++ b/{{cookiecutter.directory_name}}/tests/test_my_module.py @@ -1,15 +1,15 @@ -"""Tests for the {{ cookiecutter.package_name }}.my_module module. -""" +"""Tests for the {{ cookiecutter.package_name }}.my_module module.""" import pytest - from {{ cookiecutter.package_name }}.my_module import hello def test_hello(): + """Example using assert.""" assert hello('nlesc') == 'Hello nlesc!' def test_hello_with_error(): + """Example of testing for raised errors.""" with pytest.raises(ValueError) as excinfo: hello('nobody') assert 'Can not say hello to nobody' in str(excinfo.value) @@ -17,8 +17,10 @@ def test_hello_with_error(): @pytest.fixture def some_name(): + """Example fixture.""" return 'Jane Smith' def test_hello_with_fixture(some_name): + """Example using a fixture.""" assert hello(some_name) == 'Hello Jane Smith!' diff --git a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py index 939ed008..4a72a364 100644 --- a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py +++ b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/__init__.py @@ -1,7 +1,6 @@ -"""Documentation about {{ cookiecutter.package_name }}""" +"""Documentation about {{ cookiecutter.package_name }}.""" import logging - logging.getLogger(__name__).addHandler(logging.NullHandler()) __author__ = "{{ cookiecutter.full_name }}" diff --git a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py index be0172d9..1ebf6f27 100644 --- a/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py +++ b/{{cookiecutter.directory_name}}/{{cookiecutter.package_name}}/my_module.py @@ -3,7 +3,7 @@ # FIXME: put actual code here def hello(name): - """Say hello + """Say hello. Function docstring using Google docstring style. From 6c38999ff52c6d77c96ad35089ad9c6637f56088 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Fri, 29 Sep 2023 22:30:00 +0200 Subject: [PATCH 107/144] Re-use baked project for all tests --- tests/test_project.py | 45 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index a47d3f9b..dab64f45 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -29,8 +29,9 @@ def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProces return completed_process -@pytest.fixture -def project_env_bin_dir(tmp_path): +@pytest.fixture(scope='session') +def project_env_bin_dir(tmp_path_factory): + tmp_path = tmp_path_factory.mktemp('venv') env_output = run(['python', '-m', 'venv', 'env'], tmp_path) assert env_output.returncode == 0 bin_dir = str(tmp_path / 'env' / 'bin') @@ -39,12 +40,12 @@ def project_env_bin_dir(tmp_path): return str(bin_dir) + os.sep -@pytest.fixture -def baked_with_development_dependencies(cookies, project_env_bin_dir): - result = cookies.bake() +@pytest.fixture(scope='session') +def baked_with_development_dependencies(cookies_session, project_env_bin_dir): + result = cookies_session.bake() assert result.exit_code == 0 bin_dir = project_env_bin_dir - latest_pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], result.project) + latest_pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], result.project_path) assert latest_pip_output.returncode == 0 pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.[dev]'], result.project) assert pip_output.returncode == 0 @@ -84,11 +85,11 @@ def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): bin_dir = project_env_bin_dir subpackage = (project_dir / 'my_python_package' / 'mysub') subpackage.mkdir() - (subpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8") + (subpackage / '__init__.py').write_text('FOO = "bar"\n', encoding="utf-8") subsubpackage = (project_dir / 'my_python_package' / 'mysub' / 'mysub2') subsubpackage.mkdir() - (subsubpackage / '__init__.py').write_text('FOO = "bar"', encoding="utf-8") + (subsubpackage / '__init__.py').write_text('FOO = "bar"\n', encoding="utf-8") # sdist and bdist_wheel both call build command to create build/ dir # So instead of looking in distribution archives we can look in build/ dir @@ -126,21 +127,25 @@ def test_coverage_api_docs(baked_with_development_dependencies, project_env_bin_ # 'Statistics', # '----------', # '', - # '+-----------------------------+----------+--------------+', - # '| Module | Coverage | Undocumented |', - # '+=============================+==========+==============+', - # '| my_python_package | 100.00% | 0 |', - # '+-----------------------------+----------+--------------+', - # '| my_python_package.my_module | 100.00% | 0 |', - # '+-----------------------------+----------+--------------+', - # '| TOTAL | 100.00% | 0 |', - # '+-----------------------------+----------+--------------+', + # '+--------------------------------+----------+--------------+', + # '| Module | Coverage | Undocumented |', + # '+================================+==========+==============+', + # '| my_python_package.my_module | 100.00% | 0 |', + # '+--------------------------------+----------+--------------+', + # '| my_python_package.mysub.mysub2 | 100.00% | 0 |', + # '+--------------------------------+----------+--------------+', + # '| my_python_package | 100.00% | 0 |', + # '+--------------------------------+----------+--------------+', + # '| my_python_package.mysub | 100.00% | 0 |', + # '+--------------------------------+----------+--------------+', + # '| TOTAL | 100.00% | 0 |', + # '+--------------------------------+----------+--------------+', # '' # ] # The package coverage lines change order between runs, so we test for each data row individually: - assert '| my_python_package | 100.00% | 0 |' in coverage_file_lines - assert '| my_python_package.my_module | 100.00% | 0 |' in coverage_file_lines - assert '| TOTAL | 100.00% | 0 |' in coverage_file_lines + assert '| my_python_package | 100.00% | 0 |' in coverage_file_lines + assert '| my_python_package.my_module | 100.00% | 0 |' in coverage_file_lines + assert '| TOTAL | 100.00% | 0 |' in coverage_file_lines def test_doctest_api_docs(baked_with_development_dependencies, project_env_bin_dir): From 3ae9eae300e17cf41f1b3c24e77245aa5ba6bbf6 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Fri, 29 Sep 2023 22:55:47 +0200 Subject: [PATCH 108/144] Replace the deprecated .project with .project_path --- tests/test_project.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index dab64f45..c1a00c8f 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -14,8 +14,8 @@ def test_project_folder(cookies): assert project.exit_code == 0 assert project.exception is None - assert project.project.basename == 'my-python-project' - assert project.project.isdir() + assert project.project_path.name == 'my-python-project' + assert project.project_path.is_dir() def run(args: Sequence[str], dirpath: os.PathLike) -> subprocess.CompletedProcess: @@ -47,9 +47,9 @@ def baked_with_development_dependencies(cookies_session, project_env_bin_dir): bin_dir = project_env_bin_dir latest_pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--upgrade', 'pip', 'setuptools'], result.project_path) assert latest_pip_output.returncode == 0 - pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.[dev]'], result.project) + pip_output = run([f'{bin_dir}python', '-m', 'pip', 'install', '--editable', '.[dev]'], result.project_path) assert pip_output.returncode == 0 - return result.project + return result.project_path def test_pytest(baked_with_development_dependencies, project_env_bin_dir): From c449192a065e784b5b94489914d207368070f5f5 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Fri, 29 Sep 2023 23:08:25 +0200 Subject: [PATCH 109/144] Show test durations --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 50576450..b973dc16 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,4 +34,4 @@ jobs: python -m pip install .[dev] - name: Run pytest run: | - python -m pytest -v + python -m pytest -v --durations=0 From 4d32164b0a00e5bca20c91997c4d387ec41d61a1 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Wed, 27 Sep 2023 01:34:40 +0200 Subject: [PATCH 110/144] move setup.cfg to pyproject.toml --- CHANGELOG.md | 1 + hooks/pre_gen_project.py | 1 + .../next_steps/01_sonarcloud_integration.md | 2 +- .../.github/next_steps/02_citation.md | 4 +- .../.github/next_steps/03_readthedocs.md | 4 +- .../next_steps/04_zenodo_integration.md | 2 +- .../.github/next_steps/05_linting.md | 4 +- {{cookiecutter.directory_name}}/CITATION.cff | 2 +- .../CONTRIBUTING.md | 4 +- {{cookiecutter.directory_name}}/README.dev.md | 2 +- {{cookiecutter.directory_name}}/README.md | 12 +-- {{cookiecutter.directory_name}}/next_steps.md | 2 +- .../pyproject.toml | 78 ++++++++++++++++++- {{cookiecutter.directory_name}}/setup.cfg | 67 ---------------- {{cookiecutter.directory_name}}/setup.py | 5 -- .../sonar-project.properties | 6 +- 16 files changed, 101 insertions(+), 95 deletions(-) delete mode 100644 {{cookiecutter.directory_name}}/setup.cfg delete mode 100644 {{cookiecutter.directory_name}}/setup.py diff --git a/CHANGELOG.md b/CHANGELOG.md index c686fe0c..ce983e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Changed +* Moved from setup.cfg/.py to pyproject.toml [#351](https://github.com/NLeSC/python-template/issues/351) * Moved from prospector to ruff [#336](https://github.com/NLeSC/python-template/issues/336) * Renamed `project_name` to `directory_name` in cookiecutter questionnaire * Initial linting is error free [#227](https://github.com/NLeSC/python-template/issues/227) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 889268ff..665cbe50 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -6,5 +6,6 @@ "directory_name": cookiecutter.directory_name.lower().replace(" ", "-"), "full_name": cookiecutter.full_name.replace('\"', '\\\"'), "repository": "git@github.com:" + cookiecutter.github_organization + "/" + cookiecutter.directory_name.lower().replace(" ", "-"), + "repository_url": "https://github.com/" + cookiecutter.github_organization + "/" + cookiecutter.directory_name.lower().replace(" ", "-"), "package_short_description": cookiecutter.package_short_description.replace('\"', '\\\"') }) }} diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md b/{{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md index 01885e68..23761831 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/01_sonarcloud_integration.md @@ -4,7 +4,7 @@ title: 'Next step: Sonarcloud integration' Continuous code quality can be handled by [Sonarcloud](https://sonarcloud.io/). This repository is configured to use Sonarcloud to perform quality analysis and code coverage report on each push. -In order to configure Sonarcloud analysis [GitHub Action workflow]({{cookiecutter.repository}}/blob/main/.github/workflows/sonarcloud.yml) you must follow the steps below: +In order to configure Sonarcloud analysis [GitHub Action workflow]({{cookiecutter.repository_url}}/blob/main/.github/workflows/sonarcloud.yml) you must follow the steps below: 1. go to [Sonarcloud](https://sonarcloud.io/projects/create) to create a new Sonarcloud project 1. login with your GitHub account diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md b/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md index ea181384..8ec08600 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md @@ -2,7 +2,7 @@ title: 'Next step: Citation data' --- -It is likely that your `CITATION.cff` currently doesn't pass validation. The error messages you get from the [`cffconvert`]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) GitHub Action are unfortunately a bit cryptic, but doing the following helps: +It is likely that your `CITATION.cff` currently doesn't pass validation. The error messages you get from the [`cffconvert`]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) GitHub Action are unfortunately a bit cryptic, but doing the following helps: - [ ] Check if the `given-name` and `family-name` keys need updating. If your family name has a name particle like `von` or `van` or `de`, use the `name-particle` key; if your name has a suffix like `Sr` or `IV`, use `name-suffix`. For details, refer to the schema description: https://github.com/citation-file-format/citation-file-format - [ ] Update the value of the `orcid` key. If you do not have an orcid yet, you can get one here [https://orcid.org/](https://orcid.org/). @@ -14,7 +14,7 @@ It is likely that your `CITATION.cff` currently doesn't pass validation. The err Once you do all the steps above, the `cffconvert` workflow will tell you what content it expected to see in `.zenodo.json`. Copy-paste from the GitHub Action log into a new file `.zenodo.json`. Afterwards, the `cffconvert` GitHub Action should be green. -To help you keep the citation metadata up to date and synchronized, the [`cffconvert`]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) GitHub Action checks the following 6 aspects: +To help you keep the citation metadata up to date and synchronized, the [`cffconvert`]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) GitHub Action checks the following 6 aspects: 1. Whether your repository includes a `CITATION.cff` file. diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md b/{{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md index 30635cbb..fb72b7f3 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/03_readthedocs.md @@ -15,6 +15,6 @@ To host the documentation of this repository please perform the following instru 2. make sure {{ cookiecutter.github_organization }} has been granted access. 3. reload repository list on Read the Docs import page 1. wait for the first build to be completed at -1. check that the link of the documentation badge in the [README.md]({{ cookiecutter.repository }}) works +1. check that the link of the documentation badge in the [README.md]({{ cookiecutter.repository_url }}) works -See [README.dev.md#]({{cookiecutter.repository}}/blob/main/README.dev.md#generating-the-api-docs) how to build documentation site locally. +See [README.dev.md#]({{cookiecutter.repository_url}}/blob/main/README.dev.md#generating-the-api-docs) how to build documentation site locally. diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md b/{{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md index a0c81a8b..45ecb639 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/04_zenodo_integration.md @@ -8,7 +8,7 @@ To enable Zenodo integration: 1. Go to http://zenodo.org and login with your GitHub account. When you are redirected to GitHub, *Authorize application* to give permission to Zenodo to access your account. 1. Go to and enable Zenodo integration of your repository by clicking on `On` toggle button. -2. Your package will get a DOI only after you make a release. Create a new release as described in [README.dev.md]({{cookiecutter.repository}}/blob/main/README.dev.md#33-github) +2. Your package will get a DOI only after you make a release. Create a new release as described in [README.dev.md]({{cookiecutter.repository_url}}/blob/main/README.dev.md#33-github) 3. At this point you should have a DOI. To find out the DOI generated by Zenodo: 1. Visit https://zenodo.org/deposit and click on your repository link 2. You will find the latest DOI in the right column in Versions box in **Cite all versions?** section diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md index 471a09b4..45ad770c 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md @@ -2,9 +2,9 @@ title: 'Next step: Linting' --- -Your repository has a [workflow]({{ cookiecutter.repository }}/blob/main/.github/workflows/build.yml) which [lints](https://en.wikipedia.org/wiki/Lint_(software)) your code after every push and when creating a pull request. +Your repository has a [workflow]({{ cookiecutter.repository_url }}/blob/main/.github/workflows/build.yml) which [lints](https://en.wikipedia.org/wiki/Lint_(software)) your code after every push and when creating a pull request. -Linter workflow may fail if `description` or `keywords` field in [setup.cfg]({{ cookiecutter.repository }}/blob/main/setup.cfg) is empty. Please update these fields. To validate your changes run: +Linter workflow may fail if `description` or `keywords` field in [setup.cfg]({{ cookiecutter.repository_url }}/blob/main/setup.cfg) is empty. Please update these fields. To validate your changes run: ```shell ruff . diff --git a/{{cookiecutter.directory_name}}/CITATION.cff b/{{cookiecutter.directory_name}}/CITATION.cff index 6fa1c14a..88cb9c25 100644 --- a/{{cookiecutter.directory_name}}/CITATION.cff +++ b/{{cookiecutter.directory_name}}/CITATION.cff @@ -10,7 +10,7 @@ authors: date-released: 20??-MM-DD doi: version: "{{ cookiecutter.version }}" -repository-code: "{{ cookiecutter.repository }}" +repository-code: "{{ cookiecutter.repository_url }}" keywords: - {{ cookiecutter.keyword1 }} - {{ cookiecutter.keyword2 }} diff --git a/{{cookiecutter.directory_name}}/CONTRIBUTING.md b/{{cookiecutter.directory_name}}/CONTRIBUTING.md index 2cf3cdd1..560a32ea 100644 --- a/{{cookiecutter.directory_name}}/CONTRIBUTING.md +++ b/{{cookiecutter.directory_name}}/CONTRIBUTING.md @@ -13,13 +13,13 @@ The sections below outline the steps in each case. ## You have a question -1. use the search functionality [here]({{cookiecutter.repository}}/issues) to see if someone already filed the same issue; +1. use the search functionality [here]({{cookiecutter.repository_url}}/issues) to see if someone already filed the same issue; 2. if your issue search did not yield any relevant results, make a new issue; 3. apply the "Question" label; apply other labels when relevant. ## You think you may have found a bug -1. use the search functionality [here]({{cookiecutter.repository}}/issues) to see if someone already filed the same issue; +1. use the search functionality [here]({{cookiecutter.repository_url}}/issues) to see if someone already filed the same issue; 1. if your issue search did not yield any relevant results, make a new issue, making sure to provide enough information to the rest of the community to understand the cause and context of the problem. Depending on the issue, you may want to include: - the [SHA hashcode](https://help.github.com/articles/autolinked-references-and-urls/#commit-shas) of the commit that is causing your problem; - some identifying information (name and version number) for dependencies you're using; diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 839a4a0f..7217de9b 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -203,4 +203,4 @@ twine upload dist/* ### (3/3) GitHub -Don't forget to also make a [release on GitHub]({{cookiecutter.repository}}/releases/new). If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it. +Don't forget to also make a [release on GitHub]({{cookiecutter.repository_url}}/releases/new). If your repository uses the GitHub-Zenodo integration this will also trigger Zenodo into making a snapshot of your repository and sticking a DOI on it. diff --git a/{{cookiecutter.directory_name}}/README.md b/{{cookiecutter.directory_name}}/README.md index 30d5ce1e..0e5e2918 100644 --- a/{{cookiecutter.directory_name}}/README.md +++ b/{{cookiecutter.directory_name}}/README.md @@ -4,8 +4,8 @@ | fair-software.eu recommendations | | | :-- | :-- | -| (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)]({{cookiecutter.repository}}) | -| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{cookiecutter.github_organization}}/{{cookiecutter.directory_name}})]({{cookiecutter.repository}}) | +| (1/5) code repository | [![github repo badge](https://img.shields.io/badge/github-repo-000.svg?logo=github&labelColor=gray&color=blue)]({{cookiecutter.repository_url}}) | +| (2/5) license | [![github license badge](https://img.shields.io/github/license/{{cookiecutter.github_organization}}/{{cookiecutter.directory_name}})]({{cookiecutter.repository_url}}) | | (3/5) community registry | [![RSD](https://img.shields.io/badge/rsd-{{cookiecutter.package_name}}-00a3e3.svg)](https://www.research-software.nl/software/{{cookiecutter.package_name}}) [![workflow pypi badge](https://img.shields.io/pypi/v/{{cookiecutter.package_name}}.svg?colorB=blue)](https://pypi.python.org/project/{{cookiecutter.package_name}}/) | | (4/5) citation | [![DOI](https://zenodo.org/badge/DOI/.svg)](https://doi.org/) | | (5/5) checklist | [![workflow cii badge](https://bestpractices.coreinfrastructure.org/projects//badge)](https://bestpractices.coreinfrastructure.org/projects/) | @@ -15,10 +15,10 @@ | Coverage | [![workflow scc badge](https://sonarcloud.io/api/project_badges/measure?project={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}&metric=coverage)](https://sonarcloud.io/dashboard?id={{cookiecutter.github_organization}}_{{cookiecutter.directory_name}}) | | Documentation | [![Documentation Status](https://readthedocs.org/projects/{{cookiecutter.directory_name}}/badge/?version=latest)](https://{{cookiecutter.directory_name}}.readthedocs.io/en/latest/?badge=latest) | | **GitHub Actions** |   | -| Build | [![build]({{cookiecutter.repository}}/actions/workflows/build.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/build.yml) | -| Citation data consistency | [![cffconvert]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/cffconvert.yml) | -| SonarCloud | [![sonarcloud]({{cookiecutter.repository}}/actions/workflows/sonarcloud.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/sonarcloud.yml) | -| MarkDown link checker | [![markdown-link-check]({{cookiecutter.repository}}/actions/workflows/markdown-link-check.yml/badge.svg)]({{cookiecutter.repository}}/actions/workflows/markdown-link-check.yml) | +| Build | [![build]({{cookiecutter.repository_url}}/actions/workflows/build.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/build.yml) | +| Citation data consistency | [![cffconvert]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) | +| SonarCloud | [![sonarcloud]({{cookiecutter.repository_url}}/actions/workflows/sonarcloud.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/sonarcloud.yml) | +| MarkDown link checker | [![markdown-link-check]({{cookiecutter.repository_url}}/actions/workflows/markdown-link-check.yml/badge.svg)]({{cookiecutter.repository_url}}/actions/workflows/markdown-link-check.yml) | ## How to use {{ cookiecutter.package_name }} diff --git a/{{cookiecutter.directory_name}}/next_steps.md b/{{cookiecutter.directory_name}}/next_steps.md index 253814d7..c9710c54 100644 --- a/{{cookiecutter.directory_name}}/next_steps.md +++ b/{{cookiecutter.directory_name}}/next_steps.md @@ -35,7 +35,7 @@ git push --set-upstream origin main ## Check automatically generated issues A short while after you push your commits to GitHub for the first time, a few issues outlining next steps will added -automatically ([here]({{cookiecutter.repository}}/issues?q=author%3Aapp%2Fgithub-actions)). Resolve them to complete the +automatically ([here]({{cookiecutter.repository_url}}/issues?q=author%3Aapp%2Fgithub-actions)). Resolve them to complete the setup of your repository. ## Project development documentation diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 4e50c29d..f29a49b1 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -1,7 +1,70 @@ +# see documentation, e.g. +# - https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#declaring-project-metadata +# - https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +# - https://www.python.org/dev/peps/pep-0621/ + [build-system] -requires = ["setuptools", "wheel"] +requires = ["setuptools>=64.0.0", "setuptools-scm", "wheel"] build-backend = "setuptools.build_meta" +[project] +authors = [ + { name = "{{ cookiecutter.full_name }}", email = "{{ cookiecutter.email }}" } +] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "{{ {'Apache Software License 2.0': 'License :: OSI Approved :: Apache Software License', + 'MIT license': 'License :: OSI Approved :: MIT License', + 'BSD license': 'License :: OSI Approved :: BSD License', + 'ISC license': 'License :: OSI Approved :: ISC License (ISCL)', + 'GNU General Public License v3 or later': 'License :: OSI Approved :: GNU General Public License', + 'Not open source': 'License :: Other/Proprietary License' + }[cookiecutter.license] }}", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [] +description = "{{ cookiecutter.package_short_description }}" +keywords = [ + "{{ cookiecutter.keyword1 }}", + "{{ cookiecutter.keyword2 }}", +] +license = {file = "LICENSE"} +name = "{{ cookiecutter.package_name }}" +readme = {file = "README.md", content-type = "text/markdown"} +requires-python = ">=3.7" +version = "{{ cookiecutter.version }}" + +[project.optional-dependencies] +dev = [ + "build", + "bump2version", + "coverage [toml]", + "pytest", + "pytest-cov", + "ruff", + "sphinx", + "sphinx_rtd_theme", + "sphinx-autoapi", + "tox", + "myst_parser", +] +publishing = [ + "twine", + "wheel", +] + +[project.urls] +Repository = "{{ cookiecutter.repository_url }}" +Issues = "{{ cookiecutter.repository_url }}/issues" +Changelog = "{{ cookiecutter.repository_url }}/CHANGELOG.md" + [tool.pytest.ini_options] testpaths = ["tests"] @@ -10,6 +73,19 @@ branch = true source = ["{{ cookiecutter.package_name }}"] command_line = "-m pytest" +[tool.isort] +lines_after_imports = 2 +force_single_line = 1 +no_lines_before = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] +known_first_party = "{{ cookiecutter.package_name }}" +src_paths = ["{{ cookiecutter.package_name }}", "tests"] +line_length = 120 + +# For completeness, until we move to an src-based layout +[tool.setuptools.packages.find] +include = ["{{ cookiecutter.package_name }}*"] +exclude = ["tests*"] + [tool.tox] legacy_tox_ini = """ [tox] diff --git a/{{cookiecutter.directory_name}}/setup.cfg b/{{cookiecutter.directory_name}}/setup.cfg deleted file mode 100644 index d623faa8..00000000 --- a/{{cookiecutter.directory_name}}/setup.cfg +++ /dev/null @@ -1,67 +0,0 @@ -# see documentation, e.g. -# - https://packaging.python.org/tutorials/packaging-projects/#configuring-metadata -# - https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html -# - https://www.python.org/dev/peps/pep-0314/ - -[metadata] -author = {{ cookiecutter.full_name }} -author_email = {{ cookiecutter.email }} -classifiers = - Development Status :: 2 - Pre-Alpha - Intended Audience :: Developers - {{ {"Apache Software License 2.0": "License :: OSI Approved :: Apache Software License", - "MIT license": "License :: OSI Approved :: MIT License", - "BSD license": "License :: OSI Approved :: BSD License", - "ISC license": "License :: OSI Approved :: ISC License (ISCL)", - "GNU General Public License v3 or later": "License :: OSI Approved :: GNU General Public License", - "Not open source": "License :: Other/Proprietary License" - }[cookiecutter.license] }} - Natural Language :: English - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 -description = {{ cookiecutter.package_short_description }} -keywords = - {{ cookiecutter.keyword1 }} - {{ cookiecutter.keyword2 }} -long_description = file: README.md -long_description_content_type = text/markdown -name = {{ cookiecutter.package_name }} -project_urls = - Bug Tracker = {{ cookiecutter.repository }}/issues -url = {{ cookiecutter.repository }} -version = {{ cookiecutter.version }} - -[options] -zip_safe = False -python_requires = >=3.7 -include_package_data = True -packages = find: -install_requires = - -[options.data_files] -# This section requires setuptools>=40.6.0 -# It remains empty for now -# Check if MANIFEST.in works for your purposes - -[options.extras_require] -dev = - bump2version - coverage [toml] - ruff - pytest - pytest-cov - sphinx - sphinx_rtd_theme - sphinx-autoapi - tox - myst_parser -publishing = - twine - wheel - -[options.packages.find] -include = {{ cookiecutter.package_name }}, {{ cookiecutter.package_name }}.* diff --git a/{{cookiecutter.directory_name}}/setup.py b/{{cookiecutter.directory_name}}/setup.py deleted file mode 100644 index 3bac968b..00000000 --- a/{{cookiecutter.directory_name}}/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python -from setuptools import setup - -# see setup.cfg -setup() diff --git a/{{cookiecutter.directory_name}}/sonar-project.properties b/{{cookiecutter.directory_name}}/sonar-project.properties index c9c07032..02e14401 100644 --- a/{{cookiecutter.directory_name}}/sonar-project.properties +++ b/{{cookiecutter.directory_name}}/sonar-project.properties @@ -3,10 +3,10 @@ sonar.projectKey={{ cookiecutter.github_organization }}_{{ cookiecutter.director sonar.host.url=https://sonarcloud.io sonar.sources={{ cookiecutter.package_name }}/ sonar.tests=tests/ -sonar.links.homepage={{ cookiecutter.repository }} +sonar.links.homepage={{ cookiecutter.repository_url }} sonar.links.scm={{ cookiecutter.repository }} -sonar.links.issue={{ cookiecutter.repository }}/issues -sonar.links.ci={{ cookiecutter.repository }}/actions +sonar.links.issue={{ cookiecutter.repository_url }}/issues +sonar.links.ci={{ cookiecutter.repository_url }}/actions sonar.python.coverage.reportPaths=coverage.xml sonar.python.xunit.reportPath=xunit-result.xml sonar.python.pylint.reportPaths=pylint-report.txt From 53a6999d7e699176d949045abe60132795de3ad7 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 17 Oct 2023 19:53:02 +0200 Subject: [PATCH 111/144] make bumpversion check pyproject.toml instead of setup.cfg --- tests/test_project.py | 4 ++-- {{cookiecutter.directory_name}}/.bumpversion.cfg | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index c1a00c8f..f7715058 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -172,7 +172,7 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir): bin_dir = project_env_bin_dir original_version = '0.1.0' - assert original_version in (project_dir / 'setup.cfg').read_text('utf-8') + assert original_version in (project_dir / 'pyproject.toml').read_text('utf-8') assert original_version in (project_dir / 'CITATION.cff').read_text('utf-8') assert original_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8') assert original_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8') @@ -181,7 +181,7 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir): assert result.returncode == 0 assert '' in result.stdout expected_version = '1.0.0' - assert expected_version in (project_dir / 'setup.cfg').read_text('utf-8') + assert expected_version in (project_dir / 'pyproject.toml').read_text('utf-8') assert expected_version in (project_dir / 'CITATION.cff').read_text('utf-8') assert expected_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8') assert expected_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8') diff --git a/{{cookiecutter.directory_name}}/.bumpversion.cfg b/{{cookiecutter.directory_name}}/.bumpversion.cfg index 16899b5e..f39a78cb 100644 --- a/{{cookiecutter.directory_name}}/.bumpversion.cfg +++ b/{{cookiecutter.directory_name}}/.bumpversion.cfg @@ -8,9 +8,9 @@ comment = The contents of this file cannot be merged with that of setup.cfg unti search = __version__ = "{current_version}" replace = __version__ = "{new_version}" -[bumpversion:file:setup.cfg] -search = version = {current_version} -replace = version = {new_version} +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" [bumpversion:file:CITATION.cff] search = version: "{current_version}" From 3d9889c07d615b0777298bd990edfbb4c7171374 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 17 Oct 2023 20:29:21 +0200 Subject: [PATCH 112/144] remove setup.py reference from subpackages test --- tests/test_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_project.py b/tests/test_project.py index f7715058..5fe61098 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -93,7 +93,7 @@ def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): # sdist and bdist_wheel both call build command to create build/ dir # So instead of looking in distribution archives we can look in build/ dir - result = run([f'{bin_dir}python', 'setup.py', 'build'], project_dir) + result = run([f'{bin_dir}python', '-m', 'build', '--sdist', '--wheel'], project_dir) assert result.returncode == 0 assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / '__init__.py').exists() assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / 'mysub2' / '__init__.py').exists() From dd78c843b416e1832be8f7cbcea82afcec7a786e Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Thu, 19 Oct 2023 14:30:32 +0200 Subject: [PATCH 113/144] Update supported python versions: -3.7, +3.12 --- .github/workflows/tests.yml | 2 +- setup.cfg | 4 ++-- {{cookiecutter.directory_name}}/.github/workflows/build.yml | 2 +- {{cookiecutter.directory_name}}/project_setup.md | 2 +- {{cookiecutter.directory_name}}/pyproject.toml | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b973dc16..52fb690d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/setup.cfg b/setup.cfg index 16dedae2..5aef0661 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,11 +12,11 @@ classifiers = License :: OSI Approved :: Apache Software License Natural Language :: English Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 description = Cookiecutter template to initialize Python projects in accordance with Netherlands eScience Center best practices long_description = file: README.md long_description_content_type = text/markdown @@ -30,7 +30,7 @@ version = 0.4.0 [options] zip_safe = False include_package_data = True -python_requires = >=3.7 +python_requires = >=3.8 packages = install_requires = cookiecutter==1.7.2 diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 80ec495f..8b9e6e74 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ '{{ ' -}} matrix.python-version }} diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 127d86a6..1649f736 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -11,11 +11,11 @@ checklist](https://guide.esciencecenter.nl/#/best_practices/checklist). This repository is set up with Python versions: -- 3.7 - 3.8 - 3.9 - 3.10 - 3.11 +- 3.12 Add or remove Python versions based on project requirements. See [the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python) for more information about Python diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index f29a49b1..bb0e0235 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -23,11 +23,11 @@ classifiers = [ }[cookiecutter.license] }}", "Natural Language :: English", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dependencies = [] description = "{{ cookiecutter.package_short_description }}" @@ -38,7 +38,7 @@ keywords = [ license = {file = "LICENSE"} name = "{{ cookiecutter.package_name }}" readme = {file = "README.md", content-type = "text/markdown"} -requires-python = ">=3.7" +requires-python = ">=3.8" version = "{{ cookiecutter.version }}" [project.optional-dependencies] @@ -89,7 +89,7 @@ exclude = ["tests*"] [tool.tox] legacy_tox_ini = """ [tox] -envlist = py37,py38,py39,py310,py311 +envlist = py38,py39,py310,py311,py312 skip_missing_interpreters = true [testenv] commands = pytest From 88934791433c7f36e9709d2f9ff23c43f678e757 Mon Sep 17 00:00:00 2001 From: Patrick Bos Date: Thu, 19 Oct 2023 19:29:51 +0200 Subject: [PATCH 114/144] fix broken link Fixes #354 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df725406..2e3095bc 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ an empty Python package. Features include: - [Contributing guidelines]({{cookiecutter.directory_name}}/CONTRIBUTING.md), - Continuous code quality and code coverage reporting using [Sonarcloud](https://sonarcloud.io/), - Automatic creation of [issues]({{cookiecutter.directory_name}}/.github/next_steps) with instructions how to pass all GitHub action workflows and integrate with services like Zenodo and Read the Docs, -- Instructions how to make package [citable]({{cookiecutter.directory_name}}/.github/next_steps/04_citation.md) +- Instructions how to make package [citable]({{cookiecutter.directory_name}}/.github/next_steps/02_citation.md) - FAIR software recommendation badge, - Optional [pre commit hook]({{cookiecutter.directory_name}}/README.dev.md#running-linters-locally) to catch lint errors early From 2013c2f4fd52fec097fdab391c35c26807292005 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Fri, 20 Oct 2023 12:45:03 +0200 Subject: [PATCH 115/144] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce983e5f..e26844af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added +* Added Python 3.12 support [#356](https://github.com/NLeSC/python-template/issues/356) * Template unit tests for documentation generation, linting and version bumping * Docstring for function * Intersphinx to documentation @@ -27,6 +28,7 @@ ### Removed +* Removed Python 3.7 support [#343](https://github.com/NLeSC/python-template/issues/343) * `.pylintrc` file, was too strict, too soon [#267](https://github.com/NLeSC/python-template/issues/267) * Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md From 375ea621828c235f8c67f43176750ed68b8b1ff9 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Thu, 19 Oct 2023 19:47:54 +0200 Subject: [PATCH 116/144] small fixup of #352 This commit changed the test_subpackage build command, but left the now unnecessary '--sdist' and '--wheel' parameters. They are on by default for `python -m build` --- tests/test_project.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 5fe61098..42bc02d3 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -80,7 +80,7 @@ def test_tox(baked_with_development_dependencies, project_env_bin_dir): def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): - """Test if subpackages end up in sdist and bdist_wheel distributions""" + """Test if subpackages end up in (wheel) distributions""" project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir subpackage = (project_dir / 'my_python_package' / 'mysub') @@ -91,9 +91,14 @@ def test_subpackage(baked_with_development_dependencies, project_env_bin_dir): subsubpackage.mkdir() (subsubpackage / '__init__.py').write_text('FOO = "bar"\n', encoding="utf-8") - # sdist and bdist_wheel both call build command to create build/ dir - # So instead of looking in distribution archives we can look in build/ dir - result = run([f'{bin_dir}python', '-m', 'build', '--sdist', '--wheel'], project_dir) + # Note: we pass --wheel explicitly, because wheel has a useful side-effect + # of leaving a build directory after building that we can check for its + # contents in the asserts below. However, be aware that this behavior is + # not guaranteed to stay and is in fact a known bug / PEP-violation! + # See https://github.com/pypa/wheel/issues/447. Also, by passing --wheel + # explicitly (although by default build already builds a wheel as well), + # we omit the sdist being built, saving some seconds. + result = run([f'{bin_dir}python', '-m', 'build', '--wheel'], project_dir) assert result.returncode == 0 assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / '__init__.py').exists() assert (project_dir / 'build' / 'lib' / 'my_python_package' / 'mysub' / 'mysub2' / '__init__.py').exists() From e24c0aa1340bd401f309ad9eb3cc97db429032b1 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Fri, 20 Oct 2023 13:23:19 +0200 Subject: [PATCH 117/144] switch to python -m build --- README.md | 2 -- .../.github/workflows/build.yml | 2 +- {{cookiecutter.directory_name}}/README.dev.md | 32 ++++++------------- .../pyproject.toml | 3 +- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 2e3095bc..d70b7d73 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,6 @@ my-python-project/ ├── pyproject.toml ├── README.dev.md ├── README.md -├── setup.cfg -├── setup.py ├── sonar-project.properties └── tests ├── __init__.py diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 80ec495f..b2e166db 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: - name: Run unit tests run: python -m pytest -v - name: Verify that we can build the package - run: python setup.py sdist bdist_wheel + run: python -m build lint: name: Linting build diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 7217de9b..921634c0 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -138,35 +138,23 @@ This section describes how to make a release in 3 parts: ### (2/3) PyPI -In a new terminal, without an activated virtual environment or an env directory: +In a new terminal: ```shell -# prepare a new directory +# OPTIONAL: prepare a new directory with fresh git clone to ensure the release +# has the state of origin/main branch cd $(mktemp -d {{ cookiecutter.package_name }}.XXXXXX) - -# fresh git clone ensures the release has the state of origin/main branch git clone {{ cookiecutter.repository }} . -# prepare a clean virtual environment and activate it -python -m venv env -source env/bin/activate - -# make sure to have a recent version of pip and setuptools -python -m pip install --upgrade pip setuptools - -# install runtime dependencies and publishing dependencies -python -m pip install --no-cache-dir . -python -m pip install --no-cache-dir .[publishing] - -# clean up any previously generated artefacts -rm -rf {{ cookiecutter.package_name }}.egg-info -rm -rf dist +# make sure to have a recent version of pip and the publishing dependencies +python -m pip install --upgrade pip +python -m pip install .[publishing] # create the source distribution and the wheel -python setup.py sdist bdist_wheel +python -m build # upload to test pypi instance (requires credentials) -twine upload --repository-url https://test.pypi.org/legacy/ dist/* +python -m twine upload --repository testpypi dist/* ``` Visit @@ -183,7 +171,7 @@ python -m venv env source env/bin/activate # make sure to have a recent version of pip and setuptools -python -m pip install --upgrade pip setuptools +python -m pip install --upgrade pip # install from test pypi instance: python -m pip -v install --no-cache-dir \ @@ -198,7 +186,7 @@ Then upload to pypi.org with: ```shell # Back to the first terminal, # FINAL STEP: upload to PyPI (requires credentials) -twine upload dist/* +python -m twine upload dist/* ``` ### (3/3) GitHub diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index f29a49b1..7c216c7f 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -43,7 +43,7 @@ version = "{{ cookiecutter.version }}" [project.optional-dependencies] dev = [ - "build", + "build", # build is not only used in publishing (below), but also in the template's test suite "bump2version", "coverage [toml]", "pytest", @@ -56,6 +56,7 @@ dev = [ "myst_parser", ] publishing = [ + "build", "twine", "wheel", ] From 0635bcdd521a61a6459e5bd592bde423c5d70b4a Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Fri, 20 Oct 2023 13:24:14 +0200 Subject: [PATCH 118/144] use setup-python@v3 action in documentation workflow For some reason, we use setup-python@v3 in all workflows, except the documentation one, which still had v2. --- .../.github/workflows/documentation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml index 4338910e..2bccfd13 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Python 3.9 - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.9 - name: Python info From 568b05ba53d2764dc514e0ee698ec2e327aa787f Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 20 Nov 2023 10:48:55 +0100 Subject: [PATCH 119/144] Remove remaining setup.cfg references There is still one reference remaining in .bumpversion.cfg, but issue #362 should be resolved before we can effectively remove that one. --- .../.github/next_steps/05_linting.md | 2 +- {{cookiecutter.directory_name}}/project_setup.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md index 45ad770c..cc603833 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/05_linting.md @@ -4,7 +4,7 @@ title: 'Next step: Linting' Your repository has a [workflow]({{ cookiecutter.repository_url }}/blob/main/.github/workflows/build.yml) which [lints](https://en.wikipedia.org/wiki/Lint_(software)) your code after every push and when creating a pull request. -Linter workflow may fail if `description` or `keywords` field in [setup.cfg]({{ cookiecutter.repository_url }}/blob/main/setup.cfg) is empty. Please update these fields. To validate your changes run: +Linter workflow may fail if `description` or `keywords` field in [pyproject.toml]({{ cookiecutter.repository_url }}/blob/main/pyproject.toml) is empty. Please update these fields. To validate your changes run: ```shell ruff . diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 1649f736..8fdbf182 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -28,8 +28,8 @@ to use one or the other, as project requirements differ. For advice on what to u of the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=dependencies-and-package-management). -- Runtime dependencies should be added to `setup.cfg` in the `install_requires` list under `[options]`. -- Development dependencies should be added to `setup.cfg` in one of the lists under `[options.extras_require]`. +- Runtime dependencies should be added to `pyproject.toml` in the `dependencies` list under `[project]`. +- Development dependencies should be added to `pyproject.toml` in one of the lists under `[project.optional-dependencies]`. ## Packaging/One command install @@ -45,7 +45,7 @@ help you decide which tool to use for packaging. - The testing framework used is [PyTest](https://pytest.org) - [PyTest introduction](https://pythontest.com/pytest-book/) - PyTest is listed as a development dependency - - This is configured in `setup.cfg` + - This is configured in `pyproject.toml` - The project uses [GitHub action workflows](https://docs.github.com/en/actions) to automatically run tests on GitHub infrastructure against multiple Python versions - Workflows can be found in [`.github/workflows`](.github/workflows/) - [Relevant section in the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=testing) From b2d506b19f52b3d6520610a61dc8fa80839c7a8f Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Wed, 20 Dec 2023 15:28:56 +0100 Subject: [PATCH 120/144] switch from bump2version to bump-my-version bump2version is no longer maintained and suggests using bump-my-version instead. This also allows to put the configuration in pyproject.toml and simplify it at the same time. --- CHANGELOG.md | 1 + README.dev.md | 2 +- README.md | 5 ++--- tests/test_project.py | 2 +- .../.bumpversion.cfg | 21 ------------------- {{cookiecutter.directory_name}}/README.dev.md | 8 +++---- .../project_setup.md | 2 +- .../pyproject.toml | 17 ++++++++++++++- 8 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 {{cookiecutter.directory_name}}/.bumpversion.cfg diff --git a/CHANGELOG.md b/CHANGELOG.md index e26844af..5787702d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ * Use bumpversion for version in Sphinx config [#44](https://github.com/NLeSC/python-template/issues/44) * Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions [#44](https://github.com/NLeSC/python-template/issues/44) * Generate api rst files with extension instead of custom function [#95](https://github.com/NLeSC/python-template/issues/95) +* Change from bump2version (unmaintained) to bump-my-version. ### Removed diff --git a/README.dev.md b/README.dev.md index c7bc7c99..7bdcd553 100644 --- a/README.dev.md +++ b/README.dev.md @@ -82,7 +82,7 @@ In addition to the information in `my-python-project/project_setup.md`, the deve 1. generating `my-python-project`'s documentation locally 1. running `my-python-project`'s tests locally 1. running `my-python-project`'s linters locally -1. verifying that the `my-python-project`'s version can be updated using `bumpversion` +1. verifying that the `my-python-project`'s version can be updated using `bump-my-version` 1. making a release of `my-python-project` on https://test.pypi.org/ Follow the instructions from `my-python-project/README.dev.md` and make sure that everything works. diff --git a/README.md b/README.md index d70b7d73..d2605527 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Use this [Cookiecutter](https://cookiecutter.readthedocs.io) template to generat an empty Python package. Features include: - Boilerplate unit tests and documentation, -- [Python static setup configuration]({{cookiecutter.directory_name}}/setup.cfg), +- [Python static setup configuration]({{cookiecutter.directory_name}}/pyproject.toml), - Open source software license, - Continuous integration with [GitHub action workflows]({{cookiecutter.directory_name}}/.github/workflows) for building, testing, link checking and linting, - Code style checking with [ruff](https://beta.ruff.rs/), @@ -69,7 +69,7 @@ cookiecutter https://github.com/nlesc/python-template.git | ------------------------- | ------------- | ----------- | | directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. To get an impression of what will be generated, see the directory tree [below](https://github.com/NLeSC/python-template#step-33-read-about-what-was-just-generated) | | package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. | -| package_short_description | Short description of package | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. | +| package_short_description | Short description of package | The information that you enter here will end up in the README, documentation, license, and pyproject.toml, so it may be a good idea to prepare something in advance. | | keyword1 | keyword1 | A term that describes your package. | | keyword2 | keyword2 | Another term that describes your package. | | version | 0.1.0 |   | @@ -89,7 +89,6 @@ Good job! You have now generated the skeleton for your package: ```text my-python-project/ -├── .bumpversion.cfg ├── CHANGELOG.md ├── CITATION.cff ├── CODE_OF_CONDUCT.md diff --git a/tests/test_project.py b/tests/test_project.py index 42bc02d3..399dd799 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -182,7 +182,7 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir): assert original_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8') assert original_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8') - result = run([f'{bin_dir}bumpversion', 'major'], project_dir) + result = run([f'{bin_dir}bump-my-version', 'major'], project_dir) assert result.returncode == 0 assert '' in result.stdout expected_version = '1.0.0' diff --git a/{{cookiecutter.directory_name}}/.bumpversion.cfg b/{{cookiecutter.directory_name}}/.bumpversion.cfg deleted file mode 100644 index f39a78cb..00000000 --- a/{{cookiecutter.directory_name}}/.bumpversion.cfg +++ /dev/null @@ -1,21 +0,0 @@ -[bumpversion] -current_version = {{ cookiecutter.version }} - -[comment] -comment = The contents of this file cannot be merged with that of setup.cfg until https://github.com/c4urself/bump2version/issues/185 is resolved - -[bumpversion:file:{{ cookiecutter.package_name }}/__init__.py] -search = __version__ = "{current_version}" -replace = __version__ = "{new_version}" - -[bumpversion:file:pyproject.toml] -search = version = "{current_version}" -replace = version = "{new_version}" - -[bumpversion:file:CITATION.cff] -search = version: "{current_version}" -replace = version: "{new_version}" - -[bumpversion:file:docs/conf.py] -search = version = "{current_version}" -replace = version = "{new_version}" diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index 921634c0..a408bdb0 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -113,12 +113,12 @@ make doctest ## Versioning -Bumping the version across all files is done with [bumpversion](https://github.com/c4urself/bump2version), e.g. +Bumping the version across all files is done with [bump-my-version](https://github.com/callowayproject/bump-my-version), e.g. ```shell -bumpversion major -bumpversion minor -bumpversion patch +bump-my-version major # bumps from e.g. 0.3.2 to 1.0.0 +bump-my-version minor # bumps from e.g. 0.3.2 to 0.4.0 +bump-my-version patch # bumps from e.g. 0.3.2 to 0.3.3 ``` ## Making a release diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 8fdbf182..91ce36df 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -76,7 +76,7 @@ help you decide which tool to use for packaging. ## Package version number - We recommend using [semantic versioning](https://guide.esciencecenter.nl/#/best_practices/releases?id=semantic-versioning). -- For convenience, the package version is stored in a single place: `{{ cookiecutter.directory_name }}/.bumpversion.cfg`. +- For convenience, the package version is stored in a single place: `{{ cookiecutter.directory_name }}/pyproject.toml` under the `tool.bumpversion` header. - Don't forget to update the version number before [making a release](https://guide.esciencecenter.nl/#/best_practices/releases)! ## Logging diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 595f593f..1303b044 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -44,7 +44,7 @@ version = "{{ cookiecutter.version }}" [project.optional-dependencies] dev = [ "build", # build is not only used in publishing (below), but also in the template's test suite - "bump2version", + "bump-my-version", "coverage [toml]", "pytest", "pytest-cov", @@ -171,3 +171,18 @@ line-length = 120 known-first-party = ["{{ cookiecutter.package_name }}"] force-single-line = true no-lines-before = ["future","standard-library","third-party","first-party","local-folder"] + +[tool.bumpversion] +current_version = "{{ cookiecutter.version }}" + +[[tool.bumpversion.files]] +filename = "{{ cookiecutter.package_name }}/__init__.py" + +[[tool.bumpversion.files]] +filename = "pyproject.toml" + +[[tool.bumpversion.files]] +filename = "CITATION.cff" + +[[tool.bumpversion.files]] +filename = "docs/conf.py" From 629b297b5da667dabf0b05a30497018dc67526b9 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Wed, 20 Dec 2023 17:25:56 +0100 Subject: [PATCH 121/144] add link to impact discussion This way, we can close the issue, but still have a convenient link to the discussion to revisit the list when necessary. The process to update the list described there is given by @eriktks: > Lists of repositories using this Python template on 13 April 2021 based on searching Github: https://github.com/search?p=2&q=nlesc+cookiecutter&type=Code (the search finds several other irrelevant pages). Lists expanded on 4 May 2021 with ten more repositories from among others https://github.com/search?p=6&q=%22Relevant+section+in+the+guide%22&type=Code --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d2605527..b48dc112 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ list below: 1. pycff: [https://github.com/citation-file-format/pycff](https://github.com/citation-file-format/pycff) 1. spec2vec: [https://github.com/iomega/spec2vec](https://github.com/iomega/spec2vec) 1. yatiml: [https://github.com/yatiml/yatiml](https://github.com/yatiml/yatiml) -1. _... And many more. Make a PR to add your project here!_ +1. _... And many more (see [this discussion](https://github.com/NLeSC/python-template/issues/48)). Make a PR to add your project here, or simply ping us in an issue!_ ## How to contribute From 25f15b143b9abf59c8998686389b12d6bb31da92 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Wed, 20 Dec 2023 17:35:43 +0100 Subject: [PATCH 122/144] add Science/Research as intended audience Fixes #111. --- {{cookiecutter.directory_name}}/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 1303b044..9dd96e77 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -14,6 +14,7 @@ authors = [ classifiers = [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", + "Intended Audience :: Science/Research", "{{ {'Apache Software License 2.0': 'License :: OSI Approved :: Apache Software License', 'MIT license': 'License :: OSI Approved :: MIT License', 'BSD license': 'License :: OSI Approved :: BSD License', From bba2cc021b19f98fd9967382ecf58909c6ec2366 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Wed, 20 Dec 2023 18:05:42 +0100 Subject: [PATCH 123/144] harmonize CONTRIBUTING.md files in template and generated Also fix a link to a header that no longer existed in the generated project. --- CONTRIBUTING.md | 3 ++- {{cookiecutter.directory_name}}/CONTRIBUTING.md | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e8059802..34fd44c3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,8 @@ The sections below outline the steps in each case. 1. make sure the existing tests still work by running ``pytest``. If project tests fail use ``pytest --keep-baked-projects`` to keep generated project files in `/tmp/pytest-*` and investigate; 1. add your own tests (if necessary); 1. update or expand the documentation; -1. push your feature branch to (your fork of) the Python Template repository on GitHub; +1. update the `CHANGELOG.md` file with your change; +1. [push](http://rogerdudler.github.io/git-guide/) your feature branch to (your fork of) the Python Template repository on GitHub; 1. create the pull request, e.g. following the instructions [here](https://help.github.com/articles/creating-a-pull-request/). In case you feel like you've made a valuable contribution, but you don't know how to write or run tests for it, or how to generate the documentation: don't let this discourage you from making the pull request; we can help you! Just go ahead and submit the pull request, but keep in mind that you might be asked to append additional commits to your pull request. diff --git a/{{cookiecutter.directory_name}}/CONTRIBUTING.md b/{{cookiecutter.directory_name}}/CONTRIBUTING.md index 560a32ea..aba988f5 100644 --- a/{{cookiecutter.directory_name}}/CONTRIBUTING.md +++ b/{{cookiecutter.directory_name}}/CONTRIBUTING.md @@ -30,12 +30,13 @@ The sections below outline the steps in each case. 1. (**important**) announce your plan to the rest of the community *before you start working*. This announcement should be in the form of a (new) issue; 1. (**important**) wait until some kind of consensus is reached about your idea being a good idea; -1. if needed, fork the repository to your own Github profile and create your own feature branch off of the latest master commit. While working on your feature branch, make sure to stay up to date with the master branch by pulling in changes, possibly from the 'upstream' repository (follow the instructions [here](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and [here](https://help.github.com/articles/syncing-a-fork/)); +1. if needed, fork the repository to your own Github profile and create your own feature branch off of the latest main commit. While working on your feature branch, make sure to stay up to date with the main branch by pulling in changes, possibly from the 'upstream' repository (follow the instructions [here](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and [here](https://help.github.com/articles/syncing-a-fork/)); +1. install dependencies (see the [development documentation](README.dev.md#development_install)); 1. make sure the existing tests still work by running ``pytest``; 1. add your own tests (if necessary); 1. update or expand the documentation; -1. update the `CHANGELOG.md` file with change; -1. push your feature branch to (your fork of) the {{ cookiecutter.package_name }} repository on GitHub; +1. update the `CHANGELOG.md` file with your change; +1. [push](http://rogerdudler.github.io/git-guide/) your feature branch to (your fork of) the {{ cookiecutter.package_name }} repository on GitHub; 1. create the pull request, e.g. following the instructions [here](https://help.github.com/articles/creating-a-pull-request/). In case you feel like you've made a valuable contribution, but you don't know how to write or run tests for it, or how to generate the documentation: don't let this discourage you from making the pull request; we can help you! Just go ahead and submit the pull request, but keep in mind that you might be asked to append additional commits to your pull request. From 4c25c48068a3cbe8787f41f2c3eb8d217f03ffd3 Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Fri, 22 Dec 2023 13:54:59 +0100 Subject: [PATCH 124/144] remove .zenodo.json and all references to it CITATION.cff replaces it fully, also for integration with Zenodo. See https://github.com/citation-file-format/citation-file-format/issues/374 or https://twitter.com/zenodo_org/status/1420357001490706442 for more information on this. Concretely, this commit: - Removes .zenodo.json from the template repo - Removes all references to it in README files (also in the package) - Updates the cffconvert GitHub Actions workflow to only validate, whereas previously it also checked the .zenodo.json file for consistency - Simplifies the 02_citation.md "next steps" issue template, because consistency with .zenodo.json no longer has to be checked. --- .zenodo.json | 77 ------------------- CHANGELOG.md | 1 + README.dev.md | 2 +- .../.github/next_steps/02_citation.md | 19 +---- .../.github/workflows/cffconvert.yml | 6 +- {{cookiecutter.directory_name}}/README.dev.md | 2 +- 6 files changed, 9 insertions(+), 98 deletions(-) delete mode 100644 .zenodo.json diff --git a/.zenodo.json b/.zenodo.json deleted file mode 100644 index e76a8287..00000000 --- a/.zenodo.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "creators": [ - { - "affiliation": "Netherlands eScience Center", - "name": "van der Zwaan, Janneke", - "orcid": "0000-0002-8329-7000" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "van Werkhoven, Ben", - "orcid": "0000-0002-7508-3272" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Andela, Bouwe", - "orcid": "0000-0001-9005-8940" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Bos, Patrick", - "orcid": "0000-0002-6033-960X" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Attema, Jisk", - "orcid": "0000-0002-0948-1176" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Bakker, Tom" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Spaaks, Jurriaan H.", - "orcid": "0000-0002-7064-4069" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "van Kuppevelt, Dafne", - "orcid": "0000-0002-2662-1994" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Veen, Lourens", - "orcid": "0000-0002-6311-1168" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Rol, Evert", - "orcid": "0000-0001-8357-4453" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Verhoeven, Stefan", - "orcid": "0000-0002-5821-2060" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Diblen, Faruk", - "orcid": "0000-0002-0989-929X" - }, - { - "affiliation": "Netherlands eScience Center", - "name": "Tjong Kim Sang, Erik", - "orcid": "0000-0002-8431-081X" - } - ], - "keywords": [ - "cookiecutter", - "template", - "Python" - ], - "license": { - "id": "Apache-2.0" - }, - "title": "Netherlands eScience Center Python Template" -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 5787702d..949c3856 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ * `.pylintrc` file, was too strict, too soon [#267](https://github.com/NLeSC/python-template/issues/267) * Unused development dependencies [#167](https://github.com/NLeSC/python-template/issues/167) * Statements in project_setup.md already mentioned in README.dev.md +* .zenodo.json is no longer necessary, CITATION.cff also works with Zenodo. ## 0.4.0 diff --git a/README.dev.md b/README.dev.md index 7bdcd553..1039a9a9 100644 --- a/README.dev.md +++ b/README.dev.md @@ -92,7 +92,7 @@ Follow the instructions from `my-python-project/README.dev.md` and make sure tha ### Preparation 1. Make sure the `CHANGELOG.md` has been updated -2. Verify that the information in `CITATION.cff` is correct, and that `.zenodo.json` contains equivalent data +2. Verify that the information in `CITATION.cff` is correct. 3. Make sure that `version` in [setup.cfg](setup.cfg) and `version` in [CITATION.cff](CITATION.cff) have been bumped to the to-be-released version of the template 4. Run the unit tests with `pytest tests/` 5. Go through the steps outlined above for [generating a new package from the command line](#using-cookiecutter-to-generate-a-new-package-from-the-command-line), and verify that the generated package works as it should. diff --git a/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md b/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md index 8ec08600..7a3279d7 100644 --- a/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md +++ b/{{cookiecutter.directory_name}}/.github/next_steps/02_citation.md @@ -11,10 +11,9 @@ It is likely that your `CITATION.cff` currently doesn't pass validation. The err - [ ] Update the `doi` key with the conceptDOI for your repository (see [https://help.zenodo.org](https://help.zenodo.org/) for more information on what a conceptDOI is). If your project doesn't have a DOI yet, you can use the string `10.0000/FIXME` to pass validation. - [ ] Verify that the `keywords` array accurately describes your project. -Once you do all the steps above, the `cffconvert` workflow will tell you what content it expected to see in `.zenodo.json`. Copy-paste from the GitHub Action log into a new file `.zenodo.json`. Afterwards, the `cffconvert` GitHub Action should be green. +Afterwards, the `cffconvert` GitHub Action should be green. - -To help you keep the citation metadata up to date and synchronized, the [`cffconvert`]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) GitHub Action checks the following 6 aspects: +To make sure services like [Zenodo](https://zenodo.org) and the [Research Software Directory](https://research-software-directory.org/) can keep your citation data up to date, the [`cffconvert`]({{cookiecutter.repository_url}}/actions/workflows/cffconvert.yml) GitHub Action checks the following: 1. Whether your repository includes a `CITATION.cff` file. @@ -27,17 +26,3 @@ To help you keep the citation metadata up to date and synchronized, the [`cffcon 1. Whether your `CITATION.cff` adheres to the schema (as listed in the `CITATION.cff` file itself under key `cff-version`). _The Citation File Format schema can be found [here](https://github.com/citation-file-format/citation-file-format), along with an explanation of all the keys. You're advised to use the latest available schema version._ - -1. Whether your repository includes a `.zenodo.json` file. - - _With this file, you can control what metadata should be associated with any future releases of your software on Zenodo: things like the author names, along with their affiliations and their ORCIDs, the license under which the software has been released, as well as the name of your software and a short description. If your repository doesn't have a .zenodo.json file, Zenodo will take a somewhat crude guess to assign these metadata._ - - _The `cffconvert` GitHub action will tell you what it expects to find in `.zenodo.json`, just copy and paste it to a new file named `.zenodo.json`. The suggested text ignores CITATION.cff's `version`, `commit`, and `date-released`. `cffconvert` considers these keys `suspect` in the sense that they are often out of date, and there is little purpose to telling Zenodo about these properties: Zenodo already knows._ - -1. Whether `.zenodo.json` is valid JSON. - - _Currently unimplemented, but you can check for yourself on [https://jsonlint.com/](https://jsonlint.com/)._ - -1. Whether `CITATION.cff` and `.zenodo.json` contain equivalent data. - - _This final check verifies that the two files are in sync. The check ignores CITATION.cff's `version`, `commit`, and `date-released`._ diff --git a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml index 015d9e3e..c91a4879 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml @@ -17,5 +17,7 @@ jobs: - uses: actions/checkout@v3 name: Check out a copy of the repository - - uses: citation-file-format/cffconvert-github-action@main - name: Check whether the citation metadata from CITATION.cff is equivalent to that in .zenodo.json + - name: Check whether the citation metadata from CITATION.cff is valid + uses: citation-file-format/cffconvert-github-action@2.0.0 + with: + args: "--validate" diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index a408bdb0..fe9b0c5a 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -132,7 +132,7 @@ This section describes how to make a release in 3 parts: ### (1/3) Preparation 1. Update the (don't forget to update links at bottom of page) -2. Verify that the information in `CITATION.cff` is correct, and that `.zenodo.json` contains equivalent data +2. Verify that the information in [`CITATION.cff`](CITATION.cff) is correct. 3. Make sure the [version has been updated](#versioning). 4. Run the unit tests with `pytest -v` From f9dfef53ea4fec2245fdfb8d1abb4b3408bdb57c Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Fri, 22 Dec 2023 14:28:34 +0100 Subject: [PATCH 125/144] add release workflow to CONTRIBUTING.md Both for the template and for the package. Inspired by and fixes #156. --- CONTRIBUTING.md | 14 ++++++++++ .../CONTRIBUTING.md | 26 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 34fd44c3..d3198239 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,3 +39,17 @@ The sections below outline the steps in each case. 1. create the pull request, e.g. following the instructions [here](https://help.github.com/articles/creating-a-pull-request/). In case you feel like you've made a valuable contribution, but you don't know how to write or run tests for it, or how to generate the documentation: don't let this discourage you from making the pull request; we can help you! Just go ahead and submit the pull request, but keep in mind that you might be asked to append additional commits to your pull request. + +## You want to make a new release of the code base + +To create a release you need write permission on the repository. + +1. Check the author list in [`CITATION.cff`](CITATION.cff) +1. Update the version number in setup.cfg and CITATION.cff +1. Update the `CHANGELOG.md` to include changes made +1. Go to the [GitHub release page](https://github.com/nlesc/python-template/releases) +1. Press draft a new release button +1. Fill version, title and description field +1. Press the Publish Release button + +Also a Zenodo entry will be made for the release with its own DOI. \ No newline at end of file diff --git a/{{cookiecutter.directory_name}}/CONTRIBUTING.md b/{{cookiecutter.directory_name}}/CONTRIBUTING.md index aba988f5..c3ec5d42 100644 --- a/{{cookiecutter.directory_name}}/CONTRIBUTING.md +++ b/{{cookiecutter.directory_name}}/CONTRIBUTING.md @@ -40,3 +40,29 @@ The sections below outline the steps in each case. 1. create the pull request, e.g. following the instructions [here](https://help.github.com/articles/creating-a-pull-request/). In case you feel like you've made a valuable contribution, but you don't know how to write or run tests for it, or how to generate the documentation: don't let this discourage you from making the pull request; we can help you! Just go ahead and submit the pull request, but keep in mind that you might be asked to append additional commits to your pull request. + +## You want to make a new release of the code base + +To create a release you need write permission on the repository. + +1. Check the author list in [`CITATION.cff`](CITATION.cff) +1. Bump the version using `bump-my-version bump `. For example, `bump-my-version bump major` will increase major version numbers everywhere it's needed (code, meta, etc.) in the repo. Alternatively the version can be manually changed in {{ cookiecutter.package_name }}/__init__.py, pyproject.toml, CITATION.cff and docs/conf.py (and other places it was possibly added). +1. Update the `CHANGELOG.md` to include changes made +1. Go to the [GitHub release page]({{ cookiecutter.repository_url }}/releases) +1. Press draft a new release button +1. Fill version, title and description field +1. Press the Publish Release button + + + +Also a Zenodo entry will be made for the release with its own DOI. \ No newline at end of file From 3b1c0e53427b43e266ca4be74eb7bf76229caa71 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Wed, 10 Jan 2024 08:56:16 +0100 Subject: [PATCH 126/144] Mention the guide in contribution guidelines and pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 3 +++ CONTRIBUTING.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1ec1eac8..a3db53cd 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,8 @@ **Description** +- [ ] I have read the [contribution guidelines](../CONTRIBUTING.md) +- [ ] This update is in line with what is recommended in the [Python chapter of the Guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python) + From 938be1730b25850808058a4e665ebabcebd42f17 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Mon, 6 May 2024 13:24:54 +0200 Subject: [PATCH 133/144] Add extra optional-dependencies section for documentation requirements --- CHANGELOG.md | 1 + {{cookiecutter.directory_name}}/.readthedocs.yaml | 2 +- {{cookiecutter.directory_name}}/README.dev.md | 2 ++ {{cookiecutter.directory_name}}/project_setup.md | 2 +- {{cookiecutter.directory_name}}/pyproject.toml | 6 ++++++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 949c3856..63ca6faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Docstring for function * Intersphinx to documentation * Coverage and doctest commands for documentation [#97](https://github.com/NLeSC/python-template/issues/97) +* Added new 'docs' section in extra dependencies [#317](https://github.com/NLeSC/python-template/issues/317) ### Changed diff --git a/{{cookiecutter.directory_name}}/.readthedocs.yaml b/{{cookiecutter.directory_name}}/.readthedocs.yaml index 544d704c..b2a53689 100644 --- a/{{cookiecutter.directory_name}}/.readthedocs.yaml +++ b/{{cookiecutter.directory_name}}/.readthedocs.yaml @@ -4,4 +4,4 @@ python: - method: pip path: . extra_requirements: - - dev + - docs diff --git a/{{cookiecutter.directory_name}}/README.dev.md b/{{cookiecutter.directory_name}}/README.dev.md index f74dcfaa..b839f920 100644 --- a/{{cookiecutter.directory_name}}/README.dev.md +++ b/{{cookiecutter.directory_name}}/README.dev.md @@ -19,6 +19,8 @@ python -m pip install --upgrade pip setuptools python -m pip install --no-cache-dir --editable . # install development dependencies python -m pip install --no-cache-dir --editable .[dev] +# install documentation dependencies only +python -m pip install --no-cache-dir --editable .[docs] ``` Afterwards check that the install directory is present in the `PATH` environment variable. diff --git a/{{cookiecutter.directory_name}}/project_setup.md b/{{cookiecutter.directory_name}}/project_setup.md index 91ce36df..3d1b196e 100644 --- a/{{cookiecutter.directory_name}}/project_setup.md +++ b/{{cookiecutter.directory_name}}/project_setup.md @@ -29,7 +29,7 @@ of the guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python?id=dependencies-and-package-management). - Runtime dependencies should be added to `pyproject.toml` in the `dependencies` list under `[project]`. -- Development dependencies should be added to `pyproject.toml` in one of the lists under `[project.optional-dependencies]`. +- Development dependencies, such as for testing or documentation, should be added to `pyproject.toml` in one of the lists under `[project.optional-dependencies]`. ## Packaging/One command install diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 9dd96e77..1dcbc128 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -56,6 +56,12 @@ dev = [ "tox", "myst_parser", ] +docs = [ + "sphinx", + "sphinx_rtd_theme", + "sphinx-autoapi", + "myst_parser", +] publishing = [ "build", "twine", From 3616e1464644c23888f4e0c0c1d3ec75709c95b2 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Tue, 7 May 2024 09:14:43 +0200 Subject: [PATCH 134/144] Fix broken link to contribution guidelines in pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 621b0f93..72624dc3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ **Description** -- [ ] I have read the [contribution guidelines](../CONTRIBUTING.md) +- [ ] I have read the [contribution guidelines](https://github.com/NLeSC/python-template/blob/main/CONTRIBUTING.md) - [ ] This update is in line with what is recommended in the [Python chapter of the Guide](https://guide.esciencecenter.nl/#/best_practices/language_guides/python) - [ ] All user facing changes have been added to CHANGELOG.md From 3ce8ff997901e382179a764cecb1750afa38f6b4 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Sat, 4 May 2024 01:09:11 +0200 Subject: [PATCH 135/144] update deprecated ruff usage and config --- .../.githooks/pre-commit | 2 +- .../pyproject.toml | 56 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.githooks/pre-commit b/{{cookiecutter.directory_name}}/.githooks/pre-commit index a0f9c2e0..8279d5a5 100755 --- a/{{cookiecutter.directory_name}}/.githooks/pre-commit +++ b/{{cookiecutter.directory_name}}/.githooks/pre-commit @@ -6,7 +6,7 @@ echo "Script $0 triggered ..." echo "Starting ruff analysis..." # quietly run ruff -ruff . --fix +ruff check . --fix # use return code to abort commit if necessary if [ $? != "0" ]; then diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index ffdb0a0b..fbfaa195 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -100,6 +100,35 @@ extras = dev """ [tool.ruff] +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", + ".venv", + "scripts", +] + +target-version = "py39" +line-length = 120 + + +[tool.ruff.lint] # Enable Pyflakes `E` and `F` codes by default. select = [ "F", # Pyflakes @@ -137,39 +166,14 @@ ignore = [ fixable = ["A", "B", "C", "D", "E", "F", "I"] unfixable = [] -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".hg", - ".mypy_cache", - ".nox", - ".pants.d", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "venv", - ".venv", - "scripts", -] per-file-ignores = {} # Allow unused variables when underscore-prefixed. dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" -target-version = "py39" -line-length = 120 -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ["{{ cookiecutter.package_name }}"] force-single-line = true no-lines-before = ["future","standard-library","third-party","first-party","local-folder"] From 2f33fb9b8eda028073df8d49e3739d1e70e11709 Mon Sep 17 00:00:00 2001 From: Dani Bodor Date: Fri, 12 Jul 2024 16:47:33 +0200 Subject: [PATCH 136/144] perform ruff format check (in addition to linting) in workflow and in pre-commit hook also explicitly call `ruff check` rather than deprecated `ruff .` --- {{cookiecutter.directory_name}}/.githooks/pre-commit | 3 ++- {{cookiecutter.directory_name}}/.github/workflows/build.yml | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.directory_name}}/.githooks/pre-commit b/{{cookiecutter.directory_name}}/.githooks/pre-commit index 8279d5a5..c4bc8dd3 100755 --- a/{{cookiecutter.directory_name}}/.githooks/pre-commit +++ b/{{cookiecutter.directory_name}}/.githooks/pre-commit @@ -6,7 +6,8 @@ echo "Script $0 triggered ..." echo "Starting ruff analysis..." # quietly run ruff -ruff check . --fix +ruff check --fix +ruff format # use return code to abort commit if necessary if [ $? != "0" ]; then diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 55815c0b..2f9272da 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -59,4 +59,6 @@ jobs: python -m pip install --upgrade pip setuptools python -m pip install .[dev,publishing] - name: Check style against standards using ruff - run: ruff . + run: | + ruff check + ruff format --check From 1af168e44f986e34bf2d27ab3074fb00e7ad432f Mon Sep 17 00:00:00 2001 From: Dani Bodor Date: Fri, 12 Jul 2024 16:51:11 +0200 Subject: [PATCH 137/144] update deprecated format of ruff settings in pyproject.toml --- .../pyproject.toml | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index fbfaa195..308f4757 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -100,33 +100,8 @@ extras = dev """ [tool.ruff] -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".hg", - ".mypy_cache", - ".nox", - ".pants.d", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "venv", - ".venv", - "scripts", -] - -target-version = "py39" line-length = 120 - +output-format = "concise" [tool.ruff.lint] # Enable Pyflakes `E` and `F` codes by default. @@ -166,13 +141,9 @@ ignore = [ fixable = ["A", "B", "C", "D", "E", "F", "I"] unfixable = [] -per-file-ignores = {} - - # Allow unused variables when underscore-prefixed. dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - [tool.ruff.lint.isort] known-first-party = ["{{ cookiecutter.package_name }}"] force-single-line = true From ab8141772dcb100330ac1d606a457ea833c233cd Mon Sep 17 00:00:00 2001 From: Dani Bodor Date: Fri, 12 Jul 2024 16:53:11 +0200 Subject: [PATCH 138/144] use ruff docstring convention more consistent than explicitly ignoring certain rules --- .../pyproject.toml | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 308f4757..7f51c379 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -120,22 +120,13 @@ select = [ ] ignore = [ - 'D100', # Missing module docstring - 'D104', # Missing public package docstring - # The following list excludes rules irrelevant to the Google style - 'D203', - 'D204', - 'D213', - 'D215', - 'D400', - 'D401', - 'D404', - 'D406', - 'D407', - 'D408', - 'D409', - 'D413', + # No docstrings required in the following cases + "D100", # Missing module docstring + "D104", # Missing public package docstring + "D105", # Missing docstring in magic method + "D107", # Missing docstring in `__init__` ] +pydocstyle.convention = "google" # Allow autofix for all enabled rules (when `--fix`) is provided. fixable = ["A", "B", "C", "D", "E", "F", "I"] From 0c664509729de8a2aa939d505c99c4da40166f0e Mon Sep 17 00:00:00 2001 From: Dani Bodor Date: Fri, 12 Jul 2024 17:06:47 +0200 Subject: [PATCH 139/144] more aggressive linting checks --- .../pyproject.toml | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 7f51c379..046de3de 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -104,22 +104,19 @@ line-length = 120 output-format = "concise" [tool.ruff.lint] -# Enable Pyflakes `E` and `F` codes by default. -select = [ - "F", # Pyflakes - "E", # pycodestyle (error) - "W", # pycodestyle (warning) - # "C90", # mccabe - "I", # isort - "D", # pydocstyle - # "PL", # Pylint - # "PLC", # Convention - # "PLE", # Error - # "PLR", # Refactor - # "PLW", # Warning +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" -] +# Enable Pyflakes `E` and `F` codes by default. +select = ["ALL"] ignore = [ + "ANN101", # Missing type annotation for `self` in method + "ANN102", # Missing type annotation for `cls` in classmethod + "ANN204", # Missing return type annotation for special (dunder) method + "FBT", # Using boolean function arguments + "TD", # TODOs + "FIX002", # Resolve TODOs + "B028", # No explicit `stacklevel` keyword argument found in warning # No docstrings required in the following cases "D100", # Missing module docstring "D104", # Missing public package docstring @@ -129,11 +126,28 @@ ignore = [ pydocstyle.convention = "google" # Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = ["A", "B", "C", "D", "E", "F", "I"] -unfixable = [] +fixable = ["ALL"] +unfixable = ["F401"] # unused imports (should not disappear while editing) +extend-safe-fixes = [ + "D415", # First line should end with a period, question mark, or exclamation point + "D300", # Use triple double quotes `"""` + "D200", # One-line docstring should fit on one line + "TCH", # Format type checking only imports + "ISC001", # Implicitly concatenated strings on a single line + "EM", # Exception message variables + "RUF013", # Implicit Optional + "B006", # Mutable default argument +] -# Allow unused variables when underscore-prefixed. -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +[lint.per-file-ignores] +"tests/*" = [ + "S101", # Use of `assert` detected + "PT011", # pytest-raises-too-broad + "ANN201", # Missing return type + "D103", # Missing function docstring + "ANN401", # Function arguments annotated with too generic `Any` type + "SLF001", # Private member access +] [tool.ruff.lint.isort] known-first-party = ["{{ cookiecutter.package_name }}"] From 1360ccf55f8f9296e12a2040b84774a1156116c3 Mon Sep 17 00:00:00 2001 From: Dani Bodor Date: Fri, 12 Jul 2024 16:46:55 +0200 Subject: [PATCH 140/144] update checkout and setup-python versions for both current project as well as in cookiecutter --- .github/workflows/cffconvert.yml | 2 +- .github/workflows/markdown-link-check.yml | 2 +- .github/workflows/tests.yml | 4 ++-- .../.github/workflows/build.yml | 8 ++++---- .../.github/workflows/cffconvert.yml | 2 +- .../.github/workflows/documentation.yml | 6 +++--- .../.github/workflows/markdown-link-check.yml | 2 +- .../.github/workflows/next_steps.yml | 2 +- .../.github/workflows/sonarcloud.yml | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cffconvert.yml b/.github/workflows/cffconvert.yml index 6851c52d..71443637 100644 --- a/.github/workflows/cffconvert.yml +++ b/.github/workflows/cffconvert.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out a copy of the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Check whether the citation metadata from CITATION.cff is valid uses: citation-file-format/cffconvert-github-action@2.0.0 diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml index 3cdbce01..2b3a4852 100644 --- a/.github/workflows/markdown-link-check.yml +++ b/.github/workflows/markdown-link-check.yml @@ -14,7 +14,7 @@ jobs: name: Check markdown links runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: config-file: '.mlc-config.json' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 52fb690d..f709f3d0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,9 +18,9 @@ jobs: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Python info diff --git a/{{cookiecutter.directory_name}}/.github/workflows/build.yml b/{{cookiecutter.directory_name}}/.github/workflows/build.yml index 2f9272da..97c648cf 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/build.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/build.yml @@ -19,9 +19,9 @@ jobs: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ '{{ ' -}} matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ '{{ ' -}} matrix.python-version }} - name: Python info @@ -44,9 +44,9 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: 3.9 - name: Python info diff --git a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml index c91a4879..04fb9ea0 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/cffconvert.yml @@ -14,7 +14,7 @@ jobs: name: "cffconvert" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 name: Check out a copy of the repository - name: Check whether the citation metadata from CITATION.cff is valid diff --git a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml index 2bccfd13..f875b720 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/documentation.yml @@ -15,9 +15,9 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: 3.9 - name: Python info @@ -33,4 +33,4 @@ jobs: run: sudo apt install pandoc - name: Build documentation run: make coverage doctest html - working-directory: docs \ No newline at end of file + working-directory: docs diff --git a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml index 3cdbce01..2b3a4852 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml @@ -14,7 +14,7 @@ jobs: name: Check markdown links runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: config-file: '.mlc-config.json' diff --git a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml index 6c83c90d..e759c491 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/next_steps.yml @@ -7,7 +7,7 @@ jobs: next_steps: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Create Sonarcloud integration issue uses: JasonEtco/create-an-issue@v2 env: diff --git a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml index dc4f8672..1c7ec8b3 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/sonarcloud.yml @@ -15,11 +15,11 @@ jobs: name: SonarCloud runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: 3.9 - name: Python info From 945142025c85f6f00d3bc1756b93a4a656276831 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 30 Jul 2024 15:11:11 +0200 Subject: [PATCH 141/144] update ruff check test: specify 'check' command and further ignores --- tests/test_project.py | 2 +- {{cookiecutter.directory_name}}/pyproject.toml | 9 ++++++++- .../src/{{cookiecutter.package_name}}/my_module.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_project.py b/tests/test_project.py index 1163013b..1eb97d46 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -167,7 +167,7 @@ def test_ruff_check(baked_with_development_dependencies, project_env_bin_dir): project_dir = baked_with_development_dependencies bin_dir = project_env_bin_dir - result = run([f'{bin_dir}ruff', '.'], project_dir) + result = run([f'{bin_dir}ruff', 'check', '--fix'], project_dir) assert result.returncode == 0 assert '' in result.stdout diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index 046de3de..99df7d55 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -115,6 +115,7 @@ ignore = [ "ANN204", # Missing return type annotation for special (dunder) method "FBT", # Using boolean function arguments "TD", # TODOs + "FIX001", # Resolve FIXMEs "FIX002", # Resolve TODOs "B028", # No explicit `stacklevel` keyword argument found in warning # No docstrings required in the following cases @@ -139,15 +140,21 @@ extend-safe-fixes = [ "B006", # Mutable default argument ] -[lint.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "tests/*" = [ "S101", # Use of `assert` detected "PT011", # pytest-raises-too-broad + "ANN001", # Missing function argument type "ANN201", # Missing return type "D103", # Missing function docstring "ANN401", # Function arguments annotated with too generic `Any` type "SLF001", # Private member access ] +"docs/conf.py" = [ + "INP001", # Add __init__.py to implicit namespace package + "ERA001", # Commented-out code + "A001", # Shadowing Python builtin name, specifically `copyright` +] [tool.ruff.lint.isort] known-first-party = ["{{ cookiecutter.package_name }}"] diff --git a/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/my_module.py index 1ebf6f27..1d4476d5 100644 --- a/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/my_module.py +++ b/{{cookiecutter.directory_name}}/src/{{cookiecutter.package_name}}/my_module.py @@ -2,7 +2,7 @@ # FIXME: put actual code here -def hello(name): +def hello(name: str) -> str: """Say hello. Function docstring using Google docstring style. From 003117cdc67e90eb8b407ce503e3c3b0dc329b8b Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Tue, 30 Jul 2024 20:56:01 +0200 Subject: [PATCH 142/144] Remove outdated isort configuration (#392) --- {{cookiecutter.directory_name}}/pyproject.toml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/{{cookiecutter.directory_name}}/pyproject.toml b/{{cookiecutter.directory_name}}/pyproject.toml index fbfaa195..86ca3320 100644 --- a/{{cookiecutter.directory_name}}/pyproject.toml +++ b/{{cookiecutter.directory_name}}/pyproject.toml @@ -81,14 +81,6 @@ branch = true source = ["src/{{ cookiecutter.package_name }}"] command_line = "-m pytest" -[tool.isort] -lines_after_imports = 2 -force_single_line = 1 -no_lines_before = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] -known_first_party = "{{ cookiecutter.package_name }}" -src_paths = ["src/{{ cookiecutter.package_name }}", "tests"] -line_length = 120 - [tool.tox] legacy_tox_ini = """ [tox] From d14a2f7c38426a969f94773c25ca60af3dc24529 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Sun, 5 May 2024 16:43:57 +0200 Subject: [PATCH 143/144] enable quiet mode for markdown link checker --- .github/workflows/markdown-link-check.yml | 1 + CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/markdown-link-check.yml b/.github/workflows/markdown-link-check.yml index 2b3a4852..e27e10b3 100644 --- a/.github/workflows/markdown-link-check.yml +++ b/.github/workflows/markdown-link-check.yml @@ -17,4 +17,5 @@ jobs: - uses: actions/checkout@v4 - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: + use-quiet-mode: 'yes' config-file: '.mlc-config.json' diff --git a/CHANGELOG.md b/CHANGELOG.md index 306afdcf..8978bd94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ * Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions [#44](https://github.com/NLeSC/python-template/issues/44) * Generate api rst files with extension instead of custom function [#95](https://github.com/NLeSC/python-template/issues/95) * Change from bump2version (unmaintained) to bump-my-version. +* Set markdown link checker to quiet mode: only report broken links [#262](https://github.com/NLeSC/python-template/issues/262) ### Removed From df96ae281e38f6e0498afae068a0dc4a24b6de46 Mon Sep 17 00:00:00 2001 From: Sander van Rijn Date: Tue, 13 Aug 2024 14:49:11 +0200 Subject: [PATCH 144/144] also use quiet mode in generated package --- .../.github/workflows/markdown-link-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml index 2b3a4852..e27e10b3 100644 --- a/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml +++ b/{{cookiecutter.directory_name}}/.github/workflows/markdown-link-check.yml @@ -17,4 +17,5 @@ jobs: - uses: actions/checkout@v4 - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: + use-quiet-mode: 'yes' config-file: '.mlc-config.json'