Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
author_name: LINCC Frameworks
Expand All @@ -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
10 changes: 7 additions & 3 deletions .github/ISSUE_TEMPLATE/1-bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- [ ] 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.
10 changes: 6 additions & 4 deletions .github/workflows/pre-commit-ci.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/[email protected]
with:
extra_args: --all-files --verbose
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ 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
- name: Set up Python ${{ matrix.python-version }}
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
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/testing-and-coverage.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -15,20 +16,21 @@ 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
- name: Set up Python ${{ matrix.python-version }}
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
Expand Down
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions .setup_dev.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 ==="
Expand All @@ -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."
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2023, LINCC Frameworks
Copyright (c) 2025, LINCC Frameworks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time to update the lincense in PPT


Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
57 changes: 8 additions & 49 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" }
]
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",
Expand Down Expand Up @@ -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"]
7 changes: 2 additions & 5 deletions src/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[MAIN]

# Analyse import fallback blocks. This can be used to support both Python 2 and
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/pre_commit_hooks/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from ._version import __version__
from .check_template_version import *

__all__ = ["__version__"]
8 changes: 4 additions & 4 deletions src/pre_commit_hooks/check_template_version.py
Original file line number Diff line number Diff line change
@@ -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.
"""

Expand Down
7 changes: 2 additions & 5 deletions tests/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[MAIN]

# Analyse import fallback blocks. This can be used to support both Python 2 and
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/pre_commit_hooks/test_packaging.py
Original file line number Diff line number Diff line change
@@ -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
Loading