Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pass pre-commit checks #24

Merged
merged 3 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements/testing.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
-r development.in
-r integration.in
-e file:.[bigquery,hive,presto,trino,ocient]
-e file:.[bigquery,hive,presto,trino]
docker
flask-testing
freezegun
Expand Down
14 changes: 8 additions & 6 deletions superset/db_engine_specs/ocient.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
try:
# Ensure pyocient inherits Superset's logging level
import pyocient

from superset import app

superset_log_level = app.config["LOG_LEVEL"]
pyocient.logger.setLevel(superset_log_level)
except ImportError as e:
Expand All @@ -38,7 +40,6 @@
from superset.models.core import Database
from superset.models.sql_lab import Query


# Regular expressions to catch custom errors

CONNECTION_INVALID_USERNAME_REGEX = re.compile(
Expand Down Expand Up @@ -83,7 +84,7 @@ def _to_hex(data: bytes) -> str:
return data.hex()


def _polygon_to_json(polygon: "_STPolygon") -> str:
def _polygon_to_json(polygon: Any) -> str:
"""
Converts the _STPolygon object into its JSON representation.

Expand All @@ -98,7 +99,7 @@ def _polygon_to_json(polygon: "_STPolygon") -> str:
return json_value


def _linestring_to_json(linestring: "_STLinestring") -> str:
def _linestring_to_json(linestring: Any) -> str:
"""
Converts the _STLinestring object into its JSON representation.

Expand All @@ -108,7 +109,7 @@ def _linestring_to_json(linestring: "_STLinestring") -> str:
return f"{str([[p.long, p.lat] for p in linestring.points])}"


def _point_to_comma_delimited(point: "_STPoint") -> str:
def _point_to_comma_delimited(point: Any) -> str:
"""
Returns the x and y coordinates as a comma delimited string.

Expand Down Expand Up @@ -141,6 +142,7 @@ def _point_to_comma_delimited(point: "_STPoint") -> str:
# Need to try-catch here because pyocient may not be installed
try:
from pyocient import TypeCodes

_sanitized_ocient_type_codes: Dict[int, SanitizeFunc] = {
TypeCodes.BINARY: _to_hex,
TypeCodes.ST_POINT: _point_to_comma_delimited,
Expand All @@ -150,7 +152,7 @@ def _point_to_comma_delimited(point: "_STPoint") -> str:
TypeCodes.ST_POLYGON: _polygon_to_json,
}
except ImportError as e:
_sanitized_ocient_type_codes: Dict[int, SanitizeFunc] = {}
_sanitized_ocient_type_codes = {}


def _find_columns_to_sanitize(cursor: Any) -> List[PlacedSanitizeFunc]:
Expand Down Expand Up @@ -270,7 +272,7 @@ def fetch_data(
raise exception

# TODO: Unsure if we need to verify that we are receiving rows:
if len(rows) > 0 and type(rows[0]).__name__ == 'Row':
if len(rows) > 0 and type(rows[0]).__name__ == "Row":
# Peek at the schema to determine which column values, if any,
# require sanitization.
columns_to_sanitize: List[PlacedSanitizeFunc] = _find_columns_to_sanitize(
Expand Down
5 changes: 2 additions & 3 deletions tests/unit_tests/db_engine_specs/test_ocient.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from superset.errors import ErrorLevel, SupersetError, SupersetErrorType


# (msg,expected)
MARSHALED_OCIENT_ERRORS: List[Tuple[str, SupersetError]] = [
(
Expand Down Expand Up @@ -132,7 +131,7 @@
(
"There is a syntax error in your statement (extraneous input 'foo bar baz' expecting {<EOF>, 'trace', 'using'})",
SupersetError(
message='Syntax Error: extraneous input "foo bar baz" expecting "{<EOF>, \'trace\', \'using\'}',
message="Syntax Error: extraneous input \"foo bar baz\" expecting \"{<EOF>, 'trace', 'using'}",
error_type=SupersetErrorType.SYNTAX_ERROR,
level=ErrorLevel.ERROR,
extra={
Expand All @@ -149,7 +148,7 @@
(
"There is a syntax error in your statement (mismatched input 'to' expecting {<EOF>, 'trace', 'using'})",
SupersetError(
message='Syntax Error: mismatched input "to" expecting "{<EOF>, \'trace\', \'using\'}',
message="Syntax Error: mismatched input \"to\" expecting \"{<EOF>, 'trace', 'using'}",
error_type=SupersetErrorType.SYNTAX_ERROR,
level=ErrorLevel.ERROR,
extra={
Expand Down