Skip to content

Commit

Permalink
Merge branch 'main' into add-gh-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz authored Nov 1, 2024
2 parents 5fe40bd + a0829f7 commit 1f789b0
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
permissions:
contents: read

env:
FORCE_COLOR: 1

jobs:
# Always build & lint package.
build-package:
Expand Down Expand Up @@ -47,6 +50,7 @@ jobs:
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
repository-url: https://test.pypi.org/legacy/

# Publish to PyPI on GitHub Releases.
Expand Down Expand Up @@ -78,3 +82,5 @@ jobs:

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Test

on: [push, pull_request, workflow_dispatch]

permissions:
contents: read

env:
FORCE_COLOR: 1

Expand All @@ -11,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ ENV/

# pytest
.pytest_cache/

# hatch-vcs
src/*/_version.py
19 changes: 16 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,39 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-submodules
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.2
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/rhysd/actionlint
rev: v1.7.2
hooks:
- id: actionlint

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.1.3
rev: 2.2.4
hooks:
- id: pyproject-fmt

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.18
rev: v0.20.2
hooks:
- id: validate-pyproject

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.1
rev: 1.4.1
hooks:
- id: tox-ini-fmt

Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Changelog

## 1.2.2
## 1.3.1

- Add the `-i/--issue` and `-s/--section` options to the `add` command.
This lets you pre-fill the `gh-issue` and `section` fields in the template.
Added by @picnixz in https://github.com/python/blurb/pull/16.

## 1.3.0

* Add support for Python 3.13 by @hugovk in https://github.com/python/blurb/pull/26
* Drop support for Python 3.8 by @hugovk in https://github.com/python/blurb/pull/27
* Generate digital attestations for PyPI (PEP 740) by @hugovk in https://github.com/python/blurb/pull/28
* Allow running blurb test from blurb-* directories by @hroncok in https://github.com/python/blurb/pull/24
* Add `version` subcommand by @hugovk in https://github.com/python/blurb/pull/29
* Generate `__version__` at build to avoid slow `importlib.metadata` import by @hugovk in https://github.com/python/blurb/pull/30

## 1.2.1

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ and automatically uses the correct file paths.
You can install **blurb** from PyPI using `pip`. Alternatively,
simply add `blurb` to a directory on your path.

**blurb**'s only dependency is Python 3.8+.


## Files used by blurb

Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ maintainers = [
authors = [
{ name = "Larry Hastings", email = "[email protected]" },
]
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -43,6 +42,9 @@ scripts.blurb = "blurb.blurb:main"
[tool.hatch]
version.source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/blurb/_version.py"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

Expand Down
4 changes: 1 addition & 3 deletions src/blurb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import importlib.metadata

__version__ = importlib.metadata.version(__name__)
from ._version import __version__
29 changes: 24 additions & 5 deletions src/blurb/blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def save_next(self):
tests_run = 0

class TestParserPasses(unittest.TestCase):
directory = "blurb/tests/pass"
directory = "tests/pass"

def filename_test(self, filename):
b = Blurbs()
Expand All @@ -670,7 +670,7 @@ def test_files(self):


class TestParserFailures(TestParserPasses):
directory = "blurb/tests/fail"
directory = "tests/fail"

def filename_test(self, filename):
b = Blurbs()
Expand Down Expand Up @@ -745,6 +745,13 @@ def get_subcommand(subcommand):



@subcommand
def version():
"""Print blurb version."""
print("blurb version", __version__)



@subcommand
def help(subcommand=None):
"""
Expand Down Expand Up @@ -826,8 +833,19 @@ def help(subcommand=None):
print(doc)
sys.exit(0)

# Make "blurb --help" work.
# Make "blurb --help/--version/-V" work.
subcommands["--help"] = help
subcommands["--version"] = version
subcommands["-V"] = version


def _find_blurb_dir():
if os.path.isdir("blurb"):
return "blurb"
for path in glob.iglob("blurb-*"):
if os.path.isdir(path):
return path
return None


@subcommand
Expand All @@ -838,12 +856,13 @@ def test(*args):
# unittest.main doesn't work because this isn't a module
# so we'll do it ourselves

while not os.path.isdir("blurb"):
while (blurb_dir := _find_blurb_dir()) is None:
old_dir = os.getcwd()
os.chdir("..")
if old_dir == os.getcwd():
# we reached the root and never found it!
sys.exit("Error: Couldn't find the root of your blurb repo!")
os.chdir(blurb_dir)

print("-" * 79)

Expand Down Expand Up @@ -1379,7 +1398,7 @@ def main():
fn = get_subcommand(subcommand)

# hack
if fn in (test, help):
if fn in (help, test, version):
sys.exit(fn(*args))

try:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,12 @@ def test_extract_next_filename(news_entry, expected_path, fs):

# Assert
assert path == expected_path


def test_version(capfd):
# Act
blurb.version()

# Assert
captured = capfd.readouterr()
assert captured.out.startswith("blurb version ")
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
requires =
tox>=4.2
env_list =
py{313, 312, 311, 310, 39, 38}
py{313, 312, 311, 310, 39}

[testenv]
extras =
Expand All @@ -19,5 +19,7 @@ commands =
{posargs}
blurb test
blurb help
blurb --version
{envpython} -I -m blurb test
{envpython} -I -m blurb help
{envpython} -I -m blurb version

0 comments on commit 1f789b0

Please sign in to comment.