Skip to content

Commit

Permalink
[DOP-15764] - remove generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-lixakov committed May 22, 2024
1 parent ee1445c commit 7610b0a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
7 changes: 1 addition & 6 deletions onetl/connection/db_connection/jdbc_connection/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import warnings
from enum import Enum
from typing import Optional, TypeVar
from typing import Optional

try:
from pydantic.v1 import Field, PositiveInt, root_validator
Expand Down Expand Up @@ -625,8 +625,3 @@ def _check_partition_fields(cls, values):
class JDBCLegacyOptions(JDBCReadOptions, JDBCWriteOptions):
class Config:
prohibited_options = JDBCOptions.Config.prohibited_options


JDBCReadOptionsType = TypeVar("JDBCReadOptionsType", bound=JDBCReadOptions)
JDBCWriteOptionsType = TypeVar("JDBCWriteOptionsType", bound=JDBCWriteOptions)
JDBCSQLOptionsType = TypeVar("JDBCSQLOptionsType", bound=JDBCSQLOptions)
6 changes: 1 addition & 5 deletions onetl/connection/db_connection/jdbc_mixin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations

from typing import Optional, TypeVar
from typing import Optional

from typing_extensions import deprecated

Expand Down Expand Up @@ -123,7 +123,3 @@ class Config:
Default value depends on driver. For example, Oracle has
default ``fetchsize=10``.
"""


JDBCFetchOptionsType = TypeVar("JDBCFetchOptionsType", bound=JDBCFetchOptions)
JDBCExecuteOptionsType = TypeVar("JDBCExecuteOptionsType", bound=JDBCExecuteOptions)
14 changes: 7 additions & 7 deletions onetl/connection/db_connection/oracle/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
from onetl._util.classproperty import classproperty
from onetl._util.version import Version
from onetl.connection.db_connection.jdbc_connection import JDBCConnection
from onetl.connection.db_connection.jdbc_connection.options import JDBCReadOptionsType
from onetl.connection.db_connection.jdbc_connection.options import JDBCReadOptions
from onetl.connection.db_connection.jdbc_mixin.options import (
JDBCExecuteOptionsType,
JDBCFetchOptionsType,
JDBCExecuteOptions,
JDBCFetchOptions,
JDBCOptions,
)
from onetl.connection.db_connection.oracle.dialect import OracleDialect
Expand Down Expand Up @@ -268,7 +268,7 @@ def get_min_max_values(
window: Window,
hint: Any | None = None,
where: Any | None = None,
options: JDBCReadOptionsType | None = None,
options: JDBCReadOptions | None = None,
) -> tuple[Any, Any]:
min_value, max_value = super().get_min_max_values(
source=source,
Expand All @@ -289,7 +289,7 @@ def get_min_max_values(
def execute(
self,
statement: str,
options: JDBCOptions | JDBCExecuteOptionsType | dict | None = None, # noqa: WPS437
options: JDBCOptions | JDBCExecuteOptions | dict | None = None, # noqa: WPS437
) -> DataFrame | None:
statement = clear_statement(statement)

Expand Down Expand Up @@ -353,7 +353,7 @@ def _get_compile_errors(
type_name: str,
schema: str,
object_name: str,
options: JDBCExecuteOptionsType | JDBCFetchOptionsType,
options: JDBCExecuteOptions | JDBCFetchOptions,
) -> list[tuple[ErrorPosition, str]]:
"""
Get compile errors for the object.
Expand Down Expand Up @@ -423,7 +423,7 @@ def _build_error_message(self, aggregated_errors: OrderedDict[ErrorPosition, str
def _handle_compile_errors(
self,
statement: str,
options: JDBCExecuteOptionsType,
options: JDBCExecuteOptions,
) -> None:
"""
Oracle does not return compilation errors immediately.
Expand Down
6 changes: 3 additions & 3 deletions onetl/connection/db_connection/postgres/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from onetl._util.version import Version
from onetl.connection.db_connection.jdbc_connection import JDBCConnection
from onetl.connection.db_connection.jdbc_mixin.options import (
JDBCExecuteOptionsType,
JDBCFetchOptionsType,
JDBCExecuteOptions,
JDBCFetchOptions,
JDBCOptions,
)
from onetl.connection.db_connection.postgres.dialect import PostgresDialect
Expand Down Expand Up @@ -178,7 +178,7 @@ def instance_url(self) -> str:

def _options_to_connection_properties(
self,
options: JDBCOptions | JDBCFetchOptionsType | JDBCExecuteOptionsType,
options: JDBCOptions | JDBCFetchOptions | JDBCExecuteOptions,
): # noqa: WPS437
# See https://github.com/pgjdbc/pgjdbc/pull/1252
# Since 42.2.9 Postgres JDBC Driver added new option readOnlyMode=transaction
Expand Down

0 comments on commit 7610b0a

Please sign in to comment.