Skip to content

Commit

Permalink
Fix MyPy & black errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mwallace582 committed Jan 16, 2024
1 parent dcf64e4 commit fc06ff2
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dbt/adapters/mariadb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dbt.contracts.connection import Credentials
from dbt.events import AdapterLogger
from dataclasses import dataclass
from typing import Optional
from typing import Optional, Union

logger = AdapterLogger("mysql")

Expand Down Expand Up @@ -176,7 +176,7 @@ def get_response(cls, cursor) -> AdapterResponse:
)

@classmethod
def data_type_code_to_name(cls, type_code: int) -> str:
def data_type_code_to_name(cls, type_code: Union[int, str]) -> str:
field_type_values = mysql.connector.constants.FieldType.desc.values()
mapping = {code: name for (code, name) in field_type_values}
return mapping[type_code]
3 changes: 1 addition & 2 deletions dbt/adapters/mariadb/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ def _get_one_catalog(
for relation in self.list_relations(database, schema):
logger.debug("Getting table schema for relation {}", str(relation))
columns.extend(self._get_columns_for_catalog(relation)) # type: ignore[arg-type]
return agate.Table.from_object(columns,
column_types=DEFAULT_TYPE_TESTER)
return agate.Table.from_object(columns, column_types=DEFAULT_TYPE_TESTER)

def check_schema_exists(self, database, schema):
results = self.execute_macro(LIST_SCHEMAS_MACRO_NAME, kwargs={"database": database})
Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/mysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dbt.contracts.connection import Credentials
from dbt.events import AdapterLogger
from dataclasses import dataclass
from typing import Optional
from typing import Optional, Union

logger = AdapterLogger("mysql")

Expand Down Expand Up @@ -172,7 +172,7 @@ def get_response(cls, cursor) -> AdapterResponse:
)

@classmethod
def data_type_code_to_name(cls, type_code: int) -> str:
def data_type_code_to_name(cls, type_code: Union[int, str]) -> str:
field_type_values = mysql.connector.constants.FieldType.desc.values()
mapping = {code: name for (code, name) in field_type_values}
return mapping[type_code]
3 changes: 1 addition & 2 deletions dbt/adapters/mysql/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ def _get_one_catalog(
for relation in self.list_relations(database, schema):
logger.debug("Getting table schema for relation {}", str(relation))
columns.extend(self._get_columns_for_catalog(relation)) # type: ignore[arg-type]
return agate.Table.from_object(columns,
column_types=DEFAULT_TYPE_TESTER)
return agate.Table.from_object(columns, column_types=DEFAULT_TYPE_TESTER)

def check_schema_exists(self, database, schema):
results = self.execute_macro(LIST_SCHEMAS_MACRO_NAME, kwargs={"database": database})
Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/mysql5/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dbt.contracts.connection import Credentials
from dbt.events import AdapterLogger
from dataclasses import dataclass
from typing import Optional
from typing import Optional, Union

logger = AdapterLogger("mysql")

Expand Down Expand Up @@ -176,7 +176,7 @@ def get_response(cls, cursor) -> AdapterResponse:
)

@classmethod
def data_type_code_to_name(cls, type_code: int) -> str:
def data_type_code_to_name(cls, type_code: Union[int, str]) -> str:
field_type_values = mysql.connector.constants.FieldType.desc.values()
mapping = {code: name for (code, name) in field_type_values}
return mapping[type_code]
3 changes: 1 addition & 2 deletions dbt/adapters/mysql5/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ def _get_one_catalog(
for relation in self.list_relations(database, schema):
logger.debug("Getting table schema for relation {}", str(relation))
columns.extend(self._get_columns_for_catalog(relation)) # type: ignore[arg-type]
return agate.Table.from_object(columns,
column_types=DEFAULT_TYPE_TESTER)
return agate.Table.from_object(columns, column_types=DEFAULT_TYPE_TESTER)

def check_schema_exists(self, database, schema):
results = self.execute_macro(LIST_SCHEMAS_MACRO_NAME, kwargs={"database": database})
Expand Down
4 changes: 1 addition & 3 deletions tests/functional/adapter/constraints/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class TestMySQLTableConstraintsColumnsEqual(
pass


class TestMySQLViewConstraintsColumnsEqual(
MySQLColumnEqualSetup, BaseViewConstraintsColumnsEqual
):
class TestMySQLViewConstraintsColumnsEqual(MySQLColumnEqualSetup, BaseViewConstraintsColumnsEqual):
pass


Expand Down
4 changes: 1 addition & 3 deletions tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def project_from_dict(project, profile, packages=None, selectors=None, cli_vars=
return partial.render(renderer)


def config_from_parts_or_dicts(
project, profile, packages=None, selectors=None, cli_vars={}
):
def config_from_parts_or_dicts(project, profile, packages=None, selectors=None, cli_vars={}):
from dbt.config import Project, Profile, RuntimeConfig
from copy import deepcopy

Expand Down

0 comments on commit fc06ff2

Please sign in to comment.