From 6cc0c8fe7f893a902d16e8c24b5cfcf3ee943e9f Mon Sep 17 00:00:00 2001 From: charlie-sando Date: Sun, 26 Jun 2022 19:31:23 -0500 Subject: [PATCH 1/3] fix: Fixes #48, multiline input (lint) --- pyprql/cli/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyprql/cli/cli.py b/pyprql/cli/cli.py index 4991630..24b6a18 100644 --- a/pyprql/cli/cli.py +++ b/pyprql/cli/cli.py @@ -424,5 +424,5 @@ def run(self) -> None: self.prompt_text = "PRQL> " self.has_one_blank = False - def clean_input(self, command): + def clean_input(self, command: str) -> str: return re.sub(r'\|+', r'|', command.rstrip('|')) From b3047d8478ed6129d925a17cf1bc4472457a7930 Mon Sep 17 00:00:00 2001 From: charlie-sando Date: Sun, 26 Jun 2022 19:44:41 -0500 Subject: [PATCH 2/3] fix: Fixes #48, multiline input (lint) --- pyprql/cli/cli.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pyprql/cli/cli.py b/pyprql/cli/cli.py index f099119..722c094 100644 --- a/pyprql/cli/cli.py +++ b/pyprql/cli/cli.py @@ -77,11 +77,11 @@ def clear_screen() -> None: def clean_column_names(data: pd.DataFrame) -> pd.DataFrame: return ( data.columns.str.lower() - .str.strip() - .str.replace('"', "") - .str.replace(" ", "_") - .str.replace("(", "", regex=False) - .str.replace(")", "", regex=False) + .str.strip() + .str.replace('"', "") + .str.replace(" ", "_") + .str.replace("(", "", regex=False) + .str.replace(")", "", regex=False) ) @@ -126,7 +126,7 @@ def __init__(self, connect_str: str = "") -> None: self.command = "" self.sql_mode = False BOTTOM_TOOLBAR_TXT += ( - " Connected to " + connect_str[connect_str.rfind("/") + 1 :] + "." + " Connected to " + connect_str[connect_str.rfind("/") + 1:] + "." ) file = Path(connect_str) delims = {".csv": ",", ".tsv": "\t"} @@ -334,7 +334,7 @@ def handle_input(self, _user_input: str) -> None: key = "show columns" if key not in user_input: key = "\\d+" - table_name = user_input[key.__len__() + 1 :] + table_name = user_input[key.__len__() + 1:] print(table_name) # tables = self.engine.list_tables() columns = self.inspector.get_columns(table_name) @@ -366,7 +366,7 @@ def handle_input(self, _user_input: str) -> None: sql = prql.to_sql(cleaned) to = "" if "TO" in sql: - to = sql[sql.index("TO") :].strip() + to = sql[sql.index("TO"):].strip() sql = sql[: sql.index("TO")].strip() print("SQL:\n\t" + self.highlight_sql(sql) + "\nResults:") @@ -424,7 +424,5 @@ def run(self) -> None: self.prompt_text = "PRQL> " self.has_one_blank = False - def clean_input(self, command: str) -> str: return re.sub(r'\|+', r'|', command.rstrip('|')) - From 6dea551b5eac8700754fd6300e14a9cf685258d5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 00:47:11 +0000 Subject: [PATCH 3/3] style(*): blacken files --- pyprql/cli/cli.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pyprql/cli/cli.py b/pyprql/cli/cli.py index 722c094..2f94859 100644 --- a/pyprql/cli/cli.py +++ b/pyprql/cli/cli.py @@ -77,11 +77,11 @@ def clear_screen() -> None: def clean_column_names(data: pd.DataFrame) -> pd.DataFrame: return ( data.columns.str.lower() - .str.strip() - .str.replace('"', "") - .str.replace(" ", "_") - .str.replace("(", "", regex=False) - .str.replace(")", "", regex=False) + .str.strip() + .str.replace('"', "") + .str.replace(" ", "_") + .str.replace("(", "", regex=False) + .str.replace(")", "", regex=False) ) @@ -126,7 +126,7 @@ def __init__(self, connect_str: str = "") -> None: self.command = "" self.sql_mode = False BOTTOM_TOOLBAR_TXT += ( - " Connected to " + connect_str[connect_str.rfind("/") + 1:] + "." + " Connected to " + connect_str[connect_str.rfind("/") + 1 :] + "." ) file = Path(connect_str) delims = {".csv": ",", ".tsv": "\t"} @@ -334,7 +334,7 @@ def handle_input(self, _user_input: str) -> None: key = "show columns" if key not in user_input: key = "\\d+" - table_name = user_input[key.__len__() + 1:] + table_name = user_input[key.__len__() + 1 :] print(table_name) # tables = self.engine.list_tables() columns = self.inspector.get_columns(table_name) @@ -366,7 +366,7 @@ def handle_input(self, _user_input: str) -> None: sql = prql.to_sql(cleaned) to = "" if "TO" in sql: - to = sql[sql.index("TO"):].strip() + to = sql[sql.index("TO") :].strip() sql = sql[: sql.index("TO")].strip() print("SQL:\n\t" + self.highlight_sql(sql) + "\nResults:") @@ -425,4 +425,4 @@ def run(self) -> None: self.has_one_blank = False def clean_input(self, command: str) -> str: - return re.sub(r'\|+', r'|', command.rstrip('|')) + return re.sub(r"\|+", r"|", command.rstrip("|"))