mirror of https://github.com/dbcli/pgcli
Apply black (version 23.1.0)
This commit is contained in:
parent
1c071770bb
commit
d8eb8b5b82
|
@ -6,7 +6,6 @@ from .pgcompleter import PGCompleter
|
||||||
|
|
||||||
|
|
||||||
class CompletionRefresher:
|
class CompletionRefresher:
|
||||||
|
|
||||||
refreshers = OrderedDict()
|
refreshers = OrderedDict()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -302,7 +302,6 @@ class PGCli:
|
||||||
raise PgCliQuitError
|
raise PgCliQuitError
|
||||||
|
|
||||||
def register_special_commands(self):
|
def register_special_commands(self):
|
||||||
|
|
||||||
self.pgspecial.register(
|
self.pgspecial.register(
|
||||||
self.change_db,
|
self.change_db,
|
||||||
"\\c",
|
"\\c",
|
||||||
|
@ -474,7 +473,6 @@ class PGCli:
|
||||||
return [(None, None, None, message, "", True, True)]
|
return [(None, None, None, message, "", True, True)]
|
||||||
|
|
||||||
def initialize_logging(self):
|
def initialize_logging(self):
|
||||||
|
|
||||||
log_file = self.config["main"]["log_file"]
|
log_file = self.config["main"]["log_file"]
|
||||||
if log_file == "default":
|
if log_file == "default":
|
||||||
log_file = config_location() + "log"
|
log_file = config_location() + "log"
|
||||||
|
|
|
@ -290,7 +290,6 @@ def suggest_special(text):
|
||||||
|
|
||||||
|
|
||||||
def suggest_based_on_last_token(token, stmt):
|
def suggest_based_on_last_token(token, stmt):
|
||||||
|
|
||||||
if isinstance(token, str):
|
if isinstance(token, str):
|
||||||
token_v = token.lower()
|
token_v = token.lower()
|
||||||
elif isinstance(token, Comparison):
|
elif isinstance(token, Comparison):
|
||||||
|
@ -399,7 +398,6 @@ def suggest_based_on_last_token(token, stmt):
|
||||||
elif (token_v.endswith("join") and token.is_keyword) or (
|
elif (token_v.endswith("join") and token.is_keyword) or (
|
||||||
token_v in ("copy", "from", "update", "into", "describe", "truncate")
|
token_v in ("copy", "from", "update", "into", "describe", "truncate")
|
||||||
):
|
):
|
||||||
|
|
||||||
schema = stmt.get_identifier_schema()
|
schema = stmt.get_identifier_schema()
|
||||||
tables = extract_tables(stmt.text_before_cursor)
|
tables = extract_tables(stmt.text_before_cursor)
|
||||||
is_join = token_v.endswith("join") and token.is_keyword
|
is_join = token_v.endswith("join") and token.is_keyword
|
||||||
|
@ -436,7 +434,6 @@ def suggest_based_on_last_token(token, stmt):
|
||||||
try:
|
try:
|
||||||
prev = stmt.get_previous_token(token).value.lower()
|
prev = stmt.get_previous_token(token).value.lower()
|
||||||
if prev in ("drop", "alter", "create", "create or replace"):
|
if prev in ("drop", "alter", "create", "create or replace"):
|
||||||
|
|
||||||
# Suggest functions from either the currently-selected schema or the
|
# Suggest functions from either the currently-selected schema or the
|
||||||
# public schema if no schema has been specified
|
# public schema if no schema has been specified
|
||||||
suggest = []
|
suggest = []
|
||||||
|
|
|
@ -157,7 +157,6 @@ class PGCompleter(Completer):
|
||||||
self.all_completions.update(additional_keywords)
|
self.all_completions.update(additional_keywords)
|
||||||
|
|
||||||
def extend_schemata(self, schemata):
|
def extend_schemata(self, schemata):
|
||||||
|
|
||||||
# schemata is a list of schema names
|
# schemata is a list of schema names
|
||||||
schemata = self.escaped_names(schemata)
|
schemata = self.escaped_names(schemata)
|
||||||
metadata = self.dbmetadata["tables"]
|
metadata = self.dbmetadata["tables"]
|
||||||
|
@ -226,7 +225,6 @@ class PGCompleter(Completer):
|
||||||
self.all_completions.add(colname)
|
self.all_completions.add(colname)
|
||||||
|
|
||||||
def extend_functions(self, func_data):
|
def extend_functions(self, func_data):
|
||||||
|
|
||||||
# func_data is a list of function metadata namedtuples
|
# func_data is a list of function metadata namedtuples
|
||||||
|
|
||||||
# dbmetadata['schema_name']['functions']['function_name'] should return
|
# dbmetadata['schema_name']['functions']['function_name'] should return
|
||||||
|
@ -260,7 +258,6 @@ class PGCompleter(Completer):
|
||||||
}
|
}
|
||||||
|
|
||||||
def extend_foreignkeys(self, fk_data):
|
def extend_foreignkeys(self, fk_data):
|
||||||
|
|
||||||
# fk_data is a list of ForeignKey namedtuples, with fields
|
# fk_data is a list of ForeignKey namedtuples, with fields
|
||||||
# parentschema, childschema, parenttable, childtable,
|
# parentschema, childschema, parenttable, childtable,
|
||||||
# parentcolumns, childcolumns
|
# parentcolumns, childcolumns
|
||||||
|
@ -283,7 +280,6 @@ class PGCompleter(Completer):
|
||||||
parcolmeta.foreignkeys.append(fk)
|
parcolmeta.foreignkeys.append(fk)
|
||||||
|
|
||||||
def extend_datatypes(self, type_data):
|
def extend_datatypes(self, type_data):
|
||||||
|
|
||||||
# dbmetadata['datatypes'][schema_name][type_name] should store type
|
# dbmetadata['datatypes'][schema_name][type_name] should store type
|
||||||
# metadata, such as composite type field names. Currently, we're not
|
# metadata, such as composite type field names. Currently, we're not
|
||||||
# storing any metadata beyond typename, so just store None
|
# storing any metadata beyond typename, so just store None
|
||||||
|
@ -697,7 +693,6 @@ class PGCompleter(Completer):
|
||||||
return self.find_matches(word_before_cursor, conds, meta="join")
|
return self.find_matches(word_before_cursor, conds, meta="join")
|
||||||
|
|
||||||
def get_function_matches(self, suggestion, word_before_cursor, alias=False):
|
def get_function_matches(self, suggestion, word_before_cursor, alias=False):
|
||||||
|
|
||||||
if suggestion.usage == "from":
|
if suggestion.usage == "from":
|
||||||
# Only suggest functions allowed in FROM clause
|
# Only suggest functions allowed in FROM clause
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,6 @@ class ProtocolSafeCursor(psycopg.Cursor):
|
||||||
|
|
||||||
|
|
||||||
class PGExecute:
|
class PGExecute:
|
||||||
|
|
||||||
# The boolean argument to the current_schemas function indicates whether
|
# The boolean argument to the current_schemas function indicates whether
|
||||||
# implicit schemas, e.g. pg_catalog
|
# implicit schemas, e.g. pg_catalog
|
||||||
search_path_query = """
|
search_path_query = """
|
||||||
|
@ -180,7 +179,6 @@ class PGExecute:
|
||||||
dsn=None,
|
dsn=None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
|
|
||||||
conn_params = self._conn_params.copy()
|
conn_params = self._conn_params.copy()
|
||||||
|
|
||||||
new_params = {
|
new_params = {
|
||||||
|
|
|
@ -216,7 +216,6 @@ def pset_pager_mocks():
|
||||||
with mock.patch("pgcli.main.click.echo") as mock_echo, mock.patch(
|
with mock.patch("pgcli.main.click.echo") as mock_echo, mock.patch(
|
||||||
"pgcli.main.click.echo_via_pager"
|
"pgcli.main.click.echo_via_pager"
|
||||||
) as mock_echo_via_pager, mock.patch.object(cli, "prompt_app") as mock_app:
|
) as mock_echo_via_pager, mock.patch.object(cli, "prompt_app") as mock_app:
|
||||||
|
|
||||||
yield cli, mock_echo, mock_echo_via_pager, mock_app
|
yield cli, mock_echo, mock_echo_via_pager, mock_app
|
||||||
|
|
||||||
|
|
||||||
|
@ -371,7 +370,6 @@ def test_quoted_db_uri(tmpdir):
|
||||||
|
|
||||||
|
|
||||||
def test_pg_service_file(tmpdir):
|
def test_pg_service_file(tmpdir):
|
||||||
|
|
||||||
with mock.patch.object(PGCli, "connect") as mock_connect:
|
with mock.patch.object(PGCli, "connect") as mock_connect:
|
||||||
cli = PGCli(pgclirc_file=str(tmpdir.join("rcfile")))
|
cli = PGCli(pgclirc_file=str(tmpdir.join("rcfile")))
|
||||||
with open(tmpdir.join(".pg_service.conf").strpath, "w") as service_conf:
|
with open(tmpdir.join(".pg_service.conf").strpath, "w") as service_conf:
|
||||||
|
|
Loading…
Reference in New Issue