diff --git a/.copier-answers.yml b/.copier-answers.yml index bb3c412..ccfa189 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v2.0.1 +_commit: v2.1.2 _src_path: gh://lincc-frameworks/python-project-template author_email: lincc-frameworks-team@lists.lsst.org author_name: LINCC Frameworks @@ -18,6 +18,9 @@ project_license: BSD project_name: template-version-check project_organization: lincc-frameworks python_versions: -- '3.9' - '3.10' - '3.11' +- '3.12' +- '3.13' +- '3.14' +test_lowest_version: none diff --git a/.github/ISSUE_TEMPLATE/1-bug_report.md b/.github/ISSUE_TEMPLATE/1-bug_report.md index 220a63d..20fd071 100644 --- a/.github/ISSUE_TEMPLATE/1-bug_report.md +++ b/.github/ISSUE_TEMPLATE/1-bug_report.md @@ -9,9 +9,13 @@ assignees: '' **Bug report** +**Environment Information** + + **Before submitting** Please check the following: -- [ ] I have described the situation in which the bug arose, including what code was executed, information about my environment, and any applicable data others will need to reproduce the problem. -- [ ] I have included available evidence of the unexpected behavior (including error messages, screenshots, and/or plots) as well as a descriprion of what I expected instead. -- [ ] If I have a solution in mind, I have provided an explanation and/or pseudocode and/or task list. \ No newline at end of file +- [ ] I have described the situation in which the bug arose, including what code was executed, and any applicable data others will need to reproduce the problem. +- [ ] I have included information about my environment, including the version of this package (e.g. `pre_commit_hooks.__version__`) +- [ ] I have included available evidence of the unexpected behavior (including error messages, screenshots, and/or plots) as well as a description of what I expected instead. +- [ ] If I have a solution in mind, I have provided an explanation and/or pseudocode and/or task list. diff --git a/.github/workflows/pre-commit-ci.yml b/.github/workflows/pre-commit-ci.yml index 9c251b6..89c2b63 100644 --- a/.github/workflows/pre-commit-ci.yml +++ b/.github/workflows/pre-commit-ci.yml @@ -1,3 +1,4 @@ + # This workflow runs pre-commit hooks on pushes and pull requests to main # to enforce coding style. To ensure correct configuration, please refer to: # https://lincc-ppt.readthedocs.io/en/latest/practices/ci_precommit.html @@ -19,13 +20,14 @@ jobs: - name: Set up Python uses: actions/setup-python@v6 with: - python-version: '3.10' + python-version: '3.12' + - name: Install uv + uses: astral-sh/setup-uv@v5 - name: Install dependencies run: | sudo apt-get update - python -m pip install --upgrade pip - pip install .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + uv pip install --system .[dev] + if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi - uses: pre-commit/action@v3.0.1 with: extra_args: --all-files --verbose diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 7aaf681..1ed27b8 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@v6 @@ -28,12 +28,13 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v5 - name: Install dependencies run: | sudo apt-get update - python -m pip install --upgrade pip - pip install -e .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + uv pip install --system -e .[dev] + if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi - name: List dependencies run: | pip list diff --git a/.github/workflows/testing-and-coverage.yml b/.github/workflows/testing-and-coverage.yml index 1c53702..65bc96f 100644 --- a/.github/workflows/testing-and-coverage.yml +++ b/.github/workflows/testing-and-coverage.yml @@ -1,3 +1,4 @@ + # This workflow will install Python dependencies, run tests and report code coverage with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions @@ -15,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@v6 @@ -23,12 +24,13 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v5 - name: Install dependencies run: | sudo apt-get update - python -m pip install --upgrade pip - pip install -e .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + uv pip install --system -e .[dev] + if [ -f requirements.txt ]; then uv pip install --system -r requirements.txt; fi - name: Run unit tests with pytest run: | python -m pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc03f73..fb268ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,10 @@ + repos: # Compare the local template version to the latest remote template version # This hook should always pass. It will print a message if the local version # is out of date. - repo: https://github.com/lincc-frameworks/pre-commit-hooks - rev: v0.1.1 + rev: v0.1.2 hooks: - id: check-lincc-frameworks-template-version name: Check template version @@ -16,7 +17,8 @@ repos: name: Clear output from Jupyter notebooks description: Clear output from Jupyter notebooks. files: \.ipynb$ - stages: [commit] + exclude: ^docs/pre_executed + stages: [pre-commit] language: system entry: jupyter nbconvert --clear-output # Prevents committing directly branches named 'main' and 'master'. @@ -32,7 +34,7 @@ repos: args: ['--maxkb=500'] # Verify that pyproject.toml is well formed - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.12.1 + rev: v0.24.1 hooks: - id: validate-pyproject name: Validate pyproject.toml @@ -92,7 +94,7 @@ repos: # supported by your project here, or alternatively use # pre-commit's default_language_version, see # https://pre-commit.com/#top_level-default_language_version - language_version: python3.10 + language_version: python3.12 # Run unit tests, verify that they pass. Note that coverage is run against # the ./src directory here because that is what will be committed. In the # github workflow script, the coverage is run against the installed package diff --git a/.setup_dev.sh b/.setup_dev.sh old mode 100644 new mode 100755 index d8cd955..5286e41 --- a/.setup_dev.sh +++ b/.setup_dev.sh @@ -1,10 +1,19 @@ #!/usr/bin/env bash +# Bash Unofficial strict mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/) +# and (https://disconnected.systems/blog/another-bash-strict-mode/) +set -o nounset # Any uninitialized variable is an error +set -o errexit # Exit the script on the failure of any command to execute without error +set -o pipefail # Fail command pipelines on the failure of any individual step +IFS=$'\n\t' #set internal field separator to avoid iteration errors +# Trap all exits and output something helpful +trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR + # This script should be run by new developers to install this package in # editable mode and configure their local environment echo "Checking virtual environment" -if [ -z "${VIRTUAL_ENV}" ] && [ -z "${CONDA_PREFIX}" ]; then +if [ "${VIRTUAL_ENV:-missing}" = "missing" ] && [ "${CONDA_PREFIX:-missing}" = "missing" ]; then echo 'No virtual environment detected: none of $VIRTUAL_ENV or $CONDA_PREFIX is set.' echo echo "=== This script is going to install the project in the system python environment ===" @@ -20,7 +29,7 @@ fi echo "Checking pip version" MINIMUM_PIP_VERSION=22 -pipversion=( $(python -m pip --version | awk '{print $2}' | sed 's/\./ /g') ) +pipversion=( $(python -m pip --version | awk '{print $2}' | sed 's/\./\n\t/g') ) if let "${pipversion[0]}<${MINIMUM_PIP_VERSION}"; then echo "Insufficient version of pip found. Requires at least version ${MINIMUM_PIP_VERSION}." echo "See https://lincc-ppt.readthedocs.io/ for details." @@ -32,7 +41,7 @@ python -m pip install -e . > /dev/null echo "Installing developer dependencies in local environment" python -m pip install -e .'[dev]' > /dev/null -if [ -f docs/requirements.txt ]; then python -m pip install -r docs/requirements.txt; fi +if [ -f docs/requirements.txt ]; then python -m pip install -r docs/requirements.txt > /dev/null; fi echo "Installing pre-commit" pre-commit install > /dev/null diff --git a/LICENSE b/LICENSE index aee3ea7..a376db5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2023, LINCC Frameworks +Copyright (c) 2025, LINCC Frameworks Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/pyproject.toml b/pyproject.toml index 36e261c..ddc8d4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,20 +1,21 @@ + [project] name = "template-version-check" -license = {file = "LICENSE"} +license = "BSD-3-Clause" +license-files = ["LICENSE"] readme = "README.md" authors = [ { name = "LINCC Frameworks", email = "lincc-frameworks-team@lists.lsst.org" } ] classifiers = [ "Development Status :: 4 - Beta", - "License :: OSI Approved :: BSD License", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Operating System :: OS Independent", "Programming Language :: Python", ] dynamic = ["version"] -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "pyyaml", "GitPython", @@ -50,60 +51,18 @@ write_to = "src/pre_commit_hooks/_version.py" [tool.pytest.ini_options] testpaths = [ "tests", + "src", + "docs", ] +addopts = "--doctest-modules --doctest-glob=*.rst" [tool.black] line-length = 110 -target-version = ["py39"] - +target-version = ["py310"] [tool.isort] profile = "black" line_length = 110 -[tool.ruff] -line-length = 110 -target-version = "py39" - -[tool.ruff.lint] -select = [ - # pycodestyle - "E", - "W", - # Pyflakes - "F", - # pep8-naming - "N", - # pyupgrade - "UP", - # flake8-bugbear - "B", - # flake8-simplify - "SIM", - # isort - "I", - # docstrings - "D101", - "D102", - "D103", - "D106", - "D206", - "D207", - "D208", - "D300", - "D417", - "D419", - -] - -ignore = [ - "UP006", # Allow non standard library generics in type hints - "UP007", # Allow Union in type hints - "SIM114", # Allow if with same arms - "B028", # Allow default warning level - "SIM117", # Allow nested with - "UP015", # Allow redundant open parameters - "UP028", # Allow yield in for loop -] [tool.coverage.run] omit=["src/pre_commit_hooks/_version.py"] diff --git a/src/.pylintrc b/src/.pylintrc index b9ac186..77d0371 100644 --- a/src/.pylintrc +++ b/src/.pylintrc @@ -1,3 +1,4 @@ + [MAIN] # Analyse import fallback blocks. This can be used to support both Python 2 and @@ -87,15 +88,11 @@ persistent=yes # Minimum Python version to use for version dependent checks. Will default to # the version used to run pylint. -py-version=3.9 +py-version=3.10 # Discover python modules and packages in the file system subtree. recursive=no -# 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 diff --git a/src/pre_commit_hooks/__init__.py b/src/pre_commit_hooks/__init__.py index 9e3610c..3741e2f 100644 --- a/src/pre_commit_hooks/__init__.py +++ b/src/pre_commit_hooks/__init__.py @@ -1 +1,4 @@ +from ._version import __version__ from .check_template_version import * + +__all__ = ["__version__"] diff --git a/src/pre_commit_hooks/check_template_version.py b/src/pre_commit_hooks/check_template_version.py index 3ace2c2..e6be64b 100644 --- a/src/pre_commit_hooks/check_template_version.py +++ b/src/pre_commit_hooks/check_template_version.py @@ -1,12 +1,12 @@ -"""This module is meant to be used in a pre-commit check for projects created +"""This module is meant to be used in a pre-commit check for projects created from a Copier template. -It compares the local template version against the remote template version. +It compares the local template version against the remote template version. It prints a message to the screen if the user should update their template. It will always pass the pre-commit check, i.e. it will always return 0. -The central tenet here is that we don't want to block the users work. We only +The central tenet here is that we don't want to block the users work. We only want to make them aware that they could update their template version. -Thus if there are any exceptions raise, we should just treat it as though the +Thus if there are any exceptions raise, we should just treat it as though the test passed and return 0. """ diff --git a/tests/.pylintrc b/tests/.pylintrc index b5afc24..efc8b0a 100644 --- a/tests/.pylintrc +++ b/tests/.pylintrc @@ -1,3 +1,4 @@ + [MAIN] # Analyse import fallback blocks. This can be used to support both Python 2 and @@ -87,15 +88,11 @@ persistent=yes # Minimum Python version to use for version dependent checks. Will default to # the version used to run pylint. -py-version=3.9 +py-version=3.10 # Discover python modules and packages in the file system subtree. recursive=no -# 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 diff --git a/tests/pre_commit_hooks/test_packaging.py b/tests/pre_commit_hooks/test_packaging.py new file mode 100644 index 0000000..70eceda --- /dev/null +++ b/tests/pre_commit_hooks/test_packaging.py @@ -0,0 +1,6 @@ +import pre_commit_hooks + + +def test_version(): + """Check to see that we can get the package version""" + assert pre_commit_hooks.__version__ is not None