From 22cdebe2dcb5c8f5a8df319680ed8292e2abc261 Mon Sep 17 00:00:00 2001 From: Yurely Date: Wed, 28 Feb 2024 19:51:07 -0400 Subject: [PATCH 01/21] add code for argparse and click in the cli.py file --- .../{{cookiecutter.package_slug}}/cli.py | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py new file mode 100644 index 00000000..e7a2ac31 --- /dev/null +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -0,0 +1,97 @@ +"""Module with CLI functions.""" + +{%- if cookiecutter.use_blue == "yes" %} + {%- set QUOTE = "'" -%} +{%- elif cookiecutter.use_black == "yes" %} + {%- set QUOTE = '"' -%} +{%- else %} + {%- set QUOTE = "'" -%} +{%- endif %} + +{%- if cookiecutter.command_line_interface == "Argparse" %} + +import argparse +import os +import sys + +from {{ cookiecutter.package_slug }} import __version__ + + +class CustomHelpFormatter(argparse.RawTextHelpFormatter): + """Formatter for generating usage messages and argument help strings. + + Only the name of this class is considered a public API. All the methods + provided by the class are considered an implementation detail. + """ + + def __init__( + self, + prog, + indent_increment=2, + max_help_position=4, + width=None, + **kwargs, + ): + super().__init__( + prog, + indent_increment=indent_increment, + max_help_position=max_help_position, + width=width, + **kwargs, + ) + + +def get_args(): + """Return the arguments for the CLI.""" + + parser = argparse.ArgumentParser( + prog={{ QUOTE }}{{ cookiecutter.project_slug }}{{ QUOTE }}, + description=({{ QUOTE }}{{ cookiecutter.project_name }}{{ QUOTE }}), + epilog=( + {{ QUOTE }} If you have any problem, open an issue at: {{ QUOTE }} + {{ QUOTE }}{{ cookiecutter.project_url }}{{ QUOTE }} + ), + add_help=True, + formatter_class=CustomHelpFormatter, + ) + parser.add_argument( + {{ QUOTE }}--version{{ QUOTE }}, + action={{ QUOTE }}store_true{{ QUOTE }}, + help={{ QUOTE }}Show the version of the installed {{ cookiecutter.project_name }} tool.{{ QUOTE }}, + ) + + return parser + + +def show_version(): + """Show the version for the application.""" + print(__version__) + + +def app(): + """Run the application.""" + args_parser = get_args() + args = args_parser.parse_args() + + if args.version: + return show_version() + +{%- else cookiecutter.command_line_interface == "Click" %} + +import click + +from {{ cookiecutter.package_slug }} import __version__ + +@click.command() +@click.option({{ QUOTE }}--version{{ QUOTE }}, is_flag=True, help={{ QUOTE }}Show the version of the installed {{ cookiecutter.project_name }} tool.{{ QUOTE }}) + +def app(version): + """Run the application.""" + if version: + return click.echo(__version__) + click.echo("You can add more Click commands here.") + +if __name__ == {{ QUOTE }}__main__{{ QUOTE }}: + app() + +{%- endif %} From 05529f51597841c705197957698402d49dae34b0 Mon Sep 17 00:00:00 2001 From: Yurely Date: Wed, 28 Feb 2024 19:51:23 -0400 Subject: [PATCH 02/21] add section in pyproject.toml --- .../build-system/poetry-pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml b/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml index 61d00b4f..bf03bfd8 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml +++ b/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml @@ -28,6 +28,11 @@ exclude = [ include = ["{{ package_path }}/py.typed"] {%- endif %} +{%- if cookiecutter.comand_line_interface != "None" %} +[tool.poetry.scripts] +"{{ cookiecutter.project_slug }}" = "{{ cookiecutter.package_slug }}.__main__:app" +{%- endif %} + [tool.poetry.dependencies] python = ">=3.8.1,<4" From c628f3c5f2bbef92da888b487801c6f4dd81c87e Mon Sep 17 00:00:00 2001 From: Yurely Date: Wed, 28 Feb 2024 19:59:47 -0400 Subject: [PATCH 03/21] fix --- .../build-system/poetry-pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml b/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml index bf03bfd8..dd20b8e5 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml +++ b/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml @@ -28,7 +28,7 @@ exclude = [ include = ["{{ package_path }}/py.typed"] {%- endif %} -{%- if cookiecutter.comand_line_interface != "None" %} +{%- if cookiecutter.command_line_interface != "None" %} [tool.poetry.scripts] "{{ cookiecutter.project_slug }}" = "{{ cookiecutter.package_slug }}.__main__:app" {%- endif %} From cd3b26eaa515ac3dc89c91a036a68a80bfe77455 Mon Sep 17 00:00:00 2001 From: Yurely Date: Thu, 29 Feb 2024 11:21:31 -0400 Subject: [PATCH 04/21] fix blue option --- .../{{cookiecutter.package_slug}}/cli.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index e7a2ac31..ab12a473 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -1,8 +1,6 @@ """Module with CLI functions.""" -{%- if cookiecutter.use_blue == "yes" %} - {%- set QUOTE = "'" -%} -{%- elif cookiecutter.use_black == "yes" %} +{%- if cookiecutter.use_black == "yes" %} {%- set QUOTE = '"' -%} {%- else %} {%- set QUOTE = "'" -%} From 2215436408c1f3bc56e28c3c983f5ab5e25c969e Mon Sep 17 00:00:00 2001 From: Yurely Date: Thu, 29 Feb 2024 11:21:37 -0400 Subject: [PATCH 05/21] update --- .../build-system/poetry-pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml b/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml index dd20b8e5..b037807c 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml +++ b/src/scicookie/{{cookiecutter.project_slug}}/build-system/poetry-pyproject.toml @@ -28,7 +28,7 @@ exclude = [ include = ["{{ package_path }}/py.typed"] {%- endif %} -{%- if cookiecutter.command_line_interface != "None" %} +{% if cookiecutter.command_line_interface != "None" -%} [tool.poetry.scripts] "{{ cookiecutter.project_slug }}" = "{{ cookiecutter.package_slug }}.__main__:app" {%- endif %} From bd1ad40a00bf8ee5433ed83eb210a386238e5faa Mon Sep 17 00:00:00 2001 From: Yurely Date: Thu, 29 Feb 2024 11:33:39 -0400 Subject: [PATCH 06/21] improve --- .../{{cookiecutter.package_slug}}/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index ab12a473..7bd9f3bd 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -46,7 +46,7 @@ def get_args(): prog={{ QUOTE }}{{ cookiecutter.project_slug }}{{ QUOTE }}, description=({{ QUOTE }}{{ cookiecutter.project_name }}{{ QUOTE }}), epilog=( - {{ QUOTE }} If you have any problem, open an issue at: {{ QUOTE }} + {{ QUOTE }}If you have any problem, open an issue at: {{ QUOTE }} {{ QUOTE }}{{ cookiecutter.project_url }}{{ QUOTE }} ), add_help=True, @@ -74,7 +74,7 @@ def app(): if args.version: return show_version() -{%- else cookiecutter.command_line_interface == "Click" %} +{%- elif cookiecutter.command_line_interface == "Click" %} import click From 48837d4bee58dbb402d00a7e4e56c8a90b1ebe65 Mon Sep 17 00:00:00 2001 From: Yurely Date: Thu, 29 Feb 2024 20:04:00 -0400 Subject: [PATCH 07/21] add smoke test for cli options --- .github/workflows/main.yaml | 1 + .makim.yaml | 1 + tests/smoke/cli.sh | 7 +++++++ 3 files changed, 9 insertions(+) create mode 100644 tests/smoke/cli.sh diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0262c097..1b3defeb 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -69,6 +69,7 @@ jobs: - linters.sh - tests.sh - virtual-envs.sh + - cli.sh defaults: run: diff --git a/.makim.yaml b/.makim.yaml index a1b59b1b..1873b209 100644 --- a/.makim.yaml +++ b/.makim.yaml @@ -68,6 +68,7 @@ groups: run: | ./tests/smoke/auto-format-tools.sh ./tests/smoke/build-systems.sh + ./tests/smoke/cli.sh ./tests/smoke/containers.sh ./tests/smoke/docs.sh ./tests/smoke/files.sh diff --git a/tests/smoke/cli.sh b/tests/smoke/cli.sh new file mode 100644 index 00000000..68e860aa --- /dev/null +++ b/tests/smoke/cli.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e + +SMOKE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +. ${SMOKE_DIR}/base.sh "command_line_interface=Argparse" +. ${SMOKE_DIR}/base.sh "command_line_interface=Click" From e1ae9322cc95a5571ad1288570110a3433692c15 Mon Sep 17 00:00:00 2001 From: Yurely Date: Fri, 1 Mar 2024 11:17:14 -0400 Subject: [PATCH 08/21] fix cli.py --- .../{{cookiecutter.package_slug}}/cli.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 7bd9f3bd..251196f3 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -9,19 +9,15 @@ {%- if cookiecutter.command_line_interface == "Argparse" %} import argparse -import os -import sys from {{ cookiecutter.package_slug }} import __version__ class CustomHelpFormatter(argparse.RawTextHelpFormatter): """Formatter for generating usage messages and argument help strings. - Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. """ - def __init__( self, prog, @@ -41,7 +37,6 @@ def __init__( def get_args(): """Return the arguments for the CLI.""" - parser = argparse.ArgumentParser( prog={{ QUOTE }}{{ cookiecutter.project_slug }}{{ QUOTE }}, description=({{ QUOTE }}{{ cookiecutter.project_name }}{{ QUOTE }}), From d425f46dd7e149c3b6de2fe3aef7269189d5cb23 Mon Sep 17 00:00:00 2001 From: YurelyCamacho <49034451+YurelyCamacho@users.noreply.github.com> Date: Fri, 1 Mar 2024 11:20:47 -0400 Subject: [PATCH 09/21] Update cli.py Co-authored-by: Ivan Ogasawara --- .../{{cookiecutter.package_slug}}/cli.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 251196f3..889773a6 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -9,7 +9,6 @@ {%- if cookiecutter.command_line_interface == "Argparse" %} import argparse - from {{ cookiecutter.package_slug }} import __version__ From c91915109a4395281d71bd2547bc623d19c79b63 Mon Sep 17 00:00:00 2001 From: Yurely Date: Fri, 1 Mar 2024 11:44:29 -0400 Subject: [PATCH 10/21] update cli.py --- .../{{cookiecutter.package_slug}}/cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 889773a6..b232da8a 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -14,6 +14,7 @@ class CustomHelpFormatter(argparse.RawTextHelpFormatter): """Formatter for generating usage messages and argument help strings. + Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. """ From 76978f2a701925fe5aa8721d5331c566976d222d Mon Sep 17 00:00:00 2001 From: Yurely Date: Fri, 1 Mar 2024 12:44:40 -0400 Subject: [PATCH 11/21] fix ruff --- .../.pre-commit-config.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index e8cb7175..a4f1c804 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -46,14 +46,15 @@ repos: - python {% endif %} {%- if cookiecutter.use_ruff == 'yes' %} - - id: ruff - name: ruff - entry: ruff --fix - language: system - pass_filenames: true - files: "./" - types: - - python + - id: ruff + name: ruff + entry: ruff --fix + language: system + pass_filenames: true + require_serial: yes + files: "./" + types: + - python {% endif %} {%- if cookiecutter.use_isort == "yes" %} - id: isort From 8335f1b29a8face0c527e1f7cb29175c55ad4bd6 Mon Sep 17 00:00:00 2001 From: Yurely Date: Fri, 1 Mar 2024 12:50:13 -0400 Subject: [PATCH 12/21] fix ruff --- .../{{cookiecutter.package_slug}}/cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index b232da8a..2c30086e 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -18,6 +18,7 @@ class CustomHelpFormatter(argparse.RawTextHelpFormatter): Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. """ + def __init__( self, prog, From 73a54add1eceee4afd2d4e2c7fdba3348f276d77 Mon Sep 17 00:00:00 2001 From: Yurely Date: Sun, 3 Mar 2024 11:27:14 -0400 Subject: [PATCH 13/21] fix space --- .../{{cookiecutter.package_slug}}/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 2c30086e..e8f2d812 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -9,7 +9,7 @@ {%- if cookiecutter.command_line_interface == "Argparse" %} import argparse -from {{ cookiecutter.package_slug }} import __version__ +from {{ cookiecutter.package_slug }} import __version__ class CustomHelpFormatter(argparse.RawTextHelpFormatter): From 6c78d32c39325493d452d037a967322f77b80178 Mon Sep 17 00:00:00 2001 From: Yurely Date: Sun, 3 Mar 2024 12:43:19 -0400 Subject: [PATCH 14/21] delete quote variable --- .../{{cookiecutter.package_slug}}/cli.py | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index e8f2d812..57236981 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -1,11 +1,5 @@ """Module with CLI functions.""" -{%- if cookiecutter.use_black == "yes" %} - {%- set QUOTE = '"' -%} -{%- else %} - {%- set QUOTE = "'" -%} -{%- endif %} - {%- if cookiecutter.command_line_interface == "Argparse" %} import argparse @@ -39,19 +33,19 @@ def __init__( def get_args(): """Return the arguments for the CLI.""" parser = argparse.ArgumentParser( - prog={{ QUOTE }}{{ cookiecutter.project_slug }}{{ QUOTE }}, - description=({{ QUOTE }}{{ cookiecutter.project_name }}{{ QUOTE }}), + prog="{{ cookiecutter.project_slug }}", + description=("{{ cookiecutter.project_name }}"), epilog=( - {{ QUOTE }}If you have any problem, open an issue at: {{ QUOTE }} - {{ QUOTE }}{{ cookiecutter.project_url }}{{ QUOTE }} + "If you have any problem, open an issue at: " + "{{ cookiecutter.project_url }}" ), add_help=True, formatter_class=CustomHelpFormatter, ) parser.add_argument( - {{ QUOTE }}--version{{ QUOTE }}, - action={{ QUOTE }}store_true{{ QUOTE }}, - help={{ QUOTE }}Show the version of the installed {{ cookiecutter.project_name }} tool.{{ QUOTE }}, + "--version", + action="store_true", + help="Show the version of the installed {{ cookiecutter.project_name }} tool.", ) return parser @@ -77,7 +71,7 @@ def app(): from {{ cookiecutter.package_slug }} import __version__ @click.command() -@click.option({{ QUOTE }}--version{{ QUOTE }}, is_flag=True, help={{ QUOTE }}Show the version of the installed {{ cookiecutter.project_name }} tool.{{ QUOTE }}) +@click.option("--version", is_flag=True, help="Show the version of the installed {{ cookiecutter.project_name }} tool.") def app(version): """Run the application.""" @@ -85,7 +79,5 @@ def app(version): return click.echo(__version__) click.echo("You can add more Click commands here.") -if __name__ == {{ QUOTE }}__main__{{ QUOTE }}: +if __name__ == "__main__": app() - -{%- endif %} From 38c1b7597fef098c8618e99ae613eea7ee3eb7a0 Mon Sep 17 00:00:00 2001 From: Yurely Date: Sun, 3 Mar 2024 12:51:19 -0400 Subject: [PATCH 15/21] update cli.py --- .../{{cookiecutter.package_slug}}/cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 57236981..7962b7cf 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -81,3 +81,5 @@ def app(version): if __name__ == "__main__": app() + +{%- endif %} From 2eddb7020ad39d1eb5f83e1da0d35c55e8dcd11c Mon Sep 17 00:00:00 2001 From: Yurely Date: Sun, 3 Mar 2024 17:58:16 -0400 Subject: [PATCH 16/21] ruff format --- src/scicookie/__main__.py | 1 + src/scicookie/cli.py | 1 + src/scicookie/logs.py | 1 + src/scicookie/profile.py | 1 + src/scicookie/ui.py | 1 + tests/test_bake_project.py | 1 + 6 files changed, 6 insertions(+) diff --git a/src/scicookie/__main__.py b/src/scicookie/__main__.py index 165b5178..2c003643 100644 --- a/src/scicookie/__main__.py +++ b/src/scicookie/__main__.py @@ -1,4 +1,5 @@ """Interface for the `python -m scicookie`.""" + from scicookie.cli import app if __name__ == "__main__": diff --git a/src/scicookie/cli.py b/src/scicookie/cli.py index 5effd20a..c7e1886e 100644 --- a/src/scicookie/cli.py +++ b/src/scicookie/cli.py @@ -1,4 +1,5 @@ """Module with CLI functions.""" + import argparse import json import os diff --git a/src/scicookie/logs.py b/src/scicookie/logs.py index c6facd47..680844df 100644 --- a/src/scicookie/logs.py +++ b/src/scicookie/logs.py @@ -1,4 +1,5 @@ """Module for functions and classes for systen logs.""" + import os from enum import Enum diff --git a/src/scicookie/profile.py b/src/scicookie/profile.py index c8397fd3..1ec217f7 100644 --- a/src/scicookie/profile.py +++ b/src/scicookie/profile.py @@ -1,4 +1,5 @@ """Profile handles "profiles" defined in the .yaml files.""" + from __future__ import annotations from pathlib import Path diff --git a/src/scicookie/ui.py b/src/scicookie/ui.py index c3ef4fb3..c68f929a 100644 --- a/src/scicookie/ui.py +++ b/src/scicookie/ui.py @@ -1,4 +1,5 @@ """Define functions for the interface with the user.""" + from __future__ import annotations import os diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 0d2bb374..5db0aabf 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -1,4 +1,5 @@ """Cookiecutter bake test.""" + from pathlib import Path import pytest From 38e63d3397e74b0dfcc11332ee4afc6c460fa474 Mon Sep 17 00:00:00 2001 From: Yurely Date: Fri, 8 Mar 2024 20:05:30 -0400 Subject: [PATCH 17/21] fix black and ruff --- .../{{cookiecutter.package_slug}}/cli.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 7962b7cf..0d049a29 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -3,16 +3,18 @@ {%- if cookiecutter.command_line_interface == "Argparse" %} import argparse -from {{ cookiecutter.package_slug }} import __version__ +from {{ cookiecutter.package_slug }} import __version__ +{%- if cookiecutter.use_black == "yes" %} +{% endif %} class CustomHelpFormatter(argparse.RawTextHelpFormatter): """Formatter for generating usage messages and argument help strings. - + Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. """ - + def __init__( self, prog, @@ -69,16 +71,23 @@ def app(): import click from {{ cookiecutter.package_slug }} import __version__ +{%- if cookiecutter.use_black == "yes" %} +{% endif %} @click.command() -@click.option("--version", is_flag=True, help="Show the version of the installed {{ cookiecutter.project_name }} tool.") - +@click.option( + "--version", + is_flag=True, + help="Show the version of the installed {{ cookiecutter.project_name }} tool.", +) def app(version): """Run the application.""" if version: return click.echo(__version__) click.echo("You can add more Click commands here.") +{%- if cookiecutter.use_black == "yes" %} +{% endif %} if __name__ == "__main__": app() From 3d15a1860d56149940ea24c6ff9e9c29a91bf97d Mon Sep 17 00:00:00 2001 From: Yurely Date: Fri, 8 Mar 2024 20:24:10 -0400 Subject: [PATCH 18/21] fix error in pre-commit-config.yaml file --- .../.pre-commit-config.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index a4f1c804..b1b8ac5e 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/src/scicookie/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -46,15 +46,15 @@ repos: - python {% endif %} {%- if cookiecutter.use_ruff == 'yes' %} - - id: ruff - name: ruff - entry: ruff --fix - language: system - pass_filenames: true - require_serial: yes - files: "./" - types: - - python + - id: ruff + name: ruff + entry: ruff --fix + language: system + pass_filenames: true + require_serial: yes + files: "./" + types: + - python {% endif %} {%- if cookiecutter.use_isort == "yes" %} - id: isort From 1c33c5d951f5d0273eb5efe00780621f0b5c1afd Mon Sep 17 00:00:00 2001 From: Yurely Date: Sat, 9 Mar 2024 11:09:36 -0400 Subject: [PATCH 19/21] delete black condition --- .../{{cookiecutter.package_slug}}/cli.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 0d049a29..794cf0e9 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -5,9 +5,8 @@ import argparse from {{ cookiecutter.package_slug }} import __version__ -{%- if cookiecutter.use_black == "yes" %} -{% endif %} + class CustomHelpFormatter(argparse.RawTextHelpFormatter): """Formatter for generating usage messages and argument help strings. @@ -71,9 +70,8 @@ def app(): import click from {{ cookiecutter.package_slug }} import __version__ -{%- if cookiecutter.use_black == "yes" %} -{% endif %} + @click.command() @click.option( "--version", @@ -85,9 +83,8 @@ def app(version): if version: return click.echo(__version__) click.echo("You can add more Click commands here.") -{%- if cookiecutter.use_black == "yes" %} -{% endif %} + if __name__ == "__main__": app() From e1249fa848f31bb5a7baaba3ce1e15638ff1bb91 Mon Sep 17 00:00:00 2001 From: Yurely Date: Wed, 13 Mar 2024 15:42:24 -0400 Subject: [PATCH 20/21] update cli.py --- .../{{cookiecutter.package_slug}}/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py index 794cf0e9..ddf191b6 100644 --- a/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py +++ b/src/scicookie/{{cookiecutter.project_slug}}/{{cookiecutter.package_slug}}/cli.py @@ -84,8 +84,8 @@ def app(version): return click.echo(__version__) click.echo("You can add more Click commands here.") +{%- endif %} + if __name__ == "__main__": app() - -{%- endif %} From 4d11360915ee17f3e3c82259129b83a751467d79 Mon Sep 17 00:00:00 2001 From: Yurely Date: Wed, 13 Mar 2024 16:26:33 -0400 Subject: [PATCH 21/21] updatepost_gen_project.py --- src/scicookie/hooks/post_gen_project.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scicookie/hooks/post_gen_project.py b/src/scicookie/hooks/post_gen_project.py index f5323ebc..028c7d28 100644 --- a/src/scicookie/hooks/post_gen_project.py +++ b/src/scicookie/hooks/post_gen_project.py @@ -179,6 +179,8 @@ def clean_up_containers(): def clean_up_cli(): if not USE_CLI: remove_package_file("__main__.py") + remove_package_file("cli.py") + def clean_up_prettier(): if not USE_PRETTIER: