summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaixintao <laixintaoo@gmail.com>2020-09-14 10:27:46 +0800
committerlaixintao <laixintaoo@gmail.com>2020-09-14 10:27:46 +0800
commit13bd678ccd14e025406ed72490ab52f840ecffa2 (patch)
treecbcf8363bf3e8e57905d30f7b0426af77c958023
parent5a61b243e030cc11b26f53f54a06bf3c10f4e38f (diff)
format code using black.bugfix/behave
-rw-r--r--pgcli/main.py5
-rw-r--r--pgcli/packages/parseutils/ctes.py13
-rw-r--r--pgcli/packages/parseutils/tables.py18
-rw-r--r--pgcli/packages/parseutils/utils.py2
-rw-r--r--pgcli/pgcompleter.py19
-rw-r--r--pgcli/pgexecute.py6
6 files changed, 32 insertions, 31 deletions
diff --git a/pgcli/main.py b/pgcli/main.py
index a2821368..b1468985 100644
--- a/pgcli/main.py
+++ b/pgcli/main.py
@@ -968,7 +968,7 @@ class PGCli(object):
click.secho(str(e), err=True, fg="red")
def refresh_completions(self, history=None, persist_priorities="all"):
- """ Refresh outdated completions
+ """Refresh outdated completions
:param history: A prompt_toolkit.history.FileHistory object. Used to
load keyword and identifier preferences
@@ -1235,7 +1235,8 @@ def cli(
else:
print("Config file is now located at", config_full_path)
print(
- "Please move the existing config file ~/.pgclirc to", config_full_path,
+ "Please move the existing config file ~/.pgclirc to",
+ config_full_path,
)
if list_dsn:
try:
diff --git a/pgcli/packages/parseutils/ctes.py b/pgcli/packages/parseutils/ctes.py
index 75e4e40f..171d2002 100644
--- a/pgcli/packages/parseutils/ctes.py
+++ b/pgcli/packages/parseutils/ctes.py
@@ -14,8 +14,7 @@ TableExpression = namedtuple("TableExpression", "name columns start stop")
def isolate_query_ctes(full_text, text_before_cursor):
- """Simplify a query by converting CTEs into table metadata objects
- """
+ """Simplify a query by converting CTEs into table metadata objects"""
if not full_text:
return full_text, text_before_cursor, tuple()
@@ -46,13 +45,13 @@ def isolate_query_ctes(full_text, text_before_cursor):
def extract_ctes(sql):
- """ Extract constant table expresseions from a query
+ """Extract constant table expresseions from a query
- Returns tuple (ctes, remainder_sql)
+ Returns tuple (ctes, remainder_sql)
- ctes is a list of TableExpression namedtuples
- remainder_sql is the text from the original query after the CTEs have
- been stripped.
+ ctes is a list of TableExpression namedtuples
+ remainder_sql is the text from the original query after the CTEs have
+ been stripped.
"""
p = parse(sql)[0]
diff --git a/pgcli/packages/parseutils/tables.py b/pgcli/packages/parseutils/tables.py
index 55b65b00..0ec3e693 100644
--- a/pgcli/packages/parseutils/tables.py
+++ b/pgcli/packages/parseutils/tables.py
@@ -64,13 +64,17 @@ def extract_from_part(parsed, stop_at_punctuation=True):
yield item
elif item.ttype is Keyword or item.ttype is Keyword.DML:
item_val = item.value.upper()
- if item_val in (
- "COPY",
- "FROM",
- "INTO",
- "UPDATE",
- "TABLE",
- ) or item_val.endswith("JOIN"):
+ if (
+ item_val
+ in (
+ "COPY",
+ "FROM",
+ "INTO",
+ "UPDATE",
+ "TABLE",
+ )
+ or item_val.endswith("JOIN")
+ ):
tbl_prefix_seen = True
# 'SELECT a, FROM abc' will detect FROM as part of the column list.
# So this check here is necessary.
diff --git a/pgcli/packages/parseutils/utils.py b/pgcli/packages/parseutils/utils.py
index 594cabfd..034c96e9 100644
--- a/pgcli/packages/parseutils/utils.py
+++ b/pgcli/packages/parseutils/utils.py
@@ -64,7 +64,7 @@ def last_word(text, include="alphanum_underscore"):
def find_prev_keyword(sql, n_skip=0):
- """ Find the last sql keyword in an SQL statement
+ """Find the last sql keyword in an SQL statement
Returns the value of the last keyword, and the text of the query with
everything after the last keyword stripped
diff --git a/pgcli/pgcompleter.py b/pgcli/pgcompleter.py
index b2a57834..9c95a01c 100644
--- a/pgcli/pgcompleter.py
+++ b/pgcli/pgcompleter.py
@@ -62,7 +62,7 @@ normalize_ref = lambda ref: ref if ref[0] == '"' else '"' + ref.lower() + '"'
def generate_alias(tbl):
- """ Generate a table alias, consisting of all upper-case letters in
+ """Generate a table alias, consisting of all upper-case letters in
the table name, or, if there are no upper-case letters, the first letter +
all letters preceded by _
param tbl - unescaped name of the table to alias
@@ -172,7 +172,7 @@ class PGCompleter(Completer):
self.all_completions.update(schemata)
def extend_casing(self, words):
- """ extend casing data
+ """extend casing data
:return:
"""
@@ -491,14 +491,11 @@ class PGCompleter(Completer):
def get_column_matches(self, suggestion, word_before_cursor):
tables = suggestion.table_refs
- do_qualify = (
- suggestion.qualifiable
- and {
- "always": True,
- "never": False,
- "if_more_than_one_table": len(tables) > 1,
- }[self.qualify_columns]
- )
+ do_qualify = suggestion.qualifiable and {
+ "always": True,
+ "never": False,
+ "if_more_than_one_table": len(tables) > 1,
+ }[self.qualify_columns]
qualify = lambda col, tbl: (
(tbl + "." + self.case(col)) if do_qualify else self.case(col)
)
@@ -572,7 +569,7 @@ class PGCompleter(Completer):
return self.find_matches(word_before_cursor, flat_cols(), meta="column")
def alias(self, tbl, tbls):
- """ Generate a unique table alias
+ """Generate a unique table alias
tbl - name of the table to alias, quoted if it needs to be
tbls - TableReference iterable of tables already in query
"""
diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py
index 6f7bd715..d34bf26d 100644
--- a/pgcli/pgexecute.py
+++ b/pgcli/pgexecute.py
@@ -31,8 +31,8 @@ _WAIT_SELECT_TIMEOUT = 1
def _wait_select(conn):
"""
- copy-pasted from psycopg2.extras.wait_select
- the default implementation doesn't define a timeout in the select calls
+ copy-pasted from psycopg2.extras.wait_select
+ the default implementation doesn't define a timeout in the select calls
"""
while 1:
try:
@@ -538,7 +538,7 @@ class PGExecute(object):
def views(self):
"""Yields (schema_name, view_name) tuples.
- Includes both views and and materialized views
+ Includes both views and and materialized views
"""
for row in self._relations(kinds=["v", "m"]):
yield row