From e15399df89b84b599ca54964ff632f5cf051aa89 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Jun 2024 12:15:27 -0400 Subject: [PATCH 1/6] update security hardening, update dependencies, drop flake8-alphabetize, enable more ruff-based checks --- .github/dependabot.yml | 2 +- .github/workflows/main.yml | 4 +++ {{cookiecutter.project_slug}}/.flake8 | 3 --- .../.github/dependabot.yml | 2 +- .../.github/workflows/bump-version.yml | 2 +- .../.github/workflows/cache-cleaner.yml | 2 +- .../.github/workflows/dependency-review.yml | 2 +- .../.github/workflows/first-pull-request.yml | 2 +- .../.github/workflows/label.yml | 2 +- .../.github/workflows/main.yml | 4 +-- .../.github/workflows/publish-pypi.yml | 2 +- .../.github/workflows/scorecard.yml | 2 +- .../.github/workflows/tag-testpypi.yml | 2 +- .../.github/workflows/workflow-warning.yml | 2 +- .../environment-dev.yml | 13 +++++----- .../environment-docs.yml | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 26 ++++++++++++++----- 17 files changed, 44 insertions(+), 30 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d0ec15c99..bc715aec0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,7 +12,7 @@ updates: open-pull-requests-limit: 5 - package-ecosystem: github-actions - directory: "/{{ COOKIECUTTER_PROJECT_SLUG }}/.github/workflows/" + directory: "/\{\{cookiecutter.project_slug\}\}/.github/workflows/" schedule: interval: "weekly" open-pull-requests-limit: 10 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec0e5cdb5..93276e3b0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,6 +25,10 @@ jobs: - tox-env: pypy310 python-version: "pypy3.10" steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.12.1 with: diff --git a/{{cookiecutter.project_slug}}/.flake8 b/{{cookiecutter.project_slug}}/.flake8 index 1116575bc..2112ec135 100644 --- a/{{cookiecutter.project_slug}}/.flake8 +++ b/{{cookiecutter.project_slug}}/.flake8 @@ -6,9 +6,6 @@ exclude = docs, tests ignore = - AZ100, - AZ200, - AZ300, C, D, E, diff --git a/{{cookiecutter.project_slug}}/.github/dependabot.yml b/{{cookiecutter.project_slug}}/.github/dependabot.yml index d86e88c84..56265d3c9 100644 --- a/{{cookiecutter.project_slug}}/.github/dependabot.yml +++ b/{{cookiecutter.project_slug}}/.github/dependabot.yml @@ -1,7 +1,7 @@ version: 2 updates: - package-ecosystem: github-actions - directory: / + directory: /.github/workflows/ schedule: interval: monthly open-pull-requests-limit: 10 diff --git a/{{cookiecutter.project_slug}}/.github/workflows/bump-version.yml b/{{cookiecutter.project_slug}}/.github/workflows/bump-version.yml index 7d1e8e580..0418fa374 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/bump-version.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/bump-version.yml @@ -51,7 +51,7 @@ jobs: contents: write steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/cache-cleaner.yml b/{{cookiecutter.project_slug}}/.github/workflows/cache-cleaner.yml index c1a1aea7c..c499ba5e3 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/cache-cleaner.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/cache-cleaner.yml @@ -16,7 +16,7 @@ jobs: actions: write steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/dependency-review.yml b/{{cookiecutter.project_slug}}/.github/workflows/dependency-review.yml index 7936db509..a54cea9ab 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/dependency-review.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/dependency-review.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/first-pull-request.yml b/{{cookiecutter.project_slug}}/.github/workflows/first-pull-request.yml index f8ed96884..c5917addd 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/first-pull-request.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/first-pull-request.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/label.yml b/{{cookiecutter.project_slug}}/.github/workflows/label.yml index 2cbb024af..ff044c92a 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/label.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/label.yml @@ -25,7 +25,7 @@ jobs: pull-requests: write steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yml b/{{cookiecutter.project_slug}}/.github/workflows/main.yml index e9e71bd0a..065765099 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/main.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yml @@ -63,7 +63,7 @@ jobs: python-version: "3.12" steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: egress-policy: audit - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 @@ -96,7 +96,7 @@ jobs: shell: bash -l {0} steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: egress-policy: audit - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 diff --git a/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml index c98d19e80..a8fcc0a98 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/publish-pypi.yml @@ -18,7 +18,7 @@ jobs: id-token: write steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/scorecard.yml b/{{cookiecutter.project_slug}}/.github/workflows/scorecard.yml index 1a429967f..37bfc5cb3 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/scorecard.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/scorecard.yml @@ -29,7 +29,7 @@ jobs: id-token: write steps: - name: Harden Runner - uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml b/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml index 769a759d8..547bba70f 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/tag-testpypi.yml @@ -42,7 +42,7 @@ jobs: id-token: write steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/.github/workflows/workflow-warning.yml b/{{cookiecutter.project_slug}}/.github/workflows/workflow-warning.yml index 17e2f68bd..324a717ba 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/workflow-warning.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/workflow-warning.yml @@ -27,7 +27,7 @@ jobs: pull-requests: write steps: - name: Harden Runner - uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1 + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 with: disable-sudo: true egress-policy: block diff --git a/{{cookiecutter.project_slug}}/environment-dev.yml b/{{cookiecutter.project_slug}}/environment-dev.yml index 920aca7d1..6d55e627b 100644 --- a/{{cookiecutter.project_slug}}/environment-dev.yml +++ b/{{cookiecutter.project_slug}}/environment-dev.yml @@ -7,12 +7,12 @@ dependencies: - pip >=23.3.0 - bump-my-version >=0.18.3 - watchdog >=3.0.0 - - flake8 >=6.1.0 + - flake8 >=7.0.0 - flake8-rst-docstrings >=0.3.0 - - flit - - tox >=4.5.1 - - coverage >=6.2.0,<7.0.0 - - coveralls >=3.3.1 + - flit >=3.9.0 + - tox >=4.15.1 + - coverage >=7.5.0 + - coveralls >=4.0.0 {%- if cookiecutter.command_line_interface|lower == 'click' %} - click >=8.1.7 {%- elif cookiecutter.command_line_interface|lower == 'typer' %} @@ -23,8 +23,9 @@ dependencies: - pytest-cov >=4.0.0 {%- endif %} {%- if cookiecutter.use_black == 'y' %} - - black ==24.1.1 + - black ==24.4.2 - blackdoc ==0.3.9 - isort ==5.13.2 {%- endif %} - pre-commit >=3.3.2 + - ruff >=0.4.0 diff --git a/{{cookiecutter.project_slug}}/environment-docs.yml b/{{cookiecutter.project_slug}}/environment-docs.yml index 96d909bf1..68843c77d 100644 --- a/{{cookiecutter.project_slug}}/environment-docs.yml +++ b/{{cookiecutter.project_slug}}/environment-docs.yml @@ -4,7 +4,7 @@ channels: - defaults dependencies: - python >=3.12,<3.13 - - sphinx + - sphinx >=7.0.0 - pandoc - sphinx-rtd-theme >=1.0 - sphinx-autoapi diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 75dda4a20..4ff044c7f 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -52,11 +52,10 @@ dev = [ "pip >=23.3.0", "bump-my-version >=0.18.3", "watchdog >=3.0.0", - "flake8 >=6.1.0", - "flake8-alphabetize >=0.0.21", + "flake8 >=7.0.0", "flake8-rst-docstrings >=0.3.0", "flit >=3.9.0", - "tox >=4.5.1", + "tox >=4.15.1", "coverage >=7.0.0", "coveralls >=3.3.1", "mypy", @@ -69,13 +68,13 @@ dev = [ "blackdoc ==0.3.9", "isort ==5.13.2", {%- endif %} - "ruff >=0.3.0", + "ruff >=0.4.0", "pre-commit >=3.3.2" ] {%- if cookiecutter.make_docs == 'y' %} docs = [ # Documentation and examples - "sphinx", + "sphinx >=7.0.0", {%- if cookiecutter.command_line_interface|lower == 'click' %} "sphinx-click", {%- endif %} @@ -276,16 +275,28 @@ exclude = [ line-ending = "auto" [tool.ruff.lint] +extend-select = [ + "RUF022", # unsorted-dunder-all +] ignore = [ "D205", "D400", "D401" ] +preview = true select = [ - "C9", - "D", + "BLE", # blind-except + "C90", # mccabe-complexity + "COM", # commas + "D", # docstrings "E", "F", + "FLY002" # static-join-to-fstring + "G", # logging-format + "PERF", # iterator performance + "RUF010", # explicit-f-string-type-conversion + "RUF013", # implicit-optional + "S", "W" ] @@ -311,3 +322,4 @@ max-doc-length = 180 [tool.ruff.lint.pydocstyle] convention = "numpy" + From ad783003f8d416955b4ee245bbf47a0545616d14 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Jun 2024 12:16:19 -0400 Subject: [PATCH 2/6] use latest bump-my-version that supports selective file modification based on bump option --- .../environment-dev.yml | 4 +-- {{cookiecutter.project_slug}}/pyproject.toml | 31 +++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/environment-dev.yml b/{{cookiecutter.project_slug}}/environment-dev.yml index 6d55e627b..8458ca9a0 100644 --- a/{{cookiecutter.project_slug}}/environment-dev.yml +++ b/{{cookiecutter.project_slug}}/environment-dev.yml @@ -4,8 +4,8 @@ channels: dependencies: - python >=3.9,<3.13 # Dev tools and testing - - pip >=23.3.0 - - bump-my-version >=0.18.3 + - pip >=24.0 + - bump-my-version >=0.22.0 - watchdog >=3.0.0 - flake8 >=7.0.0 - flake8-rst-docstrings >=0.3.0 diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 4ff044c7f..ef4982474 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -49,8 +49,8 @@ dependencies = [ [project.optional-dependencies] dev = [ # Dev tools and testing - "pip >=23.3.0", - "bump-my-version >=0.18.3", + "pip >=24.0", + "bump-my-version >=0.22.0", "watchdog >=3.0.0", "flake8 >=7.0.0", "flake8-rst-docstrings >=0.3.0", @@ -134,6 +134,33 @@ serialize = [ "{major}.{minor}.{patch}" ] +[[tool.bumpversion.files]] +filename = "CHANGELOG.rst" +include_bumps = ["release"] +search = """\ +`Unreleased `_ (latest) +{{ '-' * ('`Unreleased `_ (latest)')|length }} +""" +replace = """\ +`Unreleased `_ (latest) +{{ '-' * ('`Unreleased `_ (latest)')|length }} + +Contributors: + +Changes +^^^^^^^ +* No change. + +Fixes +^^^^^ +* No change. + +.. _changes_{new_version}: + +`v{new_version} `_ +{{ '-' * ('`v' + cookiecutter.version + ' `_')|length }} +""" + [[tool.bumpversion.files]] filename = "src/{{ cookiecutter.project_slug }}/__init__.py" search = "__version__ = \"{current_version}\"" From f5000bb7ed31f4dfa7e0bdf706f80f5d426cbf82 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:43:26 -0400 Subject: [PATCH 3/6] fix formatting errors, remove flake8-alphabetize --- .../.pre-commit-config.yaml | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index c938bacda..f49bd103c 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -53,7 +53,7 @@ repos: rev: 7.0.0 hooks: - id: flake8 - additional_dependencies: [ 'flake8-alphabetize', 'flake8-rst-docstrings' ] + additional_dependencies: [ 'flake8-rst-docstrings' ] args: [ '--config=.flake8' ] {%- if cookiecutter.use_black == 'y' %} - repo: https://github.com/keewis/blackdoc diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index ef4982474..85b0b0dde 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -303,12 +303,12 @@ line-ending = "auto" [tool.ruff.lint] extend-select = [ - "RUF022", # unsorted-dunder-all + "RUF022" # unsorted-dunder-all ] ignore = [ - "D205", - "D400", - "D401" + "D205", # blank-line-after-summary + "D400", # ends-in-period + "D401" # non-imperative-mood ] preview = true select = [ @@ -316,15 +316,15 @@ select = [ "C90", # mccabe-complexity "COM", # commas "D", # docstrings - "E", - "F", - "FLY002" # static-join-to-fstring + "E", # pycodestyle errors + "FLY002", # static-join-to-fstring "G", # logging-format "PERF", # iterator performance + "PTH", # pathlib "RUF010", # explicit-f-string-type-conversion "RUF013", # implicit-optional - "S", - "W" + "S", # bandit + "W" # pycodestyle warnings ] [tool.ruff.lint.flake8-bandit] @@ -349,4 +349,3 @@ max-doc-length = 180 [tool.ruff.lint.pydocstyle] convention = "numpy" - From f8ebbdf4ef2b47ac1883aeb6dd272b220262180f Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:08:22 -0400 Subject: [PATCH 4/6] fix formatting errors, some linting in base package, exclude no-asserts in tests --- cookiecutter.json | 53 +++---- python_boilerplate/CODE_OF_CONDUCT.md | 133 ------------------ ruff.toml | 4 +- setup.py | 56 ++++---- tests/test_bake_project.py | 9 +- {{cookiecutter.project_slug}}/docs/conf.py | 1 + {{cookiecutter.project_slug}}/pyproject.toml | 1 + .../src/{{cookiecutter.project_slug}}/cli.py | 9 +- .../test_{{cookiecutter.project_slug}}.py | 4 +- 9 files changed, 76 insertions(+), 194 deletions(-) delete mode 100644 python_boilerplate/CODE_OF_CONDUCT.md diff --git a/cookiecutter.json b/cookiecutter.json index 35af3f93d..889c992f9 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -13,35 +13,40 @@ "add_pyup_badge": "n", "make_docs": "y", "add_translations": "y", - "command_line_interface": ["Typer", "Click", "Argparse", "No command-line interface"], + "command_line_interface": [ + "Typer", + "Click", + "Argparse", + "No command-line interface" + ], "create_author_file": "y", "open_source_license": [ - "MIT license", - "BSD license", - "ISC license", - "Apache Software License 2.0", - "GNU General Public License v3", - "Not open source" + "MIT license", + "BSD license", + "ISC license", + "Apache Software License 2.0", + "GNU General Public License v3", + "Not open source" ], "generated_with_cruft": "y", "__gh_slug": "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_name.replace(' ', '-') }}", "__prompts__": { - "full_name": "Your full name", - "email": "Your email address", - "github_username": "Your GitHub username (or organization)", - "project_name": "The name of your project", - "project_short_description": "A short description of your project", - "pypi_username": "Your PyPI username (or organization)", - "version": "The version of your project", - "use_pytest": "Do you want to use pytest?", - "use_black": "Do you want to use Black for code formatting?", - "use_conda": "Do you want to add configurations for Anaconda package management?", - "add_pyup_badge": "Do you want to add a pyup.io badge? (not recommended)", - "make_docs": "Do you want to generate documentation files", - "add_translations": "Do you want to add translations?", - "command_line_interface": "Which command-line interface do you want to use?", - "create_author_file": "Do you want to create an AUTHORS.rst file?", - "open_source_license": "Which open-source license do you want to use?", - "generated_with_cruft": "Was this project generated with Cruft? (Add a '.cruft.json' file)" + "full_name": "Your full name", + "email": "Your email address", + "github_username": "Your GitHub username (or organization)", + "project_name": "The name of your project", + "project_short_description": "A short description of your project", + "pypi_username": "Your PyPI username (or organization)", + "version": "The version of your project", + "use_pytest": "Do you want to use pytest?", + "use_black": "Do you want to use Black for code formatting?", + "use_conda": "Do you want to add configurations for Anaconda package management?", + "add_pyup_badge": "Do you want to add a pyup.io badge? (not recommended)", + "make_docs": "Do you want to generate documentation files", + "add_translations": "Do you want to add translations?", + "command_line_interface": "Which command-line interface do you want to use?", + "create_author_file": "Do you want to create an AUTHORS.rst file?", + "open_source_license": "Which open-source license do you want to use?", + "generated_with_cruft": "Was this project generated with Cruft? (Add a '.cruft.json' file)" } } diff --git a/python_boilerplate/CODE_OF_CONDUCT.md b/python_boilerplate/CODE_OF_CONDUCT.md deleted file mode 100644 index 20bcc4f64..000000000 --- a/python_boilerplate/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,133 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official email address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -[INSERT CONTACT METHOD]. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations diff --git a/ruff.toml b/ruff.toml index aca233bab..23d9e383e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,3 +1,3 @@ exclude = [ - "*cookiecutter.project_slug*" - ] + "*cookiecutter.project_slug*" +] diff --git a/setup.py b/setup.py index f7456e4c8..f8d9f2293 100644 --- a/setup.py +++ b/setup.py @@ -1,33 +1,39 @@ # !/usr/bin/env python from distutils.core import setup + + setup( - name='cookiecutter-pypackage', + name="cookiecutter-pypackage", packages=[], - version='0.1.0', - description='Cookiecutter template for a Python package', - author='Audrey M. Roy Greenfeld', - license='BSD', - author_email='audrey@feldroy.com', - url='https://github.com/audreyfeldroy/cookiecutter-pypackage', - keywords=['cookiecutter', 'template', 'package', ], - python_requires='>=3.8', + version="0.1.0", + description="Cookiecutter template for a Python package", + author="Audrey M. Roy Greenfeld", + license="BSD", + author_email="audrey@feldroy.com", + url="https://github.com/audreyfeldroy/cookiecutter-pypackage", + keywords=[ + "cookiecutter", + "template", + "package", + ], + python_requires=">=3.8", classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Natural Language :: English', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - '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', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Software Development', + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Developers", + "Natural Language :: English", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "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", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development", ], ) diff --git a/tests/test_bake_project.py b/tests/test_bake_project.py index 0290b6b59..b1e02435b 100644 --- a/tests/test_bake_project.py +++ b/tests/test_bake_project.py @@ -88,7 +88,10 @@ def test_bake_with_defaults(cookies): assert "environment-dev.yml" in found_toplevel_files assert "pyproject.toml" in found_toplevel_files assert "src" in found_toplevel_files - assert "python_boilerplate" in next(result.project_path.joinpath("src").iterdir()).name + assert ( + "python_boilerplate" + in next(result.project_path.joinpath("src").iterdir()).name + ) assert "tests" in found_toplevel_files assert "tox.ini" in found_toplevel_files @@ -301,7 +304,7 @@ def test_bake_with_no_console_script(cookies): assert "cli.py" not in found_project_files pyproject_path = os.path.join(project_path, "pyproject.toml") - with open(pyproject_path, "r") as setup_file: + with open(pyproject_path) as setup_file: assert "[project.scripts]" not in setup_file.read() @@ -316,7 +319,7 @@ def test_bake_with_console_options_script_files(cookies, option): assert "cli.py" in found_project_files pyproject_path = os.path.join(project_path, "pyproject.toml") - with open(pyproject_path, "r") as setup_file: + with open(pyproject_path) as setup_file: assert "[project.scripts]" in setup_file.read() diff --git a/{{cookiecutter.project_slug}}/docs/conf.py b/{{cookiecutter.project_slug}}/docs/conf.py index 400e76a86..e9b352695 100755 --- a/{{cookiecutter.project_slug}}/docs/conf.py +++ b/{{cookiecutter.project_slug}}/docs/conf.py @@ -19,6 +19,7 @@ # import os import sys + sys.path.insert(0, os.path.abspath('..')) import {{ cookiecutter.project_slug }} diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 3f21443f6..31bd2e7ce 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -346,6 +346,7 @@ max-complexity = 15 [tool.ruff.lint.per-file-ignores] "docs/**" = ["E402"] "src/{{ cookiecutter.project_slug }}/**/__init__.py" = ["F401", "F403"] +"tests/**" = ["S101"] [tool.ruff.lint.pycodestyle] max-doc-length = 180 diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py index 5147a8337..2a4f37626 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py @@ -3,6 +3,7 @@ import argparse import sys + def main(): """Console script for {{cookiecutter.project_slug}}.""" parser = argparse.ArgumentParser() @@ -10,8 +11,7 @@ def main(): args = parser.parse_args() print("Arguments: " + str(args._)) - print("Replace this message by putting your code into " - "{{cookiecutter.project_slug}}.cli.main") + print("Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main") return 0 @@ -28,7 +28,7 @@ def main(): def main(args=None): """Console script for {{cookiecutter.project_slug}}.""" click.echo( - "Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main" + "Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main", ) click.echo("See click documentation at https://click.palletsprojects.com/") return 0 @@ -39,6 +39,7 @@ def main(args=None): import typer from rich.console import Console + app = typer.Typer() console = Console() @@ -47,7 +48,7 @@ def main(args=None): def main(): """Console script for {{cookiecutter.project_slug}}.""" console.print( - "Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main" + "Replace this message by putting your code into {{cookiecutter.project_slug}}.cli.main", ) console.print("See Typer documentation at https://typer.tiangolo.com/") diff --git a/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py b/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py index d984f362e..8b925d284 100644 --- a/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py +++ b/{{cookiecutter.project_slug}}/tests/test_{{cookiecutter.project_slug}}.py @@ -1,7 +1,5 @@ #!/usr/bin/env python - """Tests for `{{ cookiecutter.project_slug }}` package.""" - import pathlib from importlib.util import find_spec {% if cookiecutter.use_pytest == 'n' -%} @@ -79,7 +77,7 @@ def test_package_metadata(): metadata = pathlib.Path(project).resolve().joinpath("__init__.py") - with open(metadata) as f: + with metadata.open() as f: contents = f.read() assert """{{ cookiecutter.full_name }}""" in contents assert '__email__ = "{{ cookiecutter.email }}"' in contents From 718684793e04310386570f18d909ed4f500e4f15 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:22:45 -0400 Subject: [PATCH 5/6] fix import lines, remove broken reference --- docs/tutorial.rst | 2 -- {{cookiecutter.project_slug}}/pyproject.toml | 2 +- .../src/{{cookiecutter.project_slug}}/cli.py | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/tutorial.rst b/docs/tutorial.rst index bab58fa7c..127174fe6 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -118,8 +118,6 @@ This will: * Encrypt your PyPI password in your Travis config. * Activate automated deployment on PyPI when you push a new tag to master branch. -See :ref:`travis-pypi-setup` for more information. - .. _`Travis CI com`: https://travis-ci.com/ diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 31bd2e7ce..8018ed7de 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -337,7 +337,7 @@ check-typed-exception = true known-first-party = ["{{ cookiecutter.project_slug }}"] case-sensitive = true detect-same-package = false -lines-after-imports = 1 +lines-after-imports = 2 no-lines-before = ["future", "standard-library"] [tool.ruff.lint.mccabe] diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py index 2a4f37626..476c2414f 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/cli.py @@ -39,7 +39,6 @@ def main(args=None): import typer from rich.console import Console - app = typer.Typer() console = Console() From aa14984c094071e1522afa612ac2a59626179260 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 14 Jun 2024 12:06:57 -0400 Subject: [PATCH 6/6] bump bump-my-version version --- {{cookiecutter.project_slug}}/environment-dev.yml | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/environment-dev.yml b/{{cookiecutter.project_slug}}/environment-dev.yml index 8458ca9a0..5e4438cfc 100644 --- a/{{cookiecutter.project_slug}}/environment-dev.yml +++ b/{{cookiecutter.project_slug}}/environment-dev.yml @@ -5,7 +5,7 @@ dependencies: - python >=3.9,<3.13 # Dev tools and testing - pip >=24.0 - - bump-my-version >=0.22.0 + - bump-my-version >=0.23.0 - watchdog >=3.0.0 - flake8 >=7.0.0 - flake8-rst-docstrings >=0.3.0 diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 8018ed7de..f3ccd1de0 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -53,7 +53,7 @@ dependencies = [ dev = [ # Dev tools and testing "pip >=24.0", - "bump-my-version >=0.22.0", + "bump-my-version >=0.23.0", "watchdog >=3.0.0", "flake8 >=7.0.0", "flake8-rst-docstrings >=0.3.0",