Skip to content
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

chore: bump textual and ruff #625

Merged
merged 1 commit into from
Aug 16, 2024
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
rev: v0.6.0
hooks:
- id: ruff-format
- id: ruff
Expand All @@ -13,7 +13,7 @@ repos:
- click
- duckdb>=0.8.0
- shandy-sqlfmt[jinjafmt]
- textual>=0.72.0
- textual>=0.76.0
- textual-textarea>=0.14.0
- textual-fastdatatable>=0.9.0
- pytest
Expand Down
112 changes: 27 additions & 85 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ build-backend = "poetry.core.masonry.api"
python = ">=3.8.1,<4.0.0"

# textual and component libraries
textual = "==0.72.0"
textual = "==0.76.0"
textual-fastdatatable = "==0.9.0"
textual-textarea = "==0.14.1"
textual-textarea = "==0.14.2"

# click
click = "^8.1.3"
Expand Down Expand Up @@ -70,7 +70,7 @@ harlequin-mysql = "^0.1.1"
pyinstrument = "^4.6.2"

[tool.poetry.group.static.dependencies]
ruff = "^0.5"
ruff = "^0.6"
mypy = "^1.11.0"
types-pygments = "^2.16.0.0"
pandas-stubs = "^2"
Expand Down
26 changes: 19 additions & 7 deletions src/harlequin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
import time
from functools import partial
from pathlib import Path
from typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Type, Union
from typing import (
TYPE_CHECKING,
Dict,
List,
Optional,
Sequence,
Type,
Union,
)

from textual import on, work
from textual.app import App, ComposeResult
Expand Down Expand Up @@ -234,15 +242,17 @@ def compose(self) -> ComposeResult:
yield self.results_viewer
yield self.footer

def push_screen( # type: ignore
# this is some kind of mypy bug; the types are literally copied from the
# parent impl
def push_screen( # type: ignore[override]
self,
screen: Union[Screen[ScreenResultType], str],
callback: Union[ScreenResultCallbackType[ScreenResultType], None] = None,
screen: Screen[ScreenResultType] | str,
callback: ScreenResultCallbackType[ScreenResultType] | None = None,
wait_for_dismiss: bool = False,
) -> Union[AwaitMount, asyncio.Future[ScreenResultType]]:
) -> AwaitMount | asyncio.Future[ScreenResultType]:
if self.editor is not None and self.editor._has_focus_within:
self.editor.text_input._pause_blink(visible=True)
return super().push_screen( # type: ignore
return super().push_screen( # type: ignore[no-any-return,call-overload]
screen,
callback=callback,
wait_for_dismiss=wait_for_dismiss,
Expand Down Expand Up @@ -745,10 +755,12 @@ def action_export(self) -> None:
)

def action_show_query_history(self) -> None:
async def history_callback(screen_data: str) -> None:
async def history_callback(screen_data: str | None) -> None:
"""
Insert the selected query into a new buffer.
"""
if screen_data is None:
return
await self.editor_collection.insert_buffer_with_text(query_text=screen_data)

if self.history is None:
Expand Down
18 changes: 14 additions & 4 deletions src/harlequin/keys_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,9 @@ def submit(self) -> None:
def handle_button_press(self, message: Button.Pressed) -> None:
if isinstance(message.button, EditButton):

def edit_button(new_key: str) -> None:
def edit_button(new_key: str | None) -> None:
if new_key is None:
return
assert isinstance(message.button, EditButton)
message.button.label = new_key
message.button.key = new_key
Expand All @@ -333,7 +335,9 @@ def edit_button(new_key: str) -> None:

elif isinstance(message.button, AddButton):

def add_button(key: str) -> None:
def add_button(key: str | None) -> None:
if key is None:
return
row = Horizontal(
NoFocusLabel("Key:"),
EditButton(key=key),
Expand Down Expand Up @@ -389,7 +393,9 @@ def compose(self) -> ComposeResult:
yield Footer()

def push_edit_modal(self, binding: HarlequinKeyBinding, cursor_row: int) -> None:
def update_binding(new_binding: HarlequinKeyBinding) -> None:
def update_binding(new_binding: HarlequinKeyBinding | None) -> None:
if new_binding is None:
return
assert self.bindings is not None
assert self.table is not None
k = format_action(new_binding.action)
Expand Down Expand Up @@ -524,7 +530,11 @@ async def action_quit(self) -> None:
await super().action_quit()
return # for mypy

def maybe_save(screen_data: tuple[bool, Path | None, str | None]) -> None:
def maybe_save(
screen_data: tuple[bool, Path | None, str | None] | None,
) -> None:
if screen_data is None:
return
do_quit, config_path, keymap_name = screen_data
if not do_quit:
return
Expand Down
4 changes: 2 additions & 2 deletions src/harlequin_duckdb/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import duckdb
from duckdb.typing import DuckDBPyType
from textual_fastdatatable.backend import AutoBackendType

from harlequin.adapter import HarlequinAdapter, HarlequinConnection, HarlequinCursor
from harlequin.autocomplete.completion import HarlequinCompletion
from harlequin.catalog import Catalog, CatalogItem
Expand All @@ -14,8 +16,6 @@
HarlequinConnectionError,
HarlequinQueryError,
)
from textual_fastdatatable.backend import AutoBackendType

from harlequin_duckdb.cli_options import DUCKDB_OPTIONS
from harlequin_duckdb.completions import get_completion_data

Expand Down
4 changes: 2 additions & 2 deletions src/harlequin_sqlite/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from typing import Any, Literal, Sequence
from urllib.parse import unquote, urlparse

from textual_fastdatatable.backend import AutoBackendType

from harlequin.adapter import HarlequinAdapter, HarlequinConnection, HarlequinCursor
from harlequin.autocomplete.completion import HarlequinCompletion
from harlequin.catalog import Catalog, CatalogItem
Expand All @@ -17,8 +19,6 @@
)
from harlequin.options import HarlequinAdapterOption, HarlequinCopyFormat
from harlequin.transaction_mode import HarlequinTransactionMode
from textual_fastdatatable.backend import AutoBackendType

from harlequin_sqlite.cli_options import SQLITE_OPTIONS
from harlequin_sqlite.completions import get_completion_data

Expand Down
3 changes: 2 additions & 1 deletion src/scripts/export_screenshots.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio

from pygments.styles import get_all_styles

from harlequin import Harlequin
from harlequin_duckdb import DuckDbAdapter
from pygments.styles import get_all_styles

TEXT = """
select
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/profile_buffers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import asyncio
from unittest.mock import patch

from textual.widgets.text_area import Selection

from harlequin import Harlequin
from harlequin.editor_cache import BufferState, Cache
from harlequin_duckdb import DuckDbAdapter
from textual.widgets.text_area import Selection


async def load_lots_of_buffers() -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/profile_fast_query.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import asyncio
from unittest.mock import patch

from textual.widgets.text_area import Selection

from harlequin import Harlequin
from harlequin.editor_cache import BufferState, Cache
from harlequin_duckdb import DuckDbAdapter
from textual.widgets.text_area import Selection


async def load_lots_of_buffers() -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/adapter_tests/test_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path

import pytest

from harlequin.catalog import Catalog, CatalogItem
from harlequin.exception import HarlequinConnectionError
from harlequin_duckdb.adapter import DuckDbAdapter
Expand Down
Loading