From 8dc3afd544c8411f44a46e1e1fab6c0d49d25090 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Wed, 24 Jan 2024 15:22:16 +0000 Subject: [PATCH 1/9] Fix linting the template check --- .github/workflows/linting.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 620f057c..dd7f7fe3 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -55,5 +55,7 @@ jobs: run: cookiecutter . --no-input --output-dir cookie-template - name: Run pre-commit - run: pre-commit run --all-files --color always --verbose - working-directory: cookie-template + run: |- + git add . + pre-commit run --all-files --color always --verbose + working-directory: cookie-template/python-template From ee6f5a3a7b200a40e1fd5e89004693fa457b620f Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Wed, 24 Jan 2024 15:28:11 +0000 Subject: [PATCH 2/9] Fix linting template --- {{cookiecutter.project_slug}}/LICENSE.md | 3 --- {{cookiecutter.project_slug}}/pyproject.toml | 7 ++----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/{{cookiecutter.project_slug}}/LICENSE.md b/{{cookiecutter.project_slug}}/LICENSE.md index 250f5ae7..f7c5ba30 100644 --- a/{{cookiecutter.project_slug}}/LICENSE.md +++ b/{{cookiecutter.project_slug}}/LICENSE.md @@ -21,7 +21,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - {%- elif cookiecutter.license == "BSD-3" -%} Copyright (c) {% now 'utc', '%Y' %}, {{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}} @@ -51,7 +50,6 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - {%- elif cookiecutter.license == "GPL-3.0" -%} # GNU General Public License @@ -648,5 +646,4 @@ more useful to permit linking proprietary applications with the library. If this what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <>. - {%- endif -%} diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 5cdecc8b..bb359e8f 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -56,9 +56,6 @@ paths.source = [ [tool.mypy] explicit_package_bases = true -plugins = [ - "numpy.typing.mypy_plugin", -] [tool.pytest.ini_options] addopts = """ @@ -74,7 +71,7 @@ testpaths = [ fix = true force-exclude = true ignore = [ - "COM812", # trailing commas (ruff-format recommended) + "COM812", # trailing commas (ruff-format recommended) "D203", # no-blank-line-before-class "D212", # multi-line-summary-first-line "D407", # removed dashes lines under sections @@ -86,7 +83,7 @@ per-file-ignores = {"tests*" = [ "S101", ]} select = [ - "ALL" + "ALL", ] target-version = "py{{cookiecutter.min_python_version | replace('.', '')}}" isort.known-first-party = [ From 866c93826de5da30831bb6a6ba1aedb56a954ffd Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Wed, 24 Jan 2024 15:52:35 +0000 Subject: [PATCH 3/9] Use `exclude` list syntax --- .pre-commit-config.yaml | 21 +++++++++++++++++---- {{cookiecutter.project_slug}}/LICENSE.md | 3 --- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b06cf46..181601d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,10 @@ repos: - id: ruff args: - --config=pyproject.toml - exclude: "{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}" + exclude: |- + (?x)( + {{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}} + ) - id: ruff-format args: - --config=pyproject.toml @@ -17,7 +20,10 @@ repos: rev: v0.23.1 hooks: - id: toml-sort-fix - exclude: "{{cookiecutter.project_slug}}/pyproject.toml" + exclude: |- + (?x)( + {{cookiecutter.project_slug}}/pyproject.toml + ) - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.8.0 hooks: @@ -26,12 +32,19 @@ repos: - --config-file=pyproject.toml additional_dependencies: - pytest - exclude: "{{cookiecutter.project_slug}}/(src/{{cookiecutter.package_name}}|tests)" + exclude: |- + (?x)( + {{cookiecutter.project_slug}}/(src/{{cookiecutter.package_name}}|tests) + ) - repo: https://github.com/pre-commit/mirrors-prettier rev: v3.1.0 hooks: - id: prettier - exclude: "{{cookiecutter.project_slug}}/.github/workflows/tests.yml" + exclude: |- + (?x)( + {{cookiecutter.project_slug}}/.github/workflows/tests.yml| + {{cookiecutter.project_slug}}/LICENSE.md + ) - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: diff --git a/{{cookiecutter.project_slug}}/LICENSE.md b/{{cookiecutter.project_slug}}/LICENSE.md index f7c5ba30..de39fe92 100644 --- a/{{cookiecutter.project_slug}}/LICENSE.md +++ b/{{cookiecutter.project_slug}}/LICENSE.md @@ -1,5 +1,4 @@ {%- if cookiecutter.license == "MIT" -%} - # The MIT License (MIT) Copyright (c) {% now 'utc', '%Y' %} {{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}} @@ -22,7 +21,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. {%- elif cookiecutter.license == "BSD-3" -%} - Copyright (c) {% now 'utc', '%Y' %}, {{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}} All rights reserved. @@ -51,7 +49,6 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. {%- elif cookiecutter.license == "GPL-3.0" -%} - # GNU General Public License _Version 3, 29 June 2007_ From 43e963ad0ead1f828bbbd52f346117ebc6153322 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Wed, 24 Jan 2024 16:15:22 +0000 Subject: [PATCH 4/9] Newline at end of `if` --- {{cookiecutter.project_slug}}/LICENSE.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/LICENSE.md b/{{cookiecutter.project_slug}}/LICENSE.md index de39fe92..0461b9c7 100644 --- a/{{cookiecutter.project_slug}}/LICENSE.md +++ b/{{cookiecutter.project_slug}}/LICENSE.md @@ -1,4 +1,5 @@ {%- if cookiecutter.license == "MIT" -%} + # The MIT License (MIT) Copyright (c) {% now 'utc', '%Y' %} {{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}} @@ -20,7 +21,9 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + {%- elif cookiecutter.license == "BSD-3" -%} + Copyright (c) {% now 'utc', '%Y' %}, {{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}} All rights reserved. @@ -48,7 +51,9 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + {%- elif cookiecutter.license == "GPL-3.0" -%} + # GNU General Public License _Version 3, 29 June 2007_ @@ -643,4 +648,5 @@ more useful to permit linking proprietary applications with the library. If this what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <>. -{%- endif -%} + +{%- endif %} From b999b00f233cb867aaf8ce6452f20f91ebc86727 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Wed, 24 Jan 2024 16:16:53 +0000 Subject: [PATCH 5/9] Remove LICENCE.md from exclude --- .pre-commit-config.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 181601d0..ffa46436 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,8 +42,7 @@ repos: - id: prettier exclude: |- (?x)( - {{cookiecutter.project_slug}}/.github/workflows/tests.yml| - {{cookiecutter.project_slug}}/LICENSE.md + {{cookiecutter.project_slug}}/.github/workflows/tests.yml ) - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 From 13514d2f3dca850efcf366920349a019b9b24e01 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Wed, 24 Jan 2024 18:12:10 +0000 Subject: [PATCH 6/9] Fix linting --- .../src/{{cookiecutter.package_name}}/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py index 3a8d6d5c..7565f210 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py @@ -1 +1,2 @@ +"""{{cookiecutter.package_name}}""" from ._version import __version__ # noqa: F401 From 749a69a494dc9eeb3b95799f90eed0806f25bbae Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Wed, 24 Jan 2024 18:13:15 +0000 Subject: [PATCH 7/9] Add full stop --- .../src/{{cookiecutter.package_name}}/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py index 7565f210..e6dfdbd4 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}/__init__.py @@ -1,2 +1,2 @@ -"""{{cookiecutter.package_name}}""" +"""{{cookiecutter.package_name}} package.""" from ._version import __version__ # noqa: F401 From 18b414a85c61b044d3e6a27b498d2aed6fde11cf Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Tue, 30 Jan 2024 14:06:07 +0000 Subject: [PATCH 8/9] Split regex Co-authored-by: David Stansby --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ffa46436..82bd4755 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,8 @@ repos: - pytest exclude: |- (?x)( - {{cookiecutter.project_slug}}/(src/{{cookiecutter.package_name}}|tests) + {{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}} + {{cookiecutter.project_slug}}/tests ) - repo: https://github.com/pre-commit/mirrors-prettier rev: v3.1.0 From 52c3337da5242fdee9e848334e88d6ee6c6bd220 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Tue, 30 Jan 2024 14:08:06 +0000 Subject: [PATCH 9/9] Add missing `|` cc: @dstansby --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 82bd4755..0bcd9716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: - pytest exclude: |- (?x)( - {{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}} + {{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}| {{cookiecutter.project_slug}}/tests ) - repo: https://github.com/pre-commit/mirrors-prettier