Skip to content

Commit

Permalink
chore: pass pre-commit checks (#24)
Browse files Browse the repository at this point in the history
* style: run pre-commit hooks

* style: remove type annotations that may not exist

* build: remove ocient from requirements/testing.in
  • Loading branch information
jwilliams-ocient authored Apr 20, 2023
1 parent 787e303 commit e82386e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
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

0 comments on commit e82386e

Please sign in to comment.