Skip to content

use the anyio pytest plugin #5764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2ecf041
apply pre-commit
graingert Apr 7, 2025
87cc68d
fix vcs permalink
graingert Apr 7, 2025
b3e0192
pre-commit autoupdate
graingert Apr 7, 2025
5ecbf61
restore SVGs from main
graingert Apr 7, 2025
945f418
exclude svg from end of file fixer
graingert Apr 7, 2025
98ce3f6
Merge branch 'main' into fix-linting
graingert Apr 8, 2025
f5c221d
fix widgets.md
graingert Apr 8, 2025
5080010
fix styles.md
graingert Apr 8, 2025
bfbcfb7
Update styles.md
graingert Apr 8, 2025
1c82183
Merge branch 'main' into fix-linting
graingert Apr 9, 2025
7f0efca
Merge branch 'main' into fix-linting
graingert Apr 17, 2025
c699d23
Merge branch 'main' into fix-linting
graingert Apr 24, 2025
f8ef8bc
remove pytest-asyncio
graingert Apr 24, 2025
b0ca2af
configure anyio backend
graingert Apr 24, 2025
5957218
autoflake
graingert Apr 24, 2025
76f5554
add anyio mark
graingert Apr 24, 2025
cfb228b
import pytest for anyio mark
graingert Apr 24, 2025
008b03f
add anyio and poetry lock
graingert Apr 24, 2025
69ecdc9
Merge branch 'main' into fix-linting
graingert Apr 26, 2025
a9801bd
Merge branch 'main' into fix-linting
graingert May 11, 2025
844107e
Merge branch 'main' into use-anyio-pytest-plugin
graingert May 22, 2025
da82d9e
Merge branch 'main' into use-anyio-pytest-plugin
graingert May 31, 2025
927ad55
Merge branch 'main' into fix-linting
graingert May 31, 2025
250e0cc
Merge branch 'main' into use-anyio-pytest-plugin
graingert May 31, 2025
4dd5474
apply pre-commit
graingert Jun 1, 2025
dd5b552
export cached_property to prevent pycln removing it
graingert Jun 1, 2025
a81365a
replace black action with pre-commit/action
graingert Jun 1, 2025
ffaf474
Merge branch 'main' into fix-linting
graingert Jun 1, 2025
681a017
add python3.11
graingert Jun 1, 2025
8737eec
Merge branch 'fix-linting' of github.com:graingert/textual into use-a…
graingert Jun 1, 2025
f1f9931
make RLock lazilly bind the Lock
graingert Jun 1, 2025
963f66c
apply pre-commit
graingert Jun 1, 2025
a489ea7
mark missing test as anyio'd
graingert Jun 1, 2025
cf95da2
anyio another missing test
graingert Jun 1, 2025
940d05c
make sure event loop is running when accessing asyncio objects
graingert Jun 1, 2025
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
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ labels: ''
assignees: ''

---


22 changes: 0 additions & 22 deletions .github/workflows/black_format.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
name: setup python 3.11 for pycln
with:
python-version: 3.11
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: check-ast # simply checks whether the files parse as valid python
- id: check-builtin-literals # requires literal syntax when initializing empty or zero python builtin types
Expand All @@ -15,20 +15,21 @@ repos:
- id: check-shebang-scripts-are-executable # ensures that (non-binary) files with a shebang are executable
- id: check-vcs-permalinks # ensures that links to vcs websites are permalinks
- id: end-of-file-fixer # ensures that a file is either empty, or ends with one newline
exclude: '^.*\.svg$'
- id: mixed-line-ending # replaces or checks mixed line ending
- repo: https://github.com/pycqa/isort
rev: '5.13.2'
rev: '6.0.1'
hooks:
- id: isort
name: isort (python)
language_version: '3.11'
args: ['--profile', 'black', '--filter-files']
- repo: https://github.com/psf/black
rev: '24.1.1'
rev: '25.1.0'
hooks:
- id: black
- repo: https://github.com/hadialqattan/pycln # removes unused imports
rev: v2.3.0
rev: v2.5.0
hooks:
- id: pycln
language_version: '3.11'
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ enforcement ladder](https://github.com/mozilla/diversity).

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
https://www.contributor-covenant.org/translations.
1 change: 0 additions & 1 deletion docs/blog/index.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Textual Blog

1 change: 0 additions & 1 deletion docs/blog/posts/helo-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ Welcome to the first post on the Textual blog.
I plan on using this as a place to make announcements regarding new releases of Textual, and any other relevant news.

The first piece of news is that we've reorganized this site a little. The Events, Styles, and Widgets references are now under "Reference", and what used to be under "Reference" is now "API" which contains API-level documentation. I hope that's a little clearer than it used to be!

2 changes: 1 addition & 1 deletion docs/blog/posts/release0-24-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This was also solved with a new rule called "constrain".
Applying `constrain` to a widget will keep the widget within the bounds of the screen.
In the case of `Select`, if you expand the options while at the bottom of the screen, then the overlay will be moved up so that you can see all the options.

These new rules are currently undocumented as they are still subject to change, but you can see them in the [Select](https://github.com/Textualize/textual/blob/main/src/textual/widgets/_select.py#L179) source if you are interested.
These new rules are currently undocumented as they are still subject to change, but you can see them in the [Select](https://github.com/Textualize/textual/blob/v0.24.0/src/textual/widgets/_select.py#L179-L220) source if you are interested.

In a future release these will be finalized and you can confidently use them in your own projects.

Expand Down
1 change: 0 additions & 1 deletion docs/blog/posts/release0-6-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,3 @@ As always, there are a number of fixes in this release. Mostly related to layout
## What's next?

The next release will focus on *pain points* we discovered while in a dog-fooding phase (see the [DevLog](https://textual.textualize.io/blog/category/devlog/) for details on what Textual devs have been building).

2 changes: 1 addition & 1 deletion docs/examples/app/event01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textual.app import App
from textual import events
from textual.app import App


class EventApp(App):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/app/question01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textual.app import App, ComposeResult
from textual.widgets import Label, Button
from textual.widgets import Button, Label


class QuestionApp(App[str]):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/app/question03.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textual.app import App, ComposeResult
from textual.widgets import Label, Button
from textual.widgets import Button, Label


class QuestionApp(App[str]):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/guide/actions/actions01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textual.app import App
from textual import events
from textual.app import App


class ActionsApp(App):
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/guide/dom2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textual.app import App, ComposeResult
from textual.widgets import Header, Footer
from textual.widgets import Footer, Header


class ExampleApp(App):
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/box_sizing01.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/dimensions01.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/dimensions02.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/dimensions03.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/dimensions04.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/margin01.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/outline01.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/padding01.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/guide/styles/padding02.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from textual.app import App, ComposeResult
from textual.widgets import Static


TEXT = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
Expand Down
3 changes: 3 additions & 0 deletions docs/examples/guide/testing/test_rgb.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pytest
from rgb import RGBApp

from textual.color import Color


@pytest.mark.anyio
async def test_keys(): # (1)!
"""Test pressing keys has the desired result."""
app = RGBApp()
Expand All @@ -25,6 +27,7 @@ async def test_keys(): # (1)!
assert app.screen.styles.background == Color.parse("blue")


@pytest.mark.anyio
async def test_buttons():
"""Test pressing keys has the desired result."""
app = RGBApp()
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/guide/widgets/checker03.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

from rich.segment import Segment

from textual.app import App, ComposeResult
from textual.geometry import Size
from textual.strip import Strip
from textual.scroll_view import ScrollView

from rich.segment import Segment
from textual.strip import Strip


class CheckerBoard(ScrollView):
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/guide/widgets/checker04.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

from rich.segment import Segment
from rich.style import Style

from textual import events
from textual.app import App, ComposeResult
from textual.geometry import Offset, Region, Size
from textual.reactive import var
from textual.strip import Strip
from textual.scroll_view import ScrollView

from rich.segment import Segment
from rich.style import Style
from textual.strip import Strip


class CheckerBoard(ScrollView):
Expand Down
18 changes: 9 additions & 9 deletions docs/guide/styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Together these styles compose the widget's *box model*. The following diagram sh

Setting the width restricts the number of columns used by a widget, and setting the height restricts the number of rows. Let's look at an example which sets both dimensions.

```python title="dimensions01.py" hl_lines="21-22"
```python title="dimensions01.py" hl_lines="20-21"
--8<-- "docs/examples/guide/styles/dimensions01.py"
```

Expand All @@ -142,7 +142,7 @@ In practice, we generally want the size of a widget to adapt to its content, whi

Let's set the height to auto and see what happens.

```python title="dimensions02.py" hl_lines="22"
```python title="dimensions02.py" hl_lines="21"
--8<-- "docs/examples/guide/styles/dimensions02.py"
```

Expand All @@ -163,7 +163,7 @@ Textual offers a few different *units* which allow you to specify dimensions rel

The following example demonstrates applying percentage units:

```python title="dimensions03.py" hl_lines="21-22"
```python title="dimensions03.py" hl_lines="20-21"
--8<-- "docs/examples/guide/styles/dimensions03.py"
```

Expand Down Expand Up @@ -193,7 +193,7 @@ When specifying `fr` units for a given dimension, Textual will divide the availa

Let's look at an example. We will create two widgets, one with a height of `"2fr"` and one with a height of `"1fr"`.

```python title="dimensions04.py" hl_lines="24-25"
```python title="dimensions04.py" hl_lines="23-24"
--8<-- "docs/examples/guide/styles/dimensions04.py"
```

Expand All @@ -219,7 +219,7 @@ The following styles set minimum and maximum sizes and can accept any of the val

Padding adds space around your content which can aid readability. Setting [padding](../styles/padding.md) to an integer will add that number additional rows and columns around the content area. The following example sets padding to 2:

```python title="padding01.py" hl_lines="22"
```python title="padding01.py" hl_lines="21"
--8<-- "docs/examples/guide/styles/padding01.py"
```

Expand All @@ -230,7 +230,7 @@ Notice the additional space around the text:

You can also set padding to a tuple of *two* integers which will apply padding to the top/bottom and left/right edges. The following example sets padding to `(2, 4)` which adds two rows to the top and bottom of the widget, and 4 columns to the left and right of the widget.

```python title="padding02.py" hl_lines="22"
```python title="padding02.py" hl_lines="21"
--8<-- "docs/examples/guide/styles/padding02.py"
```

Expand Down Expand Up @@ -289,7 +289,7 @@ Note the addition of the titles and their alignments:

[Outline](../styles/outline.md) is similar to border and is set in the same way. The difference is that outline will not change the size of the widget, and may overlap the content area. The following example sets an outline on a widget:

```python title="outline01.py" hl_lines="22"
```python title="outline01.py" hl_lines="21"
--8<-- "docs/examples/guide/styles/outline01.py"
```

Expand Down Expand Up @@ -325,7 +325,7 @@ The following example creates two widgets with a width of 30, a height of 6, and
The first widget has the default `box_sizing` (`"border-box"`).
The second widget sets `box_sizing` to `"content-box"`.

```python title="box_sizing01.py" hl_lines="32"
```python title="box_sizing01.py" hl_lines="31"
--8<-- "docs/examples/guide/styles/box_sizing01.py"
```

Expand All @@ -340,7 +340,7 @@ Margin is similar to padding in that it adds space, but unlike padding, [margin]

The following example creates two widgets, each with a margin of 2.

```python title="margin01.py" hl_lines="26-27"
```python title="margin01.py" hl_lines="25-26"
--8<-- "docs/examples/guide/styles/margin01.py"
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ Let's add scrolling to our checkerboard example. A standard 8 x 8 board isn't su

=== "checker03.py"

```python title="checker03.py" hl_lines="4 26-30 35-36 52-53"
```python title="checker03.py" hl_lines="6 26-30 35-36 52-53"
--8<-- "docs/examples/guide/widgets/checker03.py"
```

Expand Down
2 changes: 1 addition & 1 deletion examples/json_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from rich.text import Text

from textual.app import App, ComposeResult
from textual.widgets import Header, Footer, Tree
from textual.widgets import Footer, Header, Tree
from textual.widgets.tree import TreeNode


Expand Down
Loading
Loading