Skip to content

apply pre-commit #5717

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 12 commits into
base: main
Choose a base branch
from
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: ''

---


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
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
2 changes: 1 addition & 1 deletion src/textual/_tree_sitter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

from importlib import import_module

from textual import log


try:
from tree_sitter import Language

Expand Down
2 changes: 1 addition & 1 deletion src/textual/widgets/text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from textual.document._syntax_aware_document import SyntaxAwareDocument
from textual.document._wrapped_document import WrappedDocument
from textual.widgets._text_area import (
BUILTIN_LANGUAGES,
EndColumn,
Highlight,
HighlightName,
LanguageDoesNotExist,
StartColumn,
ThemeDoesNotExist,
BUILTIN_LANGUAGES,
)

__all__ = [
Expand Down
1 change: 0 additions & 1 deletion tests/input/test_input_restrict.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def test_input_number_type():
assert not re.fullmatch(number, "-inf")



def test_input_integer_type():
"""Test input type regex"""
integer = _RESTRICT_TYPES["integer"]
Expand Down
15 changes: 11 additions & 4 deletions tests/option_list/test_option_prompt_replacement.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test replacing options prompt from an option list."""

import pytest

from textual.app import App, ComposeResult
Expand All @@ -20,14 +21,18 @@ async def test_replace_option_prompt_with_invalid_id() -> None:
"""Attempting to replace the prompt of an option ID that doesn't exist should raise an exception."""
async with OptionListApp().run_test() as pilot:
with pytest.raises(OptionDoesNotExist):
pilot.app.query_one(OptionList).replace_option_prompt("does-not-exist", "new-prompt")
pilot.app.query_one(OptionList).replace_option_prompt(
"does-not-exist", "new-prompt"
)


async def test_replace_option_prompt_with_invalid_index() -> None:
"""Attempting to replace the prompt of an option index that doesn't exist should raise an exception."""
async with OptionListApp().run_test() as pilot:
with pytest.raises(OptionDoesNotExist):
pilot.app.query_one(OptionList).replace_option_prompt_at_index(23, "new-prompt")
pilot.app.query_one(OptionList).replace_option_prompt_at_index(
23, "new-prompt"
)


async def test_replace_option_prompt_with_valid_id() -> None:
Expand All @@ -41,12 +46,14 @@ async def test_replace_option_prompt_with_valid_id() -> None:
async def test_replace_option_prompt_with_valid_index() -> None:
"""It should be possible to replace the prompt of an option index that does exist."""
async with OptionListApp().run_test() as pilot:
option_list = pilot.app.query_one(OptionList).replace_option_prompt_at_index(1, "new-prompt")
option_list = pilot.app.query_one(OptionList).replace_option_prompt_at_index(
1, "new-prompt"
)
assert option_list.get_option_at_index(1).prompt == "new-prompt"


async def test_replace_single_line_option_prompt_with_multiple() -> None:
"""It should be possible to replace single line prompt with multiple lines """
"""It should be possible to replace single line prompt with multiple lines"""
new_prompt = "new-prompt\nsecond line"
async with OptionListApp().run_test() as pilot:
option_list = pilot.app.query_one(OptionList)
Expand Down
1 change: 1 addition & 0 deletions tests/select/test_blank_and_clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def compose(self):
with pytest.raises(InvalidSelectValueError):
select.clear()


async def test_selection_is_none_with_blank():
class SelectApp(App[None]):
def compose(self):
Expand Down
Loading