Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: agronholm/exceptiongroup
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.1.1
Choose a base ref
...
head repository: agronholm/exceptiongroup
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.1.2
Choose a head ref
  • 13 commits
  • 10 files changed
  • 3 contributors

Commits on Mar 13, 2023

  1. Include tests in sdist (#59)

    Include tests when building sdist archives, in order to make them
    a suitable source for distributions.
    mgorny authored Mar 13, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    abmusse Abdirahim Musse
    Copy the full SHA
    29424d4 View commit details
  2. Use develop install when running the testing suite

    This should fix the test coverage being reported incorrectly.
    agronholm committed Mar 13, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    aduh95 Antoine du Hamel
    Copy the full SHA
    406dc8c View commit details

Commits on Apr 4, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#60)

    updates:
    - [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored Apr 4, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    aduh95 Antoine du Hamel
    Copy the full SHA
    19e1ff2 View commit details

Commits on May 1, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#61)

    updates:
    - [github.com/asottile/pyupgrade: v3.3.1 → v3.3.2](asottile/pyupgrade@v3.3.1...v3.3.2)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored May 1, 2023
    Copy the full SHA
    516e532 View commit details

Commits on May 9, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#62)

    updates:
    - [github.com/asottile/pyupgrade: v3.3.2 → v3.4.0](asottile/pyupgrade@v3.3.2...v3.4.0)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored May 9, 2023
    Copy the full SHA
    c604dd8 View commit details

Commits on Jun 12, 2023

  1. [pre-commit.ci] pre-commit autoupdate (#63)

    updates:
    - [github.com/asottile/pyupgrade: v3.4.0 → v3.6.0](asottile/pyupgrade@v3.4.0...v3.6.0)
    
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    pre-commit-ci[bot] authored Jun 12, 2023
    Copy the full SHA
    9bfc03f View commit details

Commits on Jul 2, 2023

  1. Copy the full SHA
    0d63387 View commit details
  2. Copy the full SHA
    c926b0a View commit details
  3. Fixed coveralls reporting

    agronholm committed Jul 2, 2023
    Copy the full SHA
    111f338 View commit details
  4. Copy the full SHA
    cad96f6 View commit details
  5. Fixed pre-commit error

    agronholm committed Jul 2, 2023
    Copy the full SHA
    8a104eb View commit details
  6. Changed handling of a single exception raised in exception group hand…

    …lers to match Python 3.11.4
    
    Fixes #64.
    agronholm committed Jul 2, 2023
    Copy the full SHA
    821d5eb View commit details

Commits on Jul 3, 2023

  1. Added the release version

    agronholm committed Jul 3, 2023
    Copy the full SHA
    571b121 View commit details
Showing with 53 additions and 70 deletions.
  1. +11 −17 .github/workflows/test.yml
  2. +1 −0 .gitignore
  3. +9 −25 .pre-commit-config.yaml
  4. +6 −0 CHANGES.rst
  5. +17 −10 pyproject.toml
  6. +4 −1 src/exceptiongroup/_catch.py
  7. +1 −1 src/exceptiongroup/_exceptions.py
  8. +1 −7 tests/test_catch.py
  9. +1 −7 tests/test_catch_py311.py
  10. +2 −2 tests/test_exceptions.py
28 changes: 11 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -27,38 +27,32 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", pypy-3.8]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", pypy-3.10]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-test-${{ matrix.python-version }}-${{ matrix.os }}
allow-prereleases: true
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: pip install .[test] coveralls coverage[toml]
run: pip install -e .[test] coverage
- name: Test with pytest
run: coverage run -m pytest
- name: Upload Coverage
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
COVERALLS_PARALLEL: true
uses: coverallsapp/github-action@v2
with:
parallel: true

coveralls:
name: Finish Coveralls
needs: test
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip install coveralls
coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ __pycache__
.coverage
.pytest_cache/
.mypy_cache/
.ruff_cache/
.eggs/
.tox
.idea
34 changes: 9 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -15,37 +15,21 @@ repos:
args: ["--fix=lf"]
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.6.0
hooks:
- id: pyupgrade
args: ["--py37-plus", "--keep-runtime-typing"]

- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
hooks:
- id: black
exclude: "tests/test_catch_py311.py"
- id: ruff
args: [--fix, --show-fixes]
exclude: "tests/test_catch_py311.py"

- repo: https://github.com/csachs/pyproject-flake8
rev: v6.0.0.post1
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: pyproject-flake8
additional_dependencies: [flake8-bugbear]
- id: black
exclude: "tests/test_catch_py311.py"

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -3,6 +3,12 @@ Version history

This library adheres to `Semantic Versioning 2.0 <http://semver.org/>`_.

**1.1.2**

- Changed handling of exceptions in exception group handler callbacks to not wrap a
single exception in an exception group, as per
`CPython issue 103590 <https://github.com/python/cpython/issues/103590>`_

**1.1.1**

- Worked around
27 changes: 17 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -30,6 +30,9 @@ test = [
]

[tool.flit.sdist]
include = [
"tests",
]
exclude = [
".github/*",
".gitignore",
@@ -41,16 +44,19 @@ version_scheme = "post-release"
local_scheme = "dirty-tag"
write_to = "src/exceptiongroup/_version.py"

[tool.black]
target-version = ['py37']

[tool.isort]
src_paths = ["src"]
skip_gitignore = true
profile = "black"
[tool.ruff]
line-length = 88
select = [
"E", "F", "W", # default flake-8
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
]
target-version = "py37"

[tool.flake8]
max-line-length = 88
[tool.ruff.isort]
known-first-party = ["exceptiongroup"]

[tool.pytest.ini_options]
addopts = "-rsx --tb=short --strict-config --strict-markers"
@@ -69,13 +75,14 @@ exclude_lines = [
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py37, py38, py39, py310, py311, pypy3
envlist = py37, py38, py39, py310, py311, py312, pypy3
skip_missing_interpreters = true
minversion = 4.0
[testenv]
extras = test
commands = python -m pytest {posargs}
usedevelop = true
[testenv:pyright]
deps = pyright
5 changes: 4 additions & 1 deletion src/exceptiongroup/_catch.py
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ def __exit__(

return False

def handle_exception(self, exc: BaseException) -> BaseExceptionGroup | None:
def handle_exception(self, exc: BaseException) -> BaseException | None:
excgroup: BaseExceptionGroup | None
if isinstance(exc, BaseExceptionGroup):
excgroup = exc
@@ -57,6 +57,9 @@ def handle_exception(self, exc: BaseException) -> BaseExceptionGroup | None:
break

if new_exceptions:
if len(new_exceptions) == 1:
return new_exceptions[0]

if excgroup:
new_exceptions.append(excgroup)

2 changes: 1 addition & 1 deletion src/exceptiongroup/_exceptions.py
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ def __new__(
for i, exc in enumerate(__exceptions):
if not isinstance(exc, BaseException):
raise ValueError(
f"Item {i} of second argument (exceptions) is not an " f"exception"
f"Item {i} of second argument (exceptions) is not an exception"
)

if cls is BaseExceptionGroup:
8 changes: 1 addition & 7 deletions tests/test_catch.py
Original file line number Diff line number Diff line change
@@ -148,15 +148,9 @@ def test_catch_handler_raises():
def handler(exc):
raise RuntimeError("new")

try:
with pytest.raises(RuntimeError, match="new"):
with catch({(ValueError, ValueError): handler}):
raise ExceptionGroup("booboo", [ValueError("bar")])
except ExceptionGroup as exc:
assert exc.message == ""
assert len(exc.exceptions) == 1
assert isinstance(exc.exceptions[0], RuntimeError)
else:
pytest.fail("Did not raise an ExceptionGroup")


def test_catch_subclass():
8 changes: 1 addition & 7 deletions tests/test_catch_py311.py
Original file line number Diff line number Diff line change
@@ -122,17 +122,11 @@ def test_catch_full_match():


def test_catch_handler_raises():
try:
with pytest.raises(RuntimeError, match="new"):
try:
raise ExceptionGroup("booboo", [ValueError("bar")])
except* ValueError:
raise RuntimeError("new")
except ExceptionGroup as exc:
assert exc.message == ""
assert len(exc.exceptions) == 1
assert isinstance(exc.exceptions[0], RuntimeError)
else:
pytest.fail("Did not raise an ExceptionGroup")


def test_catch_subclass():
4 changes: 2 additions & 2 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -290,7 +290,7 @@ def test_basics_subgroup_by_predicate__match(self):
]

for match_type, template in testcases:
subeg = eg.subgroup(lambda e: isinstance(e, match_type)) # noqa: B023
subeg = eg.subgroup(lambda e: isinstance(e, match_type))
self.assertEqual(subeg.message, eg.message)
self.assertMatchesTemplate(subeg, ExceptionGroup, template)

@@ -355,7 +355,7 @@ def test_basics_split_by_predicate__match(self):
]

for match_type, match_template, rest_template in testcases:
match, rest = eg.split(lambda e: isinstance(e, match_type)) # noqa: B023
match, rest = eg.split(lambda e: isinstance(e, match_type))
self.assertEqual(match.message, eg.message)
self.assertMatchesTemplate(match, ExceptionGroup, match_template)
if rest_template is not None: