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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Upcoming (TBD)
Internal
--------
* Improve robustness for flaky tests when publishing.
* Improve type annotations for latest mypy/type stubs.


1.41.2 (2025/11/24)
Expand Down
3 changes: 2 additions & 1 deletion mycli/packages/completion_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def suggest_type(full_text: str, text_before_cursor: str) -> list[dict[str, Any]

last_token = statement and statement.token_prev(len(statement.tokens))[1] or ""

return suggest_based_on_last_token(last_token, text_before_cursor, full_text, identifier)
# todo: unsure about empty string as identifier
return suggest_based_on_last_token(last_token, text_before_cursor, full_text, identifier or Identifier(''))


def suggest_special(text: str) -> list[dict[str, Any]]:
Expand Down
14 changes: 7 additions & 7 deletions mycli/packages/parseutils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import re
from typing import Generator
from typing import Any, Generator

import sqlglot
import sqlparse
Expand Down Expand Up @@ -77,7 +77,7 @@ def is_subselect(parsed: TokenList) -> bool:
return False


def extract_from_part(parsed: TokenList, stop_at_punctuation: bool = True) -> Generator[str, None, None]:
def extract_from_part(parsed: TokenList, stop_at_punctuation: bool = True) -> Generator[Any, None, None]:
tbl_prefix_seen = False
for item in parsed.tokens:
if tbl_prefix_seen:
Expand Down Expand Up @@ -123,7 +123,7 @@ def extract_from_part(parsed: TokenList, stop_at_punctuation: bool = True) -> Ge
break


def extract_table_identifiers(token_stream: TokenList) -> Generator[tuple[str | None, str, str], None, None]:
def extract_table_identifiers(token_stream: Generator[Any, None, None]) -> Generator[tuple[str | None, str, str], None, None]:
"""yields tuples of (schema_name, table_name, table_alias)"""

for item in token_stream:
Expand Down Expand Up @@ -187,15 +187,15 @@ def extract_tables_from_complete_statements(sql: str) -> list[tuple[str | None,
return []

finely_parsed = []
for statement in roughly_parsed:
for rough_statement in roughly_parsed:
try:
finely_parsed.append(sqlglot.parse_one(str(statement), read='mysql'))
finely_parsed.append(sqlglot.parse_one(str(rough_statement), read='mysql'))
except sqlglot.errors.ParseError:
pass

tables = []
for statement in finely_parsed:
for identifier in statement.find_all(sqlglot.exp.Table):
for fine_statement in finely_parsed:
for identifier in fine_statement.find_all(sqlglot.exp.Table):
if identifier.parent_select and identifier.parent_select.sql().startswith('WITH'):
continue
tables.append((
Expand Down
2 changes: 1 addition & 1 deletion mycli/packages/special/iocommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def execute_favorite_query(cur: Cursor, arg: str, **_) -> Generator[tuple, None,
yield (None, None, None, message)
else:
query, arg_error = subst_favorite_query_args(query, args)
if arg_error:
if query is None:
yield (None, None, None, arg_error)
else:
for sql in sqlparse.split(query):
Expand Down