Skip to content

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
simunili committed Jan 31, 2024
1 parent ed1b2ca commit 542ab7f
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ When you're ready to contribute code to address an open issue, please follow the

git clone https://github.com/USERNAME/python-package-template.git

or
or

git clone git@github.com:USERNAME/python-package-template.git

Expand Down
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["-a", "from __future__ import annotations"]

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/hadialqattan/pycln
rev: v1.2.5
hooks:
- id: pycln
args: [--config=pyproject.toml]
stages: [manual]

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/mgedmin/check-manifest
rev: "0.47"
hooks:
- id: check-manifest
stages: [manual]
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ python:
path: .
extra_requirements:
- dev

2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from __future__ import annotations

import logging
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion docs/source/overview.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Overview
========

4 changes: 4 additions & 0 deletions gitops/commit-template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[TYPE] Brief description of the change

- Detailed explanation of the change
- Additional context or information if necessary
31 changes: 31 additions & 0 deletions gitops/commit_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Check if the current directory is a Git repository
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
echo "Error: Not in a Git repository."
exit 1
fi

current_branch=$(git symbolic-ref --short HEAD)

# Check if there are any changes to commit
if [[ -n $(git status -s) ]]; then
git fetch origin "$current_branch"
git pull origin "$current_branch"

commit_template="./gitops/commit-template.txt"

if [ -f "$commit_template" ]; then
git config commit.template "$commit_template"
git commit
git config --unset commit.template
git push origin "$current_branch"

echo "Committed and pushed changes successfully."
else
echo "Commit template not found: $commit_template"
exit 1
fi
else
echo "No changes to commit."
fi
2 changes: 2 additions & 0 deletions my_package/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from __future__ import annotations

from .version import VERSION, VERSION_SHORT
6 changes: 4 additions & 2 deletions my_package/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

_MAJOR = "0"
_MINOR = "1"
# On main and in a nightly release the patch should be one ahead of the last
Expand All @@ -7,5 +9,5 @@
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = ""

VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
VERSION = "{0}.{1}.{2}{3}".format(_MAJOR, _MINOR, _PATCH, _SUFFIX)
VERSION_SHORT = f"{_MAJOR}.{_MINOR}"
VERSION = f"{_MAJOR}.{_MINOR}.{_PATCH}{_SUFFIX}"
4 changes: 3 additions & 1 deletion scripts/personalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This script is interactive and will prompt you for various inputs.
"""

from __future__ import annotations

import sys
from pathlib import Path
from typing import Generator, List, Tuple
Expand Down Expand Up @@ -157,7 +159,7 @@ def iterfiles(dir: Path) -> Generator[Path, None, None]:
yield path


def personalize_file(path: Path, dry_run: bool, replacements: List[Tuple[str, str]]):
def personalize_file(path: Path, dry_run: bool, replacements: list[tuple[str, str]]):
with path.open(mode="r+t", encoding="utf-8") as file:
filedata = file.read()

Expand Down
2 changes: 2 additions & 0 deletions scripts/prepare_changelog.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from datetime import datetime
from pathlib import Path

Expand Down
8 changes: 4 additions & 4 deletions scripts/release_notes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8

"""
Prepares markdown release notes for GitHub releases.
"""

from __future__ import annotations

import os
from typing import List, Optional

Expand All @@ -19,7 +19,7 @@

def get_change_log_notes() -> str:
in_current_section = False
current_section_notes: List[str] = []
current_section_notes: list[str] = []
with open("CHANGELOG.md") as changelog:
for line in changelog:
if line.startswith("## "):
Expand Down Expand Up @@ -55,7 +55,7 @@ def get_commit_history() -> str:
# Out of `all_tags`, find the latest previous version so that we can collect all
# commits between that version and the new version we're about to publish.
# Note that we ignore pre-releases unless the new version is also a pre-release.
last_tag: Optional[str] = None
last_tag: str | None = None
for tag in all_tags:
if not tag.strip(): # could be blank line
continue
Expand Down
3 changes: 3 additions & 0 deletions tests/hello_test.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
from __future__ import annotations


def test_hello():
print("Hello, World!")

0 comments on commit 542ab7f

Please sign in to comment.