Skip to content

Commit 1f789b0

Browse files
authored
Merge branch 'main' into add-gh-flags
2 parents 5fe40bd + a0829f7 commit 1f789b0

11 files changed

Lines changed: 81 additions & 18 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
permissions:
1212
contents: read
1313

14+
env:
15+
FORCE_COLOR: 1
16+
1417
jobs:
1518
# Always build & lint package.
1619
build-package:
@@ -47,6 +50,7 @@ jobs:
4750
- name: Publish to Test PyPI
4851
uses: pypa/gh-action-pypi-publish@release/v1
4952
with:
53+
attestations: true
5054
repository-url: https://test.pypi.org/legacy/
5155

5256
# Publish to PyPI on GitHub Releases.
@@ -78,3 +82,5 @@ jobs:
7882

7983
- name: Publish to PyPI
8084
uses: pypa/gh-action-pypi-publish@release/v1
85+
with:
86+
attestations: true

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Test
22

33
on: [push, pull_request, workflow_dispatch]
44

5+
permissions:
6+
contents: read
7+
58
env:
69
FORCE_COLOR: 1
710

@@ -11,7 +14,7 @@ jobs:
1114
strategy:
1215
fail-fast: false
1316
matrix:
14-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1518

1619
steps:
1720
- uses: actions/checkout@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ ENV/
9090

9191
# pytest
9292
.pytest_cache/
93+
94+
# hatch-vcs
95+
src/*/_version.py

.pre-commit-config.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,39 @@ repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
33
rev: v4.6.0
44
hooks:
5+
- id: check-added-large-files
56
- id: check-case-conflict
67
- id: check-merge-conflict
78
- id: check-toml
89
- id: check-yaml
910
- id: debug-statements
1011
- id: end-of-file-fixer
12+
- id: forbid-submodules
1113
- id: trailing-whitespace
1214

15+
- repo: https://github.com/python-jsonschema/check-jsonschema
16+
rev: 0.29.2
17+
hooks:
18+
- id: check-dependabot
19+
- id: check-github-workflows
20+
21+
- repo: https://github.com/rhysd/actionlint
22+
rev: v1.7.2
23+
hooks:
24+
- id: actionlint
25+
1326
- repo: https://github.com/tox-dev/pyproject-fmt
14-
rev: 2.1.3
27+
rev: 2.2.4
1528
hooks:
1629
- id: pyproject-fmt
1730

1831
- repo: https://github.com/abravalheri/validate-pyproject
19-
rev: v0.18
32+
rev: v0.20.2
2033
hooks:
2134
- id: validate-pyproject
2235

2336
- repo: https://github.com/tox-dev/tox-ini-fmt
24-
rev: 1.3.1
37+
rev: 1.4.1
2538
hooks:
2639
- id: tox-ini-fmt
2740

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
# Changelog
22

3-
## 1.2.2
3+
## 1.3.1
44

55
- Add the `-i/--issue` and `-s/--section` options to the `add` command.
66
This lets you pre-fill the `gh-issue` and `section` fields in the template.
7+
Added by @picnixz in https://github.com/python/blurb/pull/16.
8+
9+
## 1.3.0
10+
11+
* Add support for Python 3.13 by @hugovk in https://github.com/python/blurb/pull/26
12+
* Drop support for Python 3.8 by @hugovk in https://github.com/python/blurb/pull/27
13+
* Generate digital attestations for PyPI (PEP 740) by @hugovk in https://github.com/python/blurb/pull/28
14+
* Allow running blurb test from blurb-* directories by @hroncok in https://github.com/python/blurb/pull/24
15+
* Add `version` subcommand by @hugovk in https://github.com/python/blurb/pull/29
16+
* Generate `__version__` at build to avoid slow `importlib.metadata` import by @hugovk in https://github.com/python/blurb/pull/30
717

818
## 1.2.1
919

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ and automatically uses the correct file paths.
2626
You can install **blurb** from PyPI using `pip`. Alternatively,
2727
simply add `blurb` to a directory on your path.
2828

29-
**blurb**'s only dependency is Python 3.8+.
30-
3129

3230
## Files used by blurb
3331

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ maintainers = [
1515
authors = [
1616
{ name = "Larry Hastings", email = "larry@hastings.org" },
1717
]
18-
requires-python = ">=3.8"
18+
requires-python = ">=3.9"
1919
classifiers = [
2020
"Intended Audience :: Developers",
2121
"License :: OSI Approved :: BSD License",
2222
"Programming Language :: Python :: 3 :: Only",
23-
"Programming Language :: Python :: 3.8",
2423
"Programming Language :: Python :: 3.9",
2524
"Programming Language :: Python :: 3.10",
2625
"Programming Language :: Python :: 3.11",
@@ -43,6 +42,9 @@ scripts.blurb = "blurb.blurb:main"
4342
[tool.hatch]
4443
version.source = "vcs"
4544

45+
[tool.hatch.build.hooks.vcs]
46+
version-file = "src/blurb/_version.py"
47+
4648
[tool.hatch.version.raw-options]
4749
local_scheme = "no-local-version"
4850

src/blurb/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import importlib.metadata
2-
3-
__version__ = importlib.metadata.version(__name__)
1+
from ._version import __version__

src/blurb/blurb.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def save_next(self):
645645
tests_run = 0
646646

647647
class TestParserPasses(unittest.TestCase):
648-
directory = "blurb/tests/pass"
648+
directory = "tests/pass"
649649

650650
def filename_test(self, filename):
651651
b = Blurbs()
@@ -670,7 +670,7 @@ def test_files(self):
670670

671671

672672
class TestParserFailures(TestParserPasses):
673-
directory = "blurb/tests/fail"
673+
directory = "tests/fail"
674674

675675
def filename_test(self, filename):
676676
b = Blurbs()
@@ -745,6 +745,13 @@ def get_subcommand(subcommand):
745745

746746

747747

748+
@subcommand
749+
def version():
750+
"""Print blurb version."""
751+
print("blurb version", __version__)
752+
753+
754+
748755
@subcommand
749756
def help(subcommand=None):
750757
"""
@@ -826,8 +833,19 @@ def help(subcommand=None):
826833
print(doc)
827834
sys.exit(0)
828835

829-
# Make "blurb --help" work.
836+
# Make "blurb --help/--version/-V" work.
830837
subcommands["--help"] = help
838+
subcommands["--version"] = version
839+
subcommands["-V"] = version
840+
841+
842+
def _find_blurb_dir():
843+
if os.path.isdir("blurb"):
844+
return "blurb"
845+
for path in glob.iglob("blurb-*"):
846+
if os.path.isdir(path):
847+
return path
848+
return None
831849

832850

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

841-
while not os.path.isdir("blurb"):
859+
while (blurb_dir := _find_blurb_dir()) is None:
842860
old_dir = os.getcwd()
843861
os.chdir("..")
844862
if old_dir == os.getcwd():
845863
# we reached the root and never found it!
846864
sys.exit("Error: Couldn't find the root of your blurb repo!")
865+
os.chdir(blurb_dir)
847866

848867
print("-" * 79)
849868

@@ -1379,7 +1398,7 @@ def main():
13791398
fn = get_subcommand(subcommand)
13801399

13811400
# hack
1382-
if fn in (test, help):
1401+
if fn in (help, test, version):
13831402
sys.exit(fn(*args))
13841403

13851404
try:

tests/test_blurb.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,12 @@ def test_extract_next_filename(news_entry, expected_path, fs):
186186

187187
# Assert
188188
assert path == expected_path
189+
190+
191+
def test_version(capfd):
192+
# Act
193+
blurb.version()
194+
195+
# Assert
196+
captured = capfd.readouterr()
197+
assert captured.out.startswith("blurb version ")

0 commit comments

Comments
 (0)