From 49930e2d8c16ee453d70c6b9d1311f81417deeae Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 14 Sep 2020 09:33:20 +0800 Subject: Revert "Temporarily comment out behave tests." This reverts commit 59ae65cbbf698d1608e7fd3d55b507f3599ac117. --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d56600b9..eddaf1f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,11 +22,9 @@ install: script: - set -e - coverage run --source pgcli -m py.test - # TODO: fix failing tests and uncomment. - # commented out on 9/8/2020 by j-bennet - # - cd tests - # - behave --no-capture - # - cd .. + - cd tests + - behave --no-capture + - cd .. # check for changelog ReST compliance - rst2html.py --halt=warning changelog.rst >/dev/null # check for black code compliance, 3.6 only -- cgit v1.2.3 From e60d28f1946cf22a83eee882f548368469bae375 Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 14 Sep 2020 10:01:23 +0800 Subject: bugfix: revert prompt_toolkit to 2.0.6 This was introduced by: e9c97072afe9d79276da568ef6791276fddb15d7 ( Use InputMode.REPLACE_SINGLE (#1208) ) see also: https://github.com/dbcli/pgcli/pull/1197 --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5a221d98..4e0696fd 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,9 @@ install_requirements = [ "pgspecial>=1.11.8", "click >= 4.1", "Pygments >= 2.0", # Pygments has to be Capitalcased. WTF? - "prompt_toolkit>=3.0.6,<4.0.0", + # We still need to use pt-2 unless pt-3 released on Fedora32 + # see: https://github.com/dbcli/pgcli/pull/1197 + "prompt_toolkit>=2.0.6,<4.0.0", "psycopg2 >= 2.8", "sqlparse >=0.3.0,<0.4", "configobj >= 5.0.6", -- cgit v1.2.3 From 3afbafee52e41e50634d57f99686f1cb7718c8cb Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 14 Sep 2020 10:15:32 +0800 Subject: disable cache for pip install. Otherwise it will use cache from travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eddaf1f0..5f50abac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_install: - pip install -U setuptools install: - - pip install . + - pip install --no-cache-dir . - pip install -r requirements-dev.txt - pip install keyrings.alt>=3.1 -- cgit v1.2.3 From 5a61b243e030cc11b26f53f54a06bf3c10f4e38f Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 14 Sep 2020 10:21:29 +0800 Subject: lock prompt_toolkit on 3.0.5 for prompt_toolkit. --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 8347b5d1..80e8f437 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -11,3 +11,4 @@ autopep8==1.3.3 click==6.7 twine==1.11.0 wheel==0.33.6 +prompt_toolkit==3.0.5 -- cgit v1.2.3 From 13bd678ccd14e025406ed72490ab52f840ecffa2 Mon Sep 17 00:00:00 2001 From: laixintao Date: Mon, 14 Sep 2020 10:27:46 +0800 Subject: format code using black. --- pgcli/main.py | 5 +++-- pgcli/packages/parseutils/ctes.py | 13 ++++++------- pgcli/packages/parseutils/tables.py | 18 +++++++++++------- pgcli/packages/parseutils/utils.py | 2 +- pgcli/pgcompleter.py | 19 ++++++++----------- pgcli/pgexecute.py | 6 +++--- 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 -- cgit v1.2.3