You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2023/10/21 00:19:37 UTC

[superset] 02/03: fix tests and lint

This is an automated email from the ASF dual-hosted git repository.

elizabeth pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 8d20fa11db3db6881189e34b53920bf5036980da
Author: Elizabeth Thompson <es...@gmail.com>
AuthorDate: Fri Oct 20 16:37:41 2023 -0700

    fix tests and lint
---
 requirements/development.txt |  2 --
 requirements/testing.txt     |  5 -----
 superset/models/helpers.py   | 20 ++++++++++----------
 superset/sql_parse.py        | 10 +++++-----
 4 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/requirements/development.txt b/requirements/development.txt
index 47fe7a1737..aa92fcfda4 100644
--- a/requirements/development.txt
+++ b/requirements/development.txt
@@ -80,8 +80,6 @@ pure-sasl==0.6.2
     # via thrift-sasl
 pydruid==0.6.5
     # via apache-superset
-pygments==2.12.0
-    # via ipython
 pyhive[hive]==0.6.5
     # via apache-superset
 pyinstrument==4.0.2
diff --git a/requirements/testing.txt b/requirements/testing.txt
index ead36ba3f6..73f3447521 100644
--- a/requirements/testing.txt
+++ b/requirements/testing.txt
@@ -137,8 +137,3 @@ trino==0.319.0
     # via apache-superset
 websocket-client==1.2.0
     # via docker
-wrapt==1.12.1
-    # via astroid
-# The following packages are considered to be unsafe in a requirements file:
-# pip
-# setuptools
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 795cc6faa3..ba6b15edbc 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -152,7 +152,7 @@ def convert_uuids(obj: Any) -> Any:
     if isinstance(obj, uuid.UUID):
         return str(obj)
 
-    if isinstance(obj, list):
+    if isinstance(obj, List):
         return [convert_uuids(el) for el in obj]
 
     if isinstance(obj, dict):
@@ -185,7 +185,7 @@ class ImportExportMixin:
     __mapper__: Mapper
 
     @classmethod
-    def _unique_constraints(cls) -> list[set[str]]:
+    def _unique_constraints(cls) -> List[Set[str]]:
         """Get all (single column and multi column) unique constraints"""
         unique = [
             {c.name for c in u.columns}
@@ -246,7 +246,7 @@ class ImportExportMixin:
         dict_rep: Dict[Any, Any],
         parent: Optional[Any] = None,
         recursive: bool = True,
-        sync: Optional[list[str]] = None,
+        sync: Optional[List[str]] = None,
         allow_reparenting: bool = False,
     ) -> Any:
         """Import obj from a dictionary"""
@@ -265,7 +265,7 @@ class ImportExportMixin:
         filters = []  # Using these filters to check if obj already exists
 
         # Remove fields that should not get imported
-        for k in list(dict_rep):
+        for k in List(dict_rep):
             if k not in export_fields and k not in parent_refs:
                 del dict_rep[k]
 
@@ -651,7 +651,7 @@ def clone_model(
     primary_keys = table.primary_key.columns.keys()
     data = {
         attr: getattr(target, attr)
-        for attr in list(table.columns.keys()) + (keep_relations or [])
+        for attr in List(table.columns.keys()) + (keep_relations or [])
         if attr not in primary_keys and attr not in ignore
     }
     data.update(kwargs)
@@ -1150,13 +1150,13 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
                 return utils.cast_to_boolean(value)
             return value
 
-        if isinstance(values, (list, tuple)):
+        if isinstance(values, (List, Tuple)):
             values = [handle_single_value(v) for v in values]  # type: ignore
         else:
             values = handle_single_value(values)
-        if is_list_target and not isinstance(values, (tuple, list)):
+        if is_list_target and not isinstance(values, (Tuple, List)):
             values = [values]  # type: ignore
-        elif not is_list_target and isinstance(values, (tuple, list)):
+        elif not is_list_target and isinstance(values, (Tuple, List)):
             values = values[0] if values else None
         return values
 
@@ -1407,7 +1407,7 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
         template_kwargs["removed_filters"] = removed_filters
         template_kwargs["applied_filters"] = applied_template_filters
         template_processor = self.get_template_processor(**template_kwargs)
-        prequeries: list[str] = []
+        prequeries: List[str] = []
         orderby = orderby or []
         need_groupby = bool(metrics is not None or groupby)
         metrics = metrics or []
@@ -1747,7 +1747,7 @@ class ExploreMixin:  # pylint: disable=too-many-public-methods
                         )
                     )
                 elif is_list_target:
-                    assert isinstance(eq, (tuple, list))
+                    assert isinstance(eq, (Tuple, List))
                     if len(eq) == 0:
                         raise QueryObjectValidationError(
                             _("Filter value list cannot be empty")
diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index 216b4e8825..f705ad9679 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -18,7 +18,7 @@ import logging
 import re
 from dataclasses import dataclass
 from enum import Enum
-from typing import Any, cast, Iterator, List, Optional, Set, Tuple
+from typing import Any, cast, Iterator, List, Optional, Set, Tuple, Dict
 from urllib import parse
 
 import sqlparse
@@ -216,12 +216,12 @@ class ParsedQuery:
     def limit(self) -> Optional[int]:
         return self._limit
 
-    def _get_cte_tables(self, parsed: dict[str, Any]) -> list[dict[str, Any]]:
+    def _get_cte_tables(self, parsed: Dict[str, Any]) -> List[Dict[str, Any]]:
         if "with" not in parsed:
             return []
         return parsed["with"].get("cte_tables", [])
 
-    def _check_cte_is_select(self, oxide_parse: list[dict[str, Any]]) -> bool:
+    def _check_cte_is_select(self, oxide_parse: List[Dict[str, Any]]) -> bool:
         """
         Check if a oxide parsed CTE contains only SELECT statements
 
@@ -822,10 +822,10 @@ def extract_table_references(
         """
         Find all nodes in a SQL tree matching a given key.
         """
-        if isinstance(element, list):
+        if isinstance(element, List):
             for child in element:
                 yield from find_nodes_by_key(child, target)
-        elif isinstance(element, dict):
+        elif isinstance(element, Dict):
             for key, value in element.items():
                 if key == target:
                     yield value