Skip to content

Commit 95604e7

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix_typing
2 parents 8a1e8ed + 432c410 commit 95604e7

File tree

10 files changed

+1808
-67
lines changed

10 files changed

+1808
-67
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
USING_COVERAGE: "3.8,3.9,3.10,3.11,3.12"
2222

2323
strategy:
24+
fail-fast: false
2425
matrix:
2526
os: [ubuntu-latest, macos-latest, windows-latest]
2627
python-version:
@@ -32,25 +33,23 @@ jobs:
3233
- "pypy3.9"
3334
exclude:
3435
- os: macos-latest
35-
python-version: pypy3
36+
python-version: pypy3.9
3637

3738
steps:
3839
- uses: actions/checkout@v4
3940
with:
4041
# We want our tags here
4142
fetch-depth: 0
42-
- uses: actions/setup-python@v5
43+
- name: Install the latest version of uv
44+
id: setup-uv
45+
uses: astral-sh/setup-uv@v3
4346
with:
44-
python-version: "${{ matrix.python-version }}"
45-
- name: "Install dependencies"
46-
run: |
47-
python -VV
48-
python -msite
49-
python -m pip install --upgrade pip setuptools wheel
50-
python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions
47+
enable-cache: true
5148

5249
- name: "Run tox targets for ${{ matrix.python-version }}"
53-
run: "python -m tox"
50+
env:
51+
TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }}
52+
run: uvx --with tox-uv --with tox-gh tox
5453

5554
- name: Upload coverage data
5655
uses: actions/upload-artifact@v4
@@ -60,19 +59,17 @@ jobs:
6059
if-no-files-found: ignore
6160
include-hidden-files: true
6261

63-
6462
coverage:
6563
needs:
6664
- tests
6765
runs-on: ubuntu-latest
6866
steps:
6967
- uses: actions/checkout@v4
70-
- uses: actions/setup-python@v5
68+
- name: Install the latest version of uv
69+
id: setup-uv
70+
uses: astral-sh/setup-uv@v3
7171
with:
72-
python-version: "3.12"
73-
74-
- name: Install coverage
75-
run: python -m pip install --upgrade coverage[toml]
72+
enable-cache: true
7673

7774
- name: Download coverage data
7875
uses: actions/download-artifact@v4
@@ -81,11 +78,12 @@ jobs:
8178
merge-multiple: true
8279

8380
- name: Combine coverage
84-
run: python -m coverage combine
81+
run: |
82+
uvx --with coverage[toml] coverage combine
8583
8684
# ignore-errors is so that we don't gag on missing code in .tox environments
8785
- name: Generate the HTML report
88-
run: python -m coverage html --skip-covered --skip-empty --ignore-errors
86+
run: uvx --with coverage[toml] coverage html --skip-covered --skip-empty --ignore-errors
8987

9088
- name: Upload the HTML report
9189
uses: actions/upload-artifact@v4
@@ -95,7 +93,7 @@ jobs:
9593

9694
# ignore-errors is so that we don't gag on missing code in .tox environments
9795
- name: Enforce the coverage
98-
run: python -m coverage report --ignore-errors --fail-under 95
96+
run: uvx --with coverage[toml] coverage report --ignore-errors --fail-under 95
9997

10098
package:
10199
name: "Build & verify package"
@@ -118,10 +116,14 @@ jobs:
118116

119117
steps:
120118
- uses: actions/checkout@v4
121-
- uses: actions/setup-python@v5
119+
- name: Install the latest version of uv
120+
id: setup-uv
121+
uses: astral-sh/setup-uv@v3
122122
with:
123-
python-version: "3.12"
123+
enable-cache: true
124124
- name: "Install in dev mode"
125-
run: "python -m pip install -e .[dev]"
125+
run: |
126+
uv venv
127+
uv pip install -e .[dev]
126128
- name: "Import package"
127-
run: "python -c 'import hamcrest; print(hamcrest.__version__)'"
129+
run: "uv run python -c 'import hamcrest; print(hamcrest.__version__)'"

.pre-commit-config.yaml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,22 @@ repos:
55
- id: check-useless-excludes
66

77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v4.5.0
8+
rev: v4.6.0
99
hooks:
1010
- id: debug-statements
1111

1212
- repo: https://github.com/asottile/blacken-docs
13-
rev: 1.16.0
13+
rev: 1.18.0
1414
hooks:
1515
- id: blacken-docs
1616
# args: ["-l100"]
1717

18-
- repo: https://github.com/PyCQA/flake8
19-
rev: 7.0.0
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
# Ruff version.
20+
rev: v0.6.8
2021
hooks:
21-
- id: flake8
22-
exclude: >-
23-
(?x)^(
24-
examples/.*\.py$
25-
| doc/.*\.py$
26-
)
27-
28-
- repo: https://github.com/psf/black
29-
rev: 23.12.1
30-
hooks:
31-
- id: black
32-
# args: ["-l100"]
22+
# Run the linter.
23+
- id: ruff
24+
args: [ --fix ]
25+
# Run the formatter.
26+
- id: ruff-format

doc/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
14+
import sys
15+
import os
1516
import alabaster
1617

1718
# If extensions (or modules to document with autodoc) are in another directory,

pyproject.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ dev = [
7272
"flake8",
7373
"black",
7474
"tox",
75-
"tox-asdf",
75+
"tox-uv",
7676
"doc2dash",
7777
]
7878

@@ -137,6 +137,20 @@ exclude_lines = [
137137
"-> ['\"]?NoReturn['\"]?:",
138138
]
139139

140+
[tool.ruff]
141+
exclude = [
142+
# re-ordering in this can lead to circular imports. No good!
143+
"src/hamcrest/__init__.py",
144+
]
145+
line-length = 100
146+
147+
[tool.ruff.lint]
148+
ignore = [
149+
# We use star imports everywhere in this damn codebase
150+
"F405",
151+
"F403"
152+
]
153+
140154
[tool.black]
141155
line_length = 100
142156

src/hamcrest/core/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# ruff: noqa: F405, F403
2+
13
from hamcrest.core.assert_that import assert_that
24
from hamcrest.core.core import *
35

src/hamcrest/library/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Library of Matcher implementations."""
22

3+
# ruff: noqa: F405, F403
34
from hamcrest.core import *
45
from hamcrest.library.collection import *
56
from hamcrest.library.integration import *

tests/hamcrest_unit_test/assert_that_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def testAssertionErrorShouldIncludeOptionalReason(self):
4343

4444
def testAssertionUnicodeEncodesProperly(self):
4545
expected = "EXPECTED"
46-
actual = u("\xdcnic\N{Latin Small Letter O with diaeresis}de")
46+
actual = u("\xdcnic\N{LATIN SMALL LETTER O WITH DIAERESIS}de")
4747

4848
with self.assertRaises(AssertionError):
4949
assert_that(actual, equal_to(expected), "REASON")

tests/hamcrest_unit_test/base_description_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def test_append_text_delegates(desc):
4242
("unicode-py3", "'unicode-py3'"),
4343
(b"bytes-py3", "<b'bytes-py3'>"),
4444
pytest.param(
45-
"\U0001F4A9",
46-
"'{0}'".format("\U0001F4A9"),
45+
"\U0001f4a9",
46+
"'{0}'".format("\U0001f4a9"),
4747
marks=pytest.mark.skipif(
4848
platform.python_implementation() == "PyPy",
4949
reason="Inexplicable failure on PyPy. Not super important, I hope!",

tox.ini

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ looponfailroots =
1111

1212

1313
# Keep docs in sync with docs env and .readthedocs.yml.
14-
[gh-actions]
14+
[gh]
1515
python =
16-
3.8: py38, py38-numpy
17-
3.9: py39, py39-numpy
18-
3.10: py310, py310-numpy
19-
3.11: py311, py311-numpy
20-
3.12: py312, py312-numpy, lint, changelog, typing, manifest, docs
21-
pypy-2: pypy2
22-
pypy-3: pypy3
16+
3.8 = py38, py38-numpy
17+
3.9 = py39, py39-numpy
18+
3.10 = py310, py310-numpy
19+
3.11 = py311, py311-numpy
20+
3.12 = py312, py312-numpy, lint, changelog, typing, docs
21+
pypy3.9 = pypy3
2322

2423

2524
[tox]
26-
envlist = typing,lint,py38{,-numpy},py39{,-numpy},py310{,-numpy},py311{,-numpy},py312{,-numpy},pypy{,-numpy},pypy3{,-numpy},manifest,docs,pypi-description,changelog,coverage-report
25+
envlist = typing,lint,py38{,-numpy},py39{,-numpy},py310{,-numpy},py311{,-numpy},py312{,-numpy},pypy{,-numpy},pypy3{,-numpy},docs,pypi-description,changelog,coverage-report
2726
isolated_build = True
2827

2928

@@ -65,7 +64,6 @@ commands = python -m pytest {posargs}
6564
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
6665
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
6766
basepython = python3.8
68-
install_command = pip install --no-compile {opts} {packages}
6967
setenv =
7068
PYTHONWARNINGS=d
7169
extras = {env:TOX_AP_TEST_EXTRAS:tests}
@@ -76,7 +74,6 @@ commands = coverage run -m pytest {posargs}
7674
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
7775
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
7876
basepython = python3.9
79-
install_command = pip install --no-compile {opts} {packages}
8077
setenv =
8178
PYTHONWARNINGS=d
8279
extras = {env:TOX_AP_TEST_EXTRAS:tests}
@@ -87,7 +84,6 @@ commands = coverage run -m pytest {posargs}
8784
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
8885
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
8986
basepython = python3.10
90-
install_command = pip install --no-compile {opts} {packages}
9187
setenv =
9288
PYTHONWARNINGS=d
9389
extras = {env:TOX_AP_TEST_EXTRAS:tests}
@@ -98,7 +94,6 @@ commands = coverage run -m pytest {posargs}
9894
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
9995
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
10096
basepython = python3.11
101-
install_command = pip install --no-compile {opts} {packages}
10297
setenv =
10398
PYTHONWARNINGS=d
10499
extras = {env:TOX_AP_TEST_EXTRAS:tests}
@@ -109,7 +104,6 @@ commands = coverage run -m pytest {posargs}
109104
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
110105
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
111106
basepython = python3.12
112-
install_command = pip install --no-compile {opts} {packages}
113107
setenv =
114108
PYTHONWARNINGS=d
115109
extras = {env:TOX_AP_TEST_EXTRAS:tests}
@@ -143,15 +137,6 @@ commands =
143137
sphinx-build -n -T -b html -d {envtmpdir}/doctrees doc doc/_build/html
144138

145139

146-
[testenv:manifest]
147-
basepython = python3.12
148-
deps =
149-
check-manifest
150-
setuptools-scm
151-
skip_install = true
152-
commands = check-manifest --ignore src/hamcrest/_version.py
153-
154-
155140
[testenv:pypi-description]
156141
basepython = python3.12
157142
skip_install = true

0 commit comments

Comments
 (0)