Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix_typing
Browse files Browse the repository at this point in the history
  • Loading branch information
offbyone committed Sep 26, 2024
2 parents 8a1e8ed + 432c410 commit 95604e7
Show file tree
Hide file tree
Showing 10 changed files with 1,808 additions and 67 deletions.
48 changes: 25 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
USING_COVERAGE: "3.8,3.9,3.10,3.11,3.12"

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version:
Expand All @@ -32,25 +33,23 @@ jobs:
- "pypy3.9"
exclude:
- os: macos-latest
python-version: pypy3
python-version: pypy3.9

steps:
- uses: actions/checkout@v4
with:
# We want our tags here
fetch-depth: 0
- uses: actions/setup-python@v5
- name: Install the latest version of uv
id: setup-uv
uses: astral-sh/setup-uv@v3
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: |
python -VV
python -msite
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions
enable-cache: true

- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"
env:
TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }}
run: uvx --with tox-uv --with tox-gh tox

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


coverage:
needs:
- tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install the latest version of uv
id: setup-uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"

- name: Install coverage
run: python -m pip install --upgrade coverage[toml]
enable-cache: true

- name: Download coverage data
uses: actions/download-artifact@v4
Expand All @@ -81,11 +78,12 @@ jobs:
merge-multiple: true

- name: Combine coverage
run: python -m coverage combine
run: |
uvx --with coverage[toml] coverage combine
# ignore-errors is so that we don't gag on missing code in .tox environments
- name: Generate the HTML report
run: python -m coverage html --skip-covered --skip-empty --ignore-errors
run: uvx --with coverage[toml] coverage html --skip-covered --skip-empty --ignore-errors

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

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

package:
name: "Build & verify package"
Expand All @@ -118,10 +116,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install the latest version of uv
id: setup-uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
enable-cache: true
- name: "Install in dev mode"
run: "python -m pip install -e .[dev]"
run: |
uv venv
uv pip install -e .[dev]
- name: "Import package"
run: "python -c 'import hamcrest; print(hamcrest.__version__)'"
run: "uv run python -c 'import hamcrest; print(hamcrest.__version__)'"
26 changes: 10 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,22 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: debug-statements

- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
rev: 1.18.0
hooks:
- id: blacken-docs
# args: ["-l100"]

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.8
hooks:
- id: flake8
exclude: >-
(?x)^(
examples/.*\.py$
| doc/.*\.py$
)
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
# args: ["-l100"]
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
3 changes: 2 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import sys
import os
import alabaster

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ dev = [
"flake8",
"black",
"tox",
"tox-asdf",
"tox-uv",
"doc2dash",
]

Expand Down Expand Up @@ -137,6 +137,20 @@ exclude_lines = [
"-> ['\"]?NoReturn['\"]?:",
]

[tool.ruff]
exclude = [
# re-ordering in this can lead to circular imports. No good!
"src/hamcrest/__init__.py",
]
line-length = 100

[tool.ruff.lint]
ignore = [
# We use star imports everywhere in this damn codebase
"F405",
"F403"
]

[tool.black]
line_length = 100

Expand Down
2 changes: 2 additions & 0 deletions src/hamcrest/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ruff: noqa: F405, F403

from hamcrest.core.assert_that import assert_that
from hamcrest.core.core import *

Expand Down
1 change: 1 addition & 0 deletions src/hamcrest/library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Library of Matcher implementations."""

# ruff: noqa: F405, F403
from hamcrest.core import *
from hamcrest.library.collection import *
from hamcrest.library.integration import *
Expand Down
2 changes: 1 addition & 1 deletion tests/hamcrest_unit_test/assert_that_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def testAssertionErrorShouldIncludeOptionalReason(self):

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

with self.assertRaises(AssertionError):
assert_that(actual, equal_to(expected), "REASON")
Expand Down
4 changes: 2 additions & 2 deletions tests/hamcrest_unit_test/base_description_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def test_append_text_delegates(desc):
("unicode-py3", "'unicode-py3'"),
(b"bytes-py3", "<b'bytes-py3'>"),
pytest.param(
"\U0001F4A9",
"'{0}'".format("\U0001F4A9"),
"\U0001f4a9",
"'{0}'".format("\U0001f4a9"),
marks=pytest.mark.skipif(
platform.python_implementation() == "PyPy",
reason="Inexplicable failure on PyPy. Not super important, I hope!",
Expand Down
31 changes: 8 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ looponfailroots =


# Keep docs in sync with docs env and .readthedocs.yml.
[gh-actions]
[gh]
python =
3.8: py38, py38-numpy
3.9: py39, py39-numpy
3.10: py310, py310-numpy
3.11: py311, py311-numpy
3.12: py312, py312-numpy, lint, changelog, typing, manifest, docs
pypy-2: pypy2
pypy-3: pypy3
3.8 = py38, py38-numpy
3.9 = py39, py39-numpy
3.10 = py310, py310-numpy
3.11 = py311, py311-numpy
3.12 = py312, py312-numpy, lint, changelog, typing, docs
pypy3.9 = pypy3


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


Expand Down Expand Up @@ -65,7 +64,6 @@ commands = python -m pytest {posargs}
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
basepython = python3.8
install_command = pip install --no-compile {opts} {packages}
setenv =
PYTHONWARNINGS=d
extras = {env:TOX_AP_TEST_EXTRAS:tests}
Expand All @@ -76,7 +74,6 @@ commands = coverage run -m pytest {posargs}
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
basepython = python3.9
install_command = pip install --no-compile {opts} {packages}
setenv =
PYTHONWARNINGS=d
extras = {env:TOX_AP_TEST_EXTRAS:tests}
Expand All @@ -87,7 +84,6 @@ commands = coverage run -m pytest {posargs}
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
basepython = python3.10
install_command = pip install --no-compile {opts} {packages}
setenv =
PYTHONWARNINGS=d
extras = {env:TOX_AP_TEST_EXTRAS:tests}
Expand All @@ -98,7 +94,6 @@ commands = coverage run -m pytest {posargs}
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
basepython = python3.11
install_command = pip install --no-compile {opts} {packages}
setenv =
PYTHONWARNINGS=d
extras = {env:TOX_AP_TEST_EXTRAS:tests}
Expand All @@ -109,7 +104,6 @@ commands = coverage run -m pytest {posargs}
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run.
basepython = python3.12
install_command = pip install --no-compile {opts} {packages}
setenv =
PYTHONWARNINGS=d
extras = {env:TOX_AP_TEST_EXTRAS:tests}
Expand Down Expand Up @@ -143,15 +137,6 @@ commands =
sphinx-build -n -T -b html -d {envtmpdir}/doctrees doc doc/_build/html


[testenv:manifest]
basepython = python3.12
deps =
check-manifest
setuptools-scm
skip_install = true
commands = check-manifest --ignore src/hamcrest/_version.py


[testenv:pypi-description]
basepython = python3.12
skip_install = true
Expand Down
Loading

0 comments on commit 95604e7

Please sign in to comment.