Skip to content

Commit 933d0a8

Browse files
authored
Merge pull request #6 from mutating/develop
0.0.6
2 parents 53ee733 + 5869775 commit 933d0a8

15 files changed

Lines changed: 1035 additions & 71 deletions

File tree

.github/ISSUE_TEMPLATE/question.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Question or consultation
33
about: Ask anything about this project
44
title: ''
5-
labels: guestion
5+
labels: question
66
assignees: pomponchik
77

88
---

.github/workflows/lint.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version:
11-
["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"]
10+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t", "3.15.0-alpha.1"]
1211

1312
steps:
1413
- uses: actions/checkout@v4
@@ -26,18 +25,18 @@ jobs:
2625
shell: bash
2726
run: pip install .
2827

29-
- name: Run mypy
30-
shell: bash
31-
run: mypy displayhooks --strict
32-
33-
- name: Run mypy for tests
34-
shell: bash
35-
run: mypy tests
36-
3728
- name: Run ruff
3829
shell: bash
3930
run: ruff check displayhooks
4031

4132
- name: Run ruff for tests
4233
shell: bash
4334
run: ruff check tests
35+
36+
- name: Run mypy
37+
shell: bash
38+
run: mypy --strict displayhooks
39+
40+
- name: Run mypy for tests
41+
shell: bash
42+
run: mypy tests

.github/workflows/tests_and_coverage.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [macos-latest, ubuntu-latest, windows-latest]
11-
python-version:
12-
["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"]
11+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t", "3.15.0-alpha.1"]
1312

1413
steps:
1514
- uses: actions/checkout@v4

.ruff.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
# displayhooks
1+
<details>
2+
<summary>ⓘ</summary>
23

34
[![Downloads](https://static.pepy.tech/badge/displayhooks/month)](https://pepy.tech/project/displayhooks)
45
[![Downloads](https://static.pepy.tech/badge/displayhooks)](https://pepy.tech/project/displayhooks)
5-
[![Coverage Status](https://coveralls.io/repos/github/pomponchik/displayhooks/badge.svg?branch=main)](https://coveralls.io/github/pomponchik/displayhooks?branch=main)
6-
[![Lines of code](https://sloc.xyz/github/pomponchik/displayhooks/?category=code)](https://github.com/boyter/scc/)
7-
[![Hits-of-Code](https://hitsofcode.com/github/pomponchik/displayhooks?branch=main)](https://hitsofcode.com/github/pomponchik/displayhooks/view?branch=main)
8-
[![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)
6+
[![Coverage Status](https://coveralls.io/repos/github/mutating/displayhooks/badge.svg?branch=main)](https://coveralls.io/github/mutating/displayhooks?branch=main)
7+
[![Lines of code](https://sloc.xyz/github/mutating/displayhooks/?category=code)](https://github.com/boyter/scc/)
8+
[![Hits-of-Code](https://hitsofcode.com/github/mutating/displayhooks?branch=main)](https://hitsofcode.com/github/mutating/displayhooks/view?branch=main)
9+
[![Test-Package](https://github.com/mutating/displayhooks/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/mutating/metronomes/actions/workflows/tests_and_coverage.yml)
910
[![Python versions](https://img.shields.io/pypi/pyversions/displayhooks.svg)](https://pypi.python.org/pypi/displayhooks)
1011
[![PyPI version](https://badge.fury.io/py/displayhooks.svg)](https://badge.fury.io/py/displayhooks)
1112
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
1213
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
14+
[![DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/mutating/displayhooks)
1315

16+
</details>
1417

15-
It's a micro library for manipulating [`sys.displayhook`](https://docs.python.org/3/library/sys.html#sys.displayhook).
18+
![logo](https://raw.githubusercontent.com/mutating/displayhooks/develop/docs/assets/logo_1.svg)
1619

17-
When you need to change the standard behavior of `displayhook`, with this library you will do it:
20+
21+
It's a micro-library for customizing [`sys.displayhook`](https://docs.python.org/3/library/sys.html#sys.displayhook).
22+
23+
If you need to change the default behavior of `sys.displayhook`, this library lets you do it:
1824

1925
- 💎 declaratively
2026
- 🫥 compactly
@@ -24,7 +30,7 @@ When you need to change the standard behavior of `displayhook`, with this librar
2430
## Table of contents
2531

2632
- [**Quick start**](#quick-start)
27-
- [**Change the displayed value**](#change-the-displayed-value)
33+
- [**Transform displayed values**](#transform-displayed-values)
2834
- [**Prohibiting the display of certain types of values**](#prohibiting-the-display-of-certain-types-of-values)
2935
- [**Automatic recovery of the default hook**](#automatic-recovery-of-the-default-hook)
3036

@@ -37,7 +43,7 @@ Install it:
3743
pip install displayhooks
3844
```
3945

40-
And use:
46+
Then use it:
4147

4248
```python
4349
import sys
@@ -51,9 +57,9 @@ sys.displayhook(666)
5157
# [nothing!]
5258
```
5359

54-
## Change the displayed value
60+
## Transform displayed values
5561

56-
You can declaratively declare a converter function for the printed values. What it returns will be used to call the original `displayhook` function.
62+
You can declaratively define a converter function for displayed values. Its return value will be passed to the original `displayhook` function.
5763

5864
```python
5965
import sys
@@ -67,8 +73,7 @@ sys.displayhook("What’s gone with that boy, I wonder? You TOM!")
6773
#> 'what’s gone with that boy, i wonder? you tom!'
6874
```
6975

70-
If your function returns `None`, nothing will be printed.
71-
76+
If your function returns `None`, nothing is displayed.
7277

7378
## Prohibiting the display of certain types of values
7479

displayhooks/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
from displayhooks.converter import converted_displayhook as converted_displayhook # noqa: F401
2-
from displayhooks.autorestore import autorestore_displayhook as autorestore_displayhook # noqa: F401
3-
from displayhooks.not_display import not_display as not_display # noqa: F401
1+
from displayhooks.autorestore import (
2+
autorestore_displayhook as autorestore_displayhook,
3+
)
4+
from displayhooks.converter import (
5+
converted_displayhook as converted_displayhook,
6+
)
7+
from displayhooks.not_display import not_display as not_display

displayhooks/autorestore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
else:
66
from typing_extensions import ParamSpec # pragma: no cover
77

8-
from typing import TypeVar, Callable
98
from functools import wraps
10-
9+
from typing import Callable, TypeVar
1110

1211
FunctionParameters = ParamSpec('FunctionParameters')
1312
ReturningValue = TypeVar('ReturningValue')

displayhooks/converter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import sys
2-
from typing import Callable, Any
3-
from threading import Lock
42
from functools import wraps
5-
3+
from threading import Lock
4+
from typing import Any, Callable
65

76
lock = Lock()
87

displayhooks/not_display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Type, Any
1+
from typing import Any, Type
22

33
from displayhooks.converter import converted_displayhook
44

docs/assets/logo_1.svg

Lines changed: 476 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)