Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 25 additions & 26 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
name: Lint

on:
push
on: push

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version:
["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
shell: bash
run: pip install -r requirements_dev.txt
- name: Install dependencies
shell: bash
run: pip install -r requirements_dev.txt

- name: Install the library
shell: bash
run: pip install .
- name: Install the library
shell: bash
run: pip install .

- name: Run mypy
shell: bash
run: mypy displayhooks --strict
- name: Run mypy
shell: bash
run: mypy displayhooks --strict

- name: Run mypy for tests
shell: bash
run: mypy tests
- name: Run mypy for tests
shell: bash
run: mypy tests

- name: Run ruff
shell: bash
run: ruff check displayhooks
- name: Run ruff
shell: bash
run: ruff check displayhooks

- name: Run ruff for tests
shell: bash
run: ruff check tests
- name: Run ruff for tests
shell: bash
run: ruff check tests
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.python-version }}

- name: Install dependencies
shell: bash
Expand Down
70 changes: 35 additions & 35 deletions .github/workflows/tests_and_coverage.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
name: Tests

on:
push
on: push

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version:
["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install the library
shell: bash
run: pip install .

- name: Install dependencies
shell: bash
run: pip install -r requirements_dev.txt

- name: Print all libs
shell: bash
run: pip list

- name: Run tests and show coverage on the command line
run: coverage run --source=displayhooks --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m --fail-under=100

- name: Upload reports to codecov
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
if: runner.os == 'Linux'
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
find . -iregex "codecov.*"
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}

- name: Run tests and show the branch coverage on the command line
run: coverage run --branch --source=displayhooks --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m --fail-under=100
- name: Install the library
shell: bash
run: pip install .

- name: Install dependencies
shell: bash
run: pip install -r requirements_dev.txt

- name: Print all libs
shell: bash
run: pip list

- name: Run tests and show coverage on the command line
run: |
coverage run --source=displayhooks --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m --fail-under=100
coverage xml

- name: Upload coverage to Coveralls
if: runner.os == 'Linux'
env:
COVERALLS_REPO_TOKEN: ${{secrets.COVERALLS_REPO_TOKEN}}
uses: coverallsapp/github-action@v2
with:
format: cobertura
file: coverage.xml

- name: Run tests and show the branch coverage on the command line
run: coverage run --branch --source=displayhooks --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m --fail-under=100
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Downloads](https://static.pepy.tech/badge/displayhooks/month)](https://pepy.tech/project/displayhooks)
[![Downloads](https://static.pepy.tech/badge/displayhooks)](https://pepy.tech/project/displayhooks)
[![codecov](https://codecov.io/gh/pomponchik/displayhooks/graph/badge.svg?token=UXXTj1AIcT)](https://codecov.io/gh/pomponchik/displayhooks)
[![Coverage Status](https://coveralls.io/repos/github/pomponchik/displayhooks/badge.svg?branch=main)](https://coveralls.io/github/pomponchik/displayhooks?branch=main)
[![Lines of code](https://sloc.xyz/github/pomponchik/displayhooks/?category=code)](https://github.com/boyter/scc/)
[![Hits-of-Code](https://hitsofcode.com/github/pomponchik/displayhooks?branch=main)](https://hitsofcode.com/github/pomponchik/displayhooks/view?branch=main)
[![Test-Package](https://github.com/pomponchik/displayhooks/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/pomponchik/metronomes/actions/workflows/tests_and_coverage.yml)
Expand All @@ -16,9 +16,9 @@ It's a micro library for manipulating [`sys.displayhook`](https://docs.python.or

When you need to change the standard behavior of `displayhook`, with this library you will do it:

- declaratively
- compactly
- beautifully
- 💎 declaratively
- 🫥 compactly
- 🌞 beautifully


## Table of contents
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'

[project]
name = 'displayhooks'
version = '0.0.4'
version = '0.0.5'
authors = [
{ name='Evgeniy Blinov', email='zheni-b@yandex.ru' },
]
Expand All @@ -25,6 +25,7 @@ classifiers = [
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'License :: OSI Approved :: MIT License',
'Topic :: Software Development :: Libraries',
'Intended Audience :: Developers',
Expand Down
6 changes: 3 additions & 3 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pytest==7.4.3
pytest==8.3.5
pytest-timeout==2.2.0
coverage==7.6.1
twine==6.1.0
wheel==0.41.2
build==1.2.2.post1
ruff==0.9.9
ruff==0.14.5
mypy==1.14.1
mutmut==3.2.3
full_match==0.0.2
full_match==0.0.3
8 changes: 5 additions & 3 deletions tests/test_autorestore.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import sys

import pytest
import full_match
from full_match import match

from displayhooks import autorestore_displayhook


def test_restore():
hook_before_declaration = sys.displayhook

@autorestore_displayhook
def do_something():
sys.displayhook = 5
Expand All @@ -22,14 +23,15 @@ def do_something():

def test_restore_after_exception():
hook_before_declaration = sys.displayhook

@autorestore_displayhook
def do_something():
sys.displayhook = 5
raise ValueError('message')
raise ValueError("message")

hook_before_calling = sys.displayhook

with pytest.raises(ValueError, match=full_match('message')):
with pytest.raises(ValueError, match=match("message")):
do_something()

assert hook_before_declaration is sys.displayhook
Expand Down
Loading