From bd42aafb7b04f85fdd94e765141853c767beb296 Mon Sep 17 00:00:00 2001 From: Eduardo Blancas Date: Tue, 25 Mar 2025 14:38:20 -0600 Subject: [PATCH 1/4] errro messages --- CHANGELOG.md | 2 ++ src/sql/connection/connection.py | 1 - src/sql/exceptions.py | 3 --- src/sql/inspect.py | 2 -- src/sql/magic.py | 2 -- src/sql/magic_plot.py | 1 - src/sql/plot.py | 6 ------ src/sql/store.py | 1 - 8 files changed, 2 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8de5c78a..fc2745f23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.11.1dev +* [Fix] No longer showing the Slack link in error messages + ## 0.11.0 (2025-03-03) * [API Change] Disabled `%sql` and `%%sql` on Databricks ([#1047](https://github.com/ploomber/jupysql/issues/1047)) diff --git a/src/sql/connection/connection.py b/src/sql/connection/connection.py index 6c1c1d525..f022e91ad 100644 --- a/src/sql/connection/connection.py +++ b/src/sql/connection/connection.py @@ -951,7 +951,6 @@ def close(self): self._connection.engine.dispose() @classmethod - @modify_exceptions def _start_sqlalchemy_connection(cls, engine, connect_str): try: connection = engine.connect() diff --git a/src/sql/exceptions.py b/src/sql/exceptions.py index 2f804dad2..e0a9be351 100644 --- a/src/sql/exceptions.py +++ b/src/sql/exceptions.py @@ -18,9 +18,6 @@ def exception_factory(name): def _error(message): exc = error.UsageError(message) exc.error_type = name - # this attribute will allow the @modify_exceptions decorator to add the - # community link - exc.modify_exception = True return exc return _error diff --git a/src/sql/inspect.py b/src/sql/inspect.py index 250678930..43c755d8f 100644 --- a/src/sql/inspect.py +++ b/src/sql/inspect.py @@ -165,7 +165,6 @@ def _assign_column_specific_stats(col_stats, is_numeric): return col_stats -@modify_exceptions class Columns(DatabaseInspection): """ Represents the columns in a database table @@ -195,7 +194,6 @@ def __init__(self, name, schema, conn=None) -> None: self._table_txt = self._table.get_string() -@modify_exceptions class TableDescription(DatabaseInspection): """ Generates descriptive statistics. diff --git a/src/sql/magic.py b/src/sql/magic.py index c8e7a7eb5..10c726f41 100644 --- a/src/sql/magic.py +++ b/src/sql/magic.py @@ -367,7 +367,6 @@ def execute(self, line="", cell="", local_ns=None): line=line, cell=cell, local_ns=local_ns, is_interactive_mode=False ) - @modify_exceptions def _execute(self, line, cell, local_ns, is_interactive_mode=False): """ This function implements the cell logic; we create this private @@ -626,7 +625,6 @@ def interactive_execute_wrapper(**kwargs): legal_sql_identifier = re.compile(r"^[A-Za-z0-9#_$]+") - @modify_exceptions def _persist_dataframe( self, raw, conn, user_ns, append=False, index=True, replace=False ): diff --git a/src/sql/magic_plot.py b/src/sql/magic_plot.py index 92c1aecad..f78ee6167 100644 --- a/src/sql/magic_plot.py +++ b/src/sql/magic_plot.py @@ -76,7 +76,6 @@ class SqlPlotMagic(Magics, Configurable): type=float, help="Histogram binwidth", ) - @modify_exceptions def execute(self, line="", cell="", local_ns=None): """ Plot magic diff --git a/src/sql/plot.py b/src/sql/plot.py index 2c2e106c1..a06b1934b 100644 --- a/src/sql/plot.py +++ b/src/sql/plot.py @@ -106,7 +106,6 @@ def _between(conn, table, column, whislo, whishi, with_=None): # https://github.com/matplotlib/matplotlib/blob/b5ac96a8980fdb9e59c9fb649e0714d776e26701/lib/matplotlib/cbook/__init__.py -@modify_exceptions def _boxplot_stats(conn, table, column, whis=1.5, autorange=False, with_=None): """Compute statistics required to create a boxplot""" if not conn: @@ -549,7 +548,6 @@ def histogram( return ax -@modify_exceptions def _histogram( table, column, bins, with_=None, conn=None, facet=None, breaks=None, binwidth=None ): @@ -688,7 +686,6 @@ def _histogram( return bin_, height, bin_size -@modify_exceptions def _histogram_stacked( table, column, @@ -765,7 +762,6 @@ def _histogram_stacked( return data -@modify_exceptions def _filter_aggregate(*filter_queries): """Return a single filter query based on multiple queries. @@ -797,7 +793,6 @@ def _filter_aggregate(*filter_queries): return final_filter -@modify_exceptions def _bar(table, column, with_=None, conn=None): """get x and height for bar plot""" if not conn: @@ -985,7 +980,6 @@ def bar( return ax -@modify_exceptions def _pie(table, column, with_=None, conn=None): """get x and height for pie chart""" if not conn: diff --git a/src/sql/store.py b/src/sql/store.py index e36f99a19..d164326c3 100644 --- a/src/sql/store.py +++ b/src/sql/store.py @@ -80,7 +80,6 @@ def infer_dependencies(self, query, key): dependencies.append(table) return dependencies - @modify_exceptions def store(self, key, query, with_=None): if "-" in key: raise exceptions.UsageError( From d1f4c9d3fbe8f540593012da6bd557cea36c6ab4 Mon Sep 17 00:00:00 2001 From: Eduardo Blancas Date: Tue, 25 Mar 2025 14:39:04 -0600 Subject: [PATCH 2/4] lint --- src/sql/connection/connection.py | 1 - src/sql/inspect.py | 1 - src/sql/magic.py | 1 - src/sql/magic_plot.py | 1 - src/sql/plot.py | 1 - src/sql/store.py | 1 - 6 files changed, 6 deletions(-) diff --git a/src/sql/connection/connection.py b/src/sql/connection/connection.py index f022e91ad..d4d47d8aa 100644 --- a/src/sql/connection/connection.py +++ b/src/sql/connection/connection.py @@ -22,7 +22,6 @@ from IPython.core.error import UsageError import sqlglot import sqlparse -from ploomber_core.exceptions import modify_exceptions from sql.store import store diff --git a/src/sql/inspect.py b/src/sql/inspect.py index 43c755d8f..2150413d7 100644 --- a/src/sql/inspect.py +++ b/src/sql/inspect.py @@ -1,6 +1,5 @@ from sqlalchemy import inspect from prettytable import PrettyTable -from ploomber_core.exceptions import modify_exceptions from sql.connection import ConnectionManager from sql import exceptions import math diff --git a/src/sql/magic.py b/src/sql/magic.py index 10c726f41..a41ba00f1 100644 --- a/src/sql/magic.py +++ b/src/sql/magic.py @@ -9,7 +9,6 @@ from ipywidgets import interact except ModuleNotFoundError: interact = None -from ploomber_core.exceptions import modify_exceptions from IPython.core.magic import ( Magics, cell_magic, diff --git a/src/sql/magic_plot.py b/src/sql/magic_plot.py index f78ee6167..a1db2049e 100644 --- a/src/sql/magic_plot.py +++ b/src/sql/magic_plot.py @@ -1,6 +1,5 @@ from IPython.core.magic import Magics, line_magic, magics_class, no_var_expand from IPython.core.magic_arguments import argument, magic_arguments -from ploomber_core.exceptions import modify_exceptions try: from traitlets.config.configurable import Configurable diff --git a/src/sql/plot.py b/src/sql/plot.py index a06b1934b..bdfa5d1d1 100644 --- a/src/sql/plot.py +++ b/src/sql/plot.py @@ -3,7 +3,6 @@ """ from ploomber_core.dependencies import requires -from ploomber_core.exceptions import modify_exceptions from jinja2 import Template from sql import exceptions, display diff --git a/src/sql/store.py b/src/sql/store.py index d164326c3..30baa7af2 100644 --- a/src/sql/store.py +++ b/src/sql/store.py @@ -2,7 +2,6 @@ from typing import Iterator, Iterable from collections.abc import MutableMapping from jinja2 import Template -from ploomber_core.exceptions import modify_exceptions import sql.connection import difflib From 50d7e52ba63292f023855cfe489a018831418621 Mon Sep 17 00:00:00 2001 From: Eduardo Blancas Date: Tue, 25 Mar 2025 14:55:17 -0600 Subject: [PATCH 3/4] tests --- src/tests/test_magic.py | 6 ------ src/tests/test_magic_plot.py | 2 -- src/tests/test_syntax_errors.py | 7 ------- 3 files changed, 15 deletions(-) diff --git a/src/tests/test_magic.py b/src/tests/test_magic.py index 8295441a4..c0ee3c357 100644 --- a/src/tests/test_magic.py +++ b/src/tests/test_magic.py @@ -29,10 +29,8 @@ from conftest import runsql from sql.connection import PLOOMBER_DOCS_LINK_STR -from ploomber_core.exceptions import COMMUNITY import psutil -COMMUNITY = COMMUNITY.strip() DISPLAYLIMIT_LINK = ( ' Date: Tue, 25 Mar 2025 15:04:52 -0600 Subject: [PATCH 4/4] f --- src/tests/test_magic_cmd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/test_magic_cmd.py b/src/tests/test_magic_cmd.py index c2550b33b..824705186 100644 --- a/src/tests/test_magic_cmd.py +++ b/src/tests/test_magic_cmd.py @@ -38,7 +38,7 @@ def ip_snippets(ip): ip.run_cell("%sql sqlite://") ip.run_cell( """ - %%sql --save high_price --no-execute +%%sql --save high_price --no-execute SELECT * FROM "test_store" WHERE price >= 1.50 @@ -46,7 +46,7 @@ def ip_snippets(ip): ) ip.run_cell( """ - %%sql --save high_price_a --no-execute +%%sql --save high_price_a --no-execute SELECT * FROM "high_price" WHERE symbol == 'a' @@ -54,7 +54,7 @@ def ip_snippets(ip): ) ip.run_cell( """ - %%sql --save high_price_b --no-execute +%%sql --save high_price_b --no-execute SELECT * FROM "high_price" WHERE symbol == 'b' @@ -986,7 +986,7 @@ def test_force_delete_all_with_variable_substitution(ip_snippets): def test_force_delete_all_child_query(ip_snippets, arg): ip_snippets.run_cell( """ - %%sql --save high_price_b_child --no-execute +%%sql --save high_price_b_child --no-execute SELECT * FROM "high_price_b" WHERE symbol == 'b'