summaryrefslogtreecommitdiffstats
path: root/litecli
diff options
context:
space:
mode:
Diffstat (limited to 'litecli')
-rw-r--r--litecli/__init__.py2
-rw-r--r--litecli/clistyle.py6
-rw-r--r--litecli/clitoolbar.py12
-rw-r--r--litecli/compat.py9
-rw-r--r--litecli/encodingutils.py38
-rw-r--r--litecli/main.py88
-rw-r--r--litecli/packages/completion_engine.py28
-rw-r--r--litecli/packages/filepaths.py5
-rw-r--r--litecli/packages/parseutils.py21
-rw-r--r--litecli/packages/prompt_utils.py4
-rw-r--r--litecli/packages/special/__init__.py2
-rw-r--r--litecli/packages/special/dbcommands.py11
-rw-r--r--litecli/packages/special/iocommands.py11
-rw-r--r--litecli/packages/special/main.py8
-rw-r--r--litecli/sqlcompleter.py21
-rw-r--r--litecli/sqlexecute.py4
16 files changed, 63 insertions, 207 deletions
diff --git a/litecli/__init__.py b/litecli/__init__.py
index c3fa782..53d6006 100644
--- a/litecli/__init__.py
+++ b/litecli/__init__.py
@@ -1 +1 @@
-__version__ = "1.11.1"
+__version__ = "1.12.3"
diff --git a/litecli/clistyle.py b/litecli/clistyle.py
index 7527315..5fc5a30 100644
--- a/litecli/clistyle.py
+++ b/litecli/clistyle.py
@@ -56,7 +56,7 @@ def parse_pygments_style(token_name, style_object, style_dict):
try:
other_token_type = string_to_tokentype(style_dict[token_name])
return token_type, style_object.styles[other_token_type]
- except AttributeError as err:
+ except AttributeError:
return token_type, style_dict[token_name]
@@ -85,9 +85,7 @@ def style_factory(name, cli_style):
prompt_styles.append((token, cli_style[token]))
override_style = Style([("bottom-toolbar", "noreverse")])
- return merge_styles(
- [style_from_pygments_cls(style), override_style, Style(prompt_styles)]
- )
+ return merge_styles([style_from_pygments_cls(style), override_style, Style(prompt_styles)])
def style_factory_output(name, cli_style):
diff --git a/litecli/clitoolbar.py b/litecli/clitoolbar.py
index 1e28784..6739665 100644
--- a/litecli/clitoolbar.py
+++ b/litecli/clitoolbar.py
@@ -15,23 +15,17 @@ def create_toolbar_tokens_func(cli, show_fish_help):
result.append(("class:bottom-toolbar", " "))
if cli.multi_line:
- result.append(
- ("class:bottom-toolbar", " (Semi-colon [;] will end the line) ")
- )
+ result.append(("class:bottom-toolbar", " (Semi-colon [;] will end the line) "))
if cli.multi_line:
result.append(("class:bottom-toolbar.on", "[F3] Multiline: ON "))
else:
result.append(("class:bottom-toolbar.off", "[F3] Multiline: OFF "))
if cli.prompt_app.editing_mode == EditingMode.VI:
- result.append(
- ("class:botton-toolbar.on", "Vi-mode ({})".format(_get_vi_mode()))
- )
+ result.append(("class:botton-toolbar.on", "Vi-mode ({})".format(_get_vi_mode())))
if show_fish_help():
- result.append(
- ("class:bottom-toolbar", " Right-arrow to complete suggestion")
- )
+ result.append(("class:bottom-toolbar", " Right-arrow to complete suggestion"))
if cli.completion_refresher.is_refreshing():
result.append(("class:bottom-toolbar", " Refreshing completions..."))
diff --git a/litecli/compat.py b/litecli/compat.py
deleted file mode 100644
index 7316261..0000000
--- a/litecli/compat.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Platform and Python version compatibility support."""
-
-import sys
-
-
-PY2 = sys.version_info[0] == 2
-PY3 = sys.version_info[0] == 3
-WIN = sys.platform in ("win32", "cygwin")
diff --git a/litecli/encodingutils.py b/litecli/encodingutils.py
deleted file mode 100644
index 6caf14d..0000000
--- a/litecli/encodingutils.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from litecli.compat import PY2
-
-
-if PY2:
- binary_type = str
- string_types = basestring
- text_type = unicode
-else:
- binary_type = bytes
- string_types = str
- text_type = str
-
-
-def unicode2utf8(arg):
- """Convert strings to UTF8-encoded bytes.
-
- Only in Python 2. In Python 3 the args are expected as unicode.
-
- """
-
- if PY2 and isinstance(arg, text_type):
- return arg.encode("utf-8")
- return arg
-
-
-def utf8tounicode(arg):
- """Convert UTF8-encoded bytes to strings.
-
- Only in Python 2. In Python 3 the errors are returned as strings.
-
- """
-
- if PY2 and isinstance(arg, binary_type):
- return arg.decode("utf-8")
- return arg
diff --git a/litecli/main.py b/litecli/main.py
index 6dc9dff..d1d3713 100644
--- a/litecli/main.py
+++ b/litecli/main.py
@@ -20,7 +20,6 @@ import sqlparse
from prompt_toolkit.completion import DynamicCompleter
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
from prompt_toolkit.shortcuts import PromptSession, CompleteStyle
-from prompt_toolkit.styles.pygments import style_from_pygments_cls
from prompt_toolkit.document import Document
from prompt_toolkit.filters import HasFocus, IsDone
from prompt_toolkit.formatted_text import ANSI
@@ -43,7 +42,6 @@ from .clibuffer import cli_is_multiline
from .completion_refresher import CompletionRefresher
from .config import config_location, ensure_dir_exists, get_config
from .key_bindings import cli_bindings
-from .encodingutils import utf8tounicode, text_type
from .lexer import LiteCliLexer
from .__init__ import __version__
from .packages.filepaths import dir_path_exists
@@ -94,9 +92,7 @@ class LiteCli(object):
self.login_path_as_host = c["main"].as_bool("login_path_as_host")
# read from cli argument or user config file
- self.auto_vertical_output = auto_vertical_output or c["main"].as_bool(
- "auto_vertical_output"
- )
+ self.auto_vertical_output = auto_vertical_output or c["main"].as_bool("auto_vertical_output")
# audit log
if self.logfile is None and "audit_log" in c["main"]:
@@ -112,9 +108,7 @@ class LiteCli(object):
# Load startup commands.
try:
self.startup_commands = c["startup_commands"]
- except (
- KeyError
- ): # Redundant given the load_config() function that merges in the standard config, but put here to avoid fail if user do not have updated config file.
+ except KeyError: # Redundant given the load_config() function that merges in the standard config, but put here to avoid fail if user do not have updated config file.
self.startup_commands = None
self.completion_refresher = CompletionRefresher()
@@ -123,9 +117,7 @@ class LiteCli(object):
self.initialize_logging()
prompt_cnf = self.read_my_cnf_files(["prompt"])["prompt"]
- self.prompt_format = (
- prompt or prompt_cnf or c["main"]["prompt"] or self.default_prompt
- )
+ self.prompt_format = prompt or prompt_cnf or c["main"]["prompt"] or self.default_prompt
self.prompt_continuation_format = c["main"]["prompt_continuation"]
keyword_casing = c["main"].get("keyword_casing", "auto")
@@ -270,10 +262,7 @@ class LiteCli(object):
)
return
- formatter = logging.Formatter(
- "%(asctime)s (%(process)d/%(threadName)s) "
- "%(name)s %(levelname)s - %(message)s"
- )
+ formatter = logging.Formatter("%(asctime)s (%(process)d/%(threadName)s) " "%(name)s %(levelname)s - %(message)s")
handler.setFormatter(formatter)
@@ -371,8 +360,7 @@ class LiteCli(object):
else:
history = None
self.echo(
- 'Error: Unable to open the history file "{}". '
- "Your query history will not be saved.".format(history_file),
+ 'Error: Unable to open the history file "{}". ' "Your query history will not be saved.".format(history_file),
err=True,
fg="red",
)
@@ -385,10 +373,7 @@ class LiteCli(object):
def get_message():
prompt = self.get_prompt(self.prompt_format)
- if (
- self.prompt_format == self.default_prompt
- and len(prompt) > self.max_len_prompt
- ):
+ if self.prompt_format == self.default_prompt and len(prompt) > self.max_len_prompt:
prompt = self.get_prompt("\\d> ")
prompt = prompt.replace("\\x1b", "\x1b")
return ANSI(prompt)
@@ -469,9 +454,7 @@ class LiteCli(object):
else:
max_width = None
- formatted = self.format_output(
- title, cur, headers, special.is_expanded_output(), max_width
- )
+ formatted = self.format_output(title, cur, headers, special.is_expanded_output(), max_width)
t = time() - start
try:
@@ -601,9 +584,7 @@ class LiteCli(object):
for title, cur, headers, status in res:
if title == "dot command not implemented":
self.echo(
- "The SQLite dot command '"
- + command.split(" ", 1)[0]
- + "' is not yet implemented.",
+ "The SQLite dot command '" + command.split(" ", 1)[0] + "' is not yet implemented.",
fg="yellow",
)
else:
@@ -619,9 +600,7 @@ class LiteCli(object):
try:
startup_commands()
except Exception as e:
- self.echo(
- "Could not execute all startup commands: \n" + str(e), fg="yellow"
- )
+ self.echo("Could not execute all startup commands: \n" + str(e), fg="yellow")
try:
while True:
@@ -635,7 +614,7 @@ class LiteCli(object):
def log_output(self, output):
"""Log the output in the audit log, if it's enabled."""
if self.logfile:
- click.echo(utf8tounicode(output), file=self.logfile)
+ click.echo(output, file=self.logfile)
def echo(self, s, **kwargs):
"""Print a message to stdout.
@@ -651,11 +630,7 @@ class LiteCli(object):
def get_output_margin(self, status=None):
"""Get the output margin (number of rows for the prompt, footer and
timing message."""
- margin = (
- self.get_reserved_space()
- + self.get_prompt(self.prompt_format).count("\n")
- + 2
- )
+ margin = self.get_reserved_space() + self.get_prompt(self.prompt_format).count("\n") + 2
if status:
margin += 1 + status.count("\n")
@@ -741,9 +716,7 @@ class LiteCli(object):
},
)
- return [
- (None, None, None, "Auto-completion refresh started in the background.")
- ]
+ return [(None, None, None, "Auto-completion refresh started in the background.")]
def _on_completions_refreshed(self, new_completer):
"""Swap the completer object in cli with the newly created completer."""
@@ -757,9 +730,7 @@ class LiteCli(object):
def get_completions(self, text, cursor_positition):
with self._completer_lock:
- return self.completer.get_completions(
- Document(text=text, cursor_position=cursor_positition), None
- )
+ return self.completer.get_completions(Document(text=text, cursor_position=cursor_positition), None)
def get_prompt(self, string):
self.logger.debug("Getting prompt")
@@ -805,13 +776,7 @@ class LiteCli(object):
if cur:
column_types = None
if hasattr(cur, "description"):
-
- def get_col_type(col):
- # col_type = FIELD_TYPES.get(col[1], text_type)
- # return col_type if type(col_type) is type else text_type
- return text_type
-
- column_types = [get_col_type(col) for col in cur.description]
+ column_types = [str(col) for col in cur.description]
if max_width is not None:
cur = list(cur)
@@ -824,20 +789,14 @@ class LiteCli(object):
**output_kwargs,
)
- if isinstance(formatted, (text_type)):
+ if isinstance(formatted, str):
formatted = formatted.splitlines()
formatted = iter(formatted)
first_line = next(formatted)
formatted = itertools.chain([first_line], formatted)
- if (
- not expanded
- and max_width
- and headers
- and cur
- and len(first_line) > max_width
- ):
+ if not expanded and max_width and headers and cur and len(first_line) > max_width:
formatted = self.formatter.format_output(
cur,
headers,
@@ -845,7 +804,7 @@ class LiteCli(object):
column_types=column_types,
**output_kwargs,
)
- if isinstance(formatted, (text_type)):
+ if isinstance(formatted, str):
formatted = iter(formatted.splitlines())
output = itertools.chain(output, formatted)
@@ -890,13 +849,9 @@ class LiteCli(object):
is_flag=True,
help="Automatically switch to vertical output mode if the result is wider than the terminal width.",
)
-@click.option(
- "-t", "--table", is_flag=True, help="Display batch output in table format."
-)
+@click.option("-t", "--table", is_flag=True, help="Display batch output in table format.")
@click.option("--csv", is_flag=True, help="Display batch output in CSV format.")
-@click.option(
- "--warn/--no-warn", default=None, help="Warn before running a destructive query."
-)
+@click.option("--warn/--no-warn", default=None, help="Warn before running a destructive query.")
@click.option("-e", "--execute", type=str, help="Execute command and quit.")
@click.argument("database", default="", nargs=1)
def cli(
@@ -964,10 +919,7 @@ def cli(
except (FileNotFoundError, OSError):
litecli.logger.warning("Unable to open TTY as stdin.")
- if (
- litecli.destructive_warning
- and confirm_destructive_query(stdin_text) is False
- ):
+ if litecli.destructive_warning and confirm_destructive_query(stdin_text) is False:
exit(0)
try:
new_line = True
diff --git a/litecli/packages/completion_engine.py b/litecli/packages/completion_engine.py
index 31a32b7..05b70ac 100644
--- a/litecli/packages/completion_engine.py
+++ b/litecli/packages/completion_engine.py
@@ -1,8 +1,6 @@
from __future__ import print_function
-import sys
import sqlparse
from sqlparse.sql import Comparison, Identifier, Where
-from litecli.encodingutils import string_types, text_type
from .parseutils import last_word, extract_tables, find_prev_keyword
from .special import parse_special_command
@@ -52,7 +50,7 @@ def suggest_type(full_text, text_before_cursor):
stmt_start, stmt_end = 0, 0
for statement in parsed:
- stmt_len = len(text_type(statement))
+ stmt_len = len(str(statement))
stmt_start, stmt_end = stmt_end, stmt_end + stmt_len
if stmt_end >= current_pos:
@@ -83,9 +81,7 @@ def suggest_type(full_text, text_before_cursor):
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
- )
+ return suggest_based_on_last_token(last_token, text_before_cursor, full_text, identifier)
def suggest_special(text):
@@ -142,7 +138,7 @@ def _expecting_arg_idx(arg, text):
def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier):
- if isinstance(token, string_types):
+ if isinstance(token, str):
token_v = token.lower()
elif isinstance(token, Comparison):
# If 'token' is a Comparison type such as
@@ -158,13 +154,12 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier
# 'where foo > 5 and '. We need to look "inside" token.tokens to handle
# suggestions in complicated where clauses correctly
prev_keyword, text_before_cursor = find_prev_keyword(text_before_cursor)
- return suggest_based_on_last_token(
- prev_keyword, text_before_cursor, full_text, identifier
- )
+ return suggest_based_on_last_token(prev_keyword, text_before_cursor, full_text, identifier)
else:
token_v = token.value.lower()
- is_operand = lambda x: x and any([x.endswith(op) for op in ["+", "-", "*", "/"]])
+ def is_operand(x):
+ return x and any([x.endswith(op) for op in ["+", "-", "*", "/"]])
if not token:
return [{"type": "keyword"}, {"type": "special"}]
@@ -183,9 +178,7 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier
# Suggest columns/functions AND keywords. (If we wanted to be
# really fancy, we could suggest only array-typed columns)
- column_suggestions = suggest_based_on_last_token(
- "where", text_before_cursor, full_text, identifier
- )
+ column_suggestions = suggest_based_on_last_token("where", text_before_cursor, full_text, identifier)
# Check for a subquery expression (cases 3 & 4)
where = p.tokens[-1]
@@ -256,8 +249,7 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier
{"type": "keyword"},
]
elif (token_v.endswith("join") and token.is_keyword) or (
- token_v
- in ("copy", "from", "update", "into", "describe", "truncate", "desc", "explain")
+ token_v in ("copy", "from", "update", "into", "describe", "truncate", "desc", "explain")
):
schema = (identifier and identifier.get_parent_name()) or []
@@ -318,9 +310,7 @@ def suggest_based_on_last_token(token, text_before_cursor, full_text, identifier
elif token_v.endswith(",") or is_operand(token_v) or token_v in ["=", "and", "or"]:
prev_keyword, text_before_cursor = find_prev_keyword(text_before_cursor)
if prev_keyword:
- return suggest_based_on_last_token(
- prev_keyword, text_before_cursor, full_text, identifier
- )
+ return suggest_based_on_last_token(prev_keyword, text_before_cursor, full_text, identifier)
else:
return []
else:
diff --git a/litecli/packages/filepaths.py b/litecli/packages/filepaths.py
index 2f01046..12a2deb 100644
--- a/litecli/packages/filepaths.py
+++ b/litecli/packages/filepaths.py
@@ -2,7 +2,6 @@
from __future__ import unicode_literals
-from litecli.encodingutils import text_type
import os
@@ -64,10 +63,10 @@ def suggest_path(root_dir):
"""
if not root_dir:
- return map(text_type, [os.path.abspath(os.sep), "~", os.curdir, os.pardir])
+ return map(str, [os.path.abspath(os.sep), "~", os.curdir, os.pardir])
if "~" in root_dir:
- root_dir = text_type(os.path.expanduser(root_dir))
+ root_dir = str(os.path.expanduser(root_dir))
if not os.path.exists(root_dir):
root_dir, _ = os.path.split(root_dir)
diff --git a/litecli/packages/parseutils.py b/litecli/packages/parseutils.py
index d5fd197..f3a3e03 100644
--- a/litecli/packages/parseutils.py
+++ b/litecli/packages/parseutils.py
@@ -96,17 +96,18 @@ def extract_from_part(parsed, stop_at_punctuation=True):
# Also 'SELECT * FROM abc JOIN def' will trigger this elif
# condition. So we need to ignore the keyword JOIN and its variants
# INNER JOIN, FULL OUTER JOIN, etc.
- elif (
- item.ttype is Keyword
- and (not item.value.upper() == "FROM")
- and (not item.value.upper().endswith("JOIN"))
- ):
+ elif item.ttype is Keyword and (not item.value.upper() == "FROM") and (not item.value.upper().endswith("JOIN")):
return
else:
yield item
- elif (
- item.ttype is Keyword or item.ttype is Keyword.DML
- ) and item.value.upper() in ("COPY", "FROM", "INTO", "UPDATE", "TABLE", "JOIN"):
+ elif (item.ttype is Keyword or item.ttype is Keyword.DML) and item.value.upper() in (
+ "COPY",
+ "FROM",
+ "INTO",
+ "UPDATE",
+ "TABLE",
+ "JOIN",
+ ):
tbl_prefix_seen = True
# 'SELECT a, FROM abc' will detect FROM as part of the column list.
# So this check here is necessary.
@@ -180,9 +181,7 @@ def find_prev_keyword(sql):
logical_operators = ("AND", "OR", "NOT", "BETWEEN")
for t in reversed(flattened):
- if t.value == "(" or (
- t.is_keyword and (t.value.upper() not in logical_operators)
- ):
+ if t.value == "(" or (t.is_keyword and (t.value.upper() not in logical_operators)):
# Find the location of token t in the original parsed statement
# We can't use parsed.token_index(t) because t may be a child token
# inside a TokenList, in which case token_index thows an error
diff --git a/litecli/packages/prompt_utils.py b/litecli/packages/prompt_utils.py
index d9ad2b6..93d9532 100644
--- a/litecli/packages/prompt_utils.py
+++ b/litecli/packages/prompt_utils.py
@@ -16,9 +16,7 @@ def confirm_destructive_query(queries):
* False if the query is destructive and the user doesn't want to proceed.
"""
- prompt_text = (
- "You're about to run a destructive command.\n" "Do you want to proceed? (y/n)"
- )
+ prompt_text = "You're about to run a destructive command.\n" "Do you want to proceed? (y/n)"
if is_destructive(queries) and sys.stdin.isatty():
return prompt(prompt_text, type=bool)
diff --git a/litecli/packages/special/__init__.py b/litecli/packages/special/__init__.py
index fd2b18c..5924d09 100644
--- a/litecli/packages/special/__init__.py
+++ b/litecli/packages/special/__init__.py
@@ -1,3 +1,5 @@
+# ruff: noqa
+
__all__ = []
diff --git a/litecli/packages/special/dbcommands.py b/litecli/packages/special/dbcommands.py
index 687c9a4..c0ed7e4 100644
--- a/litecli/packages/special/dbcommands.py
+++ b/litecli/packages/special/dbcommands.py
@@ -5,12 +5,10 @@ import os
import sys
import platform
import shlex
-from sqlite3 import ProgrammingError
from litecli import __version__
from litecli.packages.special import iocommands
-from litecli.packages.special.utils import format_uptime
-from .main import special_command, RAW_QUERY, PARSED_QUERY, ArgumentMissing
+from .main import special_command, RAW_QUERY, PARSED_QUERY
log = logging.getLogger(__name__)
@@ -220,9 +218,7 @@ def describe(cur, arg, **_):
args = (arg,)
query = """
PRAGMA table_info({})
- """.format(
- arg
- )
+ """.format(args)
else:
return list_tables(cur)
@@ -275,8 +271,7 @@ def import_file(cur, arg=None, **_):
for i, row in enumerate(reader):
if len(row) != ncols:
print(
- "%s:%d expected %d columns but found %d - ignored"
- % (filename, i, ncols, len(row)),
+ "%s:%d expected %d columns but found %d - ignored" % (filename, i, ncols, len(row)),
file=sys.stderr,
)
nignored += 1
diff --git a/litecli/packages/special/iocommands.py b/litecli/packages/special/iocommands.py
index c1596eb..78f8707 100644
--- a/litecli/packages/special/iocommands.py
+++ b/litecli/packages/special/iocommands.py
@@ -241,8 +241,7 @@ def subst_favorite_query_args(query, args):
else:
return [
None,
- "Too many arguments.\nQuery does not have enough place holders to substitute.\n"
- + query,
+ "Too many arguments.\nQuery does not have enough place holders to substitute.\n" + query,
]
match = re.search(r"\?|\$\d+", query)
@@ -393,9 +392,7 @@ def write_once(output):
once_file = open(**once_file_args)
except (IOError, OSError) as e:
once_file = None
- raise OSError(
- "Cannot write to file '{}': {}".format(e.filename, e.strerror)
- )
+ raise OSError("Cannot write to file '{}': {}".format(e.filename, e.strerror))
click.echo(output, file=once_file, nl=False)
click.echo("\n", file=once_file, nl=False)
@@ -451,9 +448,7 @@ def watch_query(arg, **kwargs):
elif destructive_prompt is True:
click.secho("Your call!")
cur = kwargs["cur"]
- sql_list = [
- (sql.rstrip(";"), "> {0!s}".format(sql)) for sql in sqlparse.split(statement)
- ]
+ sql_list = [(sql.rstrip(";"), "> {0!s}".format(sql)) for sql in sqlparse.split(statement)]
old_pager_enabled = is_pager_enabled()
while True:
if clear_screen:
diff --git a/litecli/packages/special/main.py b/litecli/packages/special/main.py
index 3dd0e77..49abdf0 100644
--- a/litecli/packages/special/main.py
+++ b/litecli/packages/special/main.py
@@ -82,9 +82,7 @@ def register_special_command(
aliases=(),
):
cmd = command.lower() if not case_sensitive else command
- COMMANDS[cmd] = SpecialCommand(
- handler, command, shortcut, description, arg_type, hidden, case_sensitive
- )
+ COMMANDS[cmd] = SpecialCommand(handler, command, shortcut, description, arg_type, hidden, case_sensitive)
for alias in aliases:
cmd = alias.lower() if not case_sensitive else alias
COMMANDS[cmd] = SpecialCommand(
@@ -123,9 +121,7 @@ def execute(cur, sql):
return special_cmd.handler(cur=cur, query=sql)
-@special_command(
- "help", "\\?", "Show this help.", arg_type=NO_QUERY, aliases=("\\?", "?")
-)
+@special_command("help", "\\?", "Show this help.", arg_type=NO_QUERY, aliases=("\\?", "?"))
def show_help(): # All the parameters are ignored.
headers = ["Command", "Shortcut", "Description"]
result = []
diff --git a/litecli/sqlcompleter.py b/litecli/sqlcompleter.py
index 68252ea..b154432 100644
--- a/litecli/sqlcompleter.py
+++ b/litecli/sqlcompleter.py
@@ -267,11 +267,7 @@ class SQLCompleter(Completer):
self.reset_completions()
def escape_name(self, name):
- if name and (
- (not self.name_pattern.match(name))
- or (name.upper() in self.reserved_words)
- or (name.upper() in self.functions)
- ):
+ if name and ((not self.name_pattern.match(name)) or (name.upper() in self.reserved_words) or (name.upper() in self.functions)):
name = "`%s`" % name
return name
@@ -437,10 +433,7 @@ class SQLCompleter(Completer):
return kw.upper()
return kw.lower()
- return (
- Completion(z if casing is None else apply_case(z), -len(text))
- for x, y, z in sorted(completions)
- )
+ return (Completion(z if casing is None else apply_case(z), -len(text)) for x, y, z in sorted(completions))
def get_completions(self, document, complete_event):
word_before_cursor = document.get_word_before_cursor(WORD=True)
@@ -458,11 +451,7 @@ class SQLCompleter(Completer):
# drop_unique is used for 'tb11 JOIN tbl2 USING (...'
# which should suggest only columns that appear in more than
# one table
- scoped_cols = [
- col
- for (col, count) in Counter(scoped_cols).items()
- if count > 1 and col != "*"
- ]
+ scoped_cols = [col for (col, count) in Counter(scoped_cols).items() if count > 1 and col != "*"]
cols = self.find_matches(word_before_cursor, scoped_cols)
completions.extend(cols)
@@ -535,9 +524,7 @@ class SQLCompleter(Completer):
)
completions.extend(queries)
elif suggestion["type"] == "table_format":
- formats = self.find_matches(
- word_before_cursor, self.table_formats, start_only=True, fuzzy=False
- )
+ formats = self.find_matches(word_before_cursor, self.table_formats, start_only=True, fuzzy=False)
completions.extend(formats)
elif suggestion["type"] == "file_name":
file_names = self.find_files(word_before_cursor)
diff --git a/litecli/sqlexecute.py b/litecli/sqlexecute.py
index 2392472..4277512 100644
--- a/litecli/sqlexecute.py
+++ b/litecli/sqlexecute.py
@@ -112,9 +112,7 @@ class SQLExecute(object):
or sql.startswith("exit")
or sql.startswith("quit")
):
- _logger.debug(
- "Not connected to database. Will not run statement: %s.", sql
- )
+ _logger.debug("Not connected to database. Will not run statement: %s.", sql)
raise OperationalError("Not connected to database.")
# yield ('Not connected to database', None, None, None)
# return