Skip to content

Commit

Permalink
Refactoring/#219 applied ptb checks and fixes (#220)
Browse files Browse the repository at this point in the history
* #219: Applied PTB checks and fixes
* Use absolute imports in exasol.analytics.schema
* Removed copies of mock_cast.py
* deleted unuses duplicate class exasol/analytics/query_handler/udf/factory.py
  • Loading branch information
ckunki authored Nov 22, 2024
1 parent fcbf1bf commit f4fef21
Show file tree
Hide file tree
Showing 270 changed files with 8,949 additions and 5,798 deletions.
1 change: 1 addition & 0 deletions doc/changes/changes_0.1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Code name:
* #208: Replaced access to private attribute by public
* #203: Cleaned-up package names and directory structure
* #217: Rename dataflow abstraction files
* #219: Applied PTB checks and fixes
2 changes: 1 addition & 1 deletion exasol/analytics/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0'
__version__ = "0.1.0"
7 changes: 2 additions & 5 deletions exasol/analytics/query_handler/context/connection_name.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

from exasol.analytics.schema import (
DBObjectNameImpl,
DBObjectName,
)
from typeguard import typechecked

from exasol.analytics.schema import DBObjectName, DBObjectNameImpl


class ConnectionName(DBObjectName):
"""A DBObjectName class which represents the name of a connection object"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from exasol.analytics.query_handler.context.connection_name import ConnectionName, ConnectionNameImpl
from exasol.analytics.query_handler.context.proxy.db_object_name_proxy import DBObjectNameProxy
from exasol.analytics.query_handler.context.connection_name import (
ConnectionName,
ConnectionNameImpl,
)
from exasol.analytics.query_handler.context.proxy.db_object_name_proxy import (
DBObjectNameProxy,
)
from exasol.analytics.query_handler.query.drop.connection import DropConnectionQuery
from exasol.analytics.query_handler.query.interface import Query

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import logging

from exasol.analytics.query_handler.context.proxy.object_proxy import ObjectProxy
import exasol.bucketfs as bfs

from exasol.analytics.query_handler.context.proxy.object_proxy import ObjectProxy

LOGGER = logging.getLogger(__file__)


Expand All @@ -18,7 +19,9 @@ def bucketfs_location(self) -> bfs.path.PathLike:

def cleanup(self):
if self._not_released:
raise Exception("Cleanup of BucketFSLocationProxy only allowed after release.")
raise Exception(
"Cleanup of BucketFSLocationProxy only allowed after release."
)
files = self._list_files()
for file in files:
self._remove_file(file)
Expand All @@ -33,7 +36,11 @@ def _list_files(self):
try:
return list(self._bucketfs_location.iterdir())
except FileNotFoundError as e:
LOGGER.debug(f"File not found {self._bucketfs_location.as_udf_path} during cleanup.")
LOGGER.debug(
f"File not found {self._bucketfs_location.as_udf_path} during cleanup."
)
except Exception as e:
LOGGER.exception(f"Got exception during listing files in temporary BucketFSLocation")
LOGGER.exception(
f"Got exception during listing files in temporary BucketFSLocation"
)
return []
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from abc import abstractmethod
from typing import TypeVar, Generic

from exasol.analytics.schema import DBObjectName

from exasol.analytics.utils.repr_generation_for_object import generate_repr_for_object
from typing import Generic, TypeVar

from exasol.analytics.query_handler.context.proxy.object_proxy import ObjectProxy
from exasol.analytics.query_handler.query.interface import Query
from exasol.analytics.schema import DBObjectName
from exasol.analytics.utils.repr_generation_for_object import generate_repr_for_object

NameType = TypeVar('NameType', bound=DBObjectName)
NameType = TypeVar("NameType", bound=DBObjectName)


class DBObjectNameProxy(ObjectProxy, DBObjectName, Generic[NameType]):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from typing import TypeVar, Generic
from typing import Generic, TypeVar

from exasol.analytics.schema import (
DBObjectNameWithSchema,
SchemaName,
from exasol.analytics.query_handler.context.proxy.db_object_name_proxy import (
DBObjectNameProxy,
)
from exasol.analytics.schema import DBObjectNameWithSchema, SchemaName

from exasol.analytics.query_handler.context.proxy.db_object_name_proxy import DBObjectNameProxy
NameType = TypeVar("NameType", bound=DBObjectNameWithSchema)

NameType = TypeVar('NameType', bound=DBObjectNameWithSchema)


class DBObjectNameWithSchemaProxy(DBObjectNameProxy[NameType], DBObjectNameWithSchema, Generic[NameType]):
class DBObjectNameWithSchemaProxy(
DBObjectNameProxy[NameType], DBObjectNameWithSchema, Generic[NameType]
):
def __init__(self, db_object_name_with_schema: NameType, global_counter_value: int):
super().__init__(db_object_name_with_schema, global_counter_value)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from exasol.analytics.schema import UDFName


from exasol.analytics.query_handler.query.drop.interface import DropQuery
from exasol.analytics.schema import UDFName


class DropUDFQuery(DropQuery):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from typing import Generic, TypeVar

from exasol.analytics.query_handler.context.proxy.db_object_name_with_schema_proxy import (
DBObjectNameWithSchemaProxy,
)
from exasol.analytics.schema import TableLikeName

NameType = TypeVar("NameType", bound=TableLikeName)

from exasol.analytics.query_handler.context.proxy.db_object_name_with_schema_proxy import DBObjectNameWithSchemaProxy

NameType = TypeVar('NameType', bound=TableLikeName)


class TableLikeNameProxy(DBObjectNameWithSchemaProxy[NameType], TableLikeName, Generic[NameType]):
class TableLikeNameProxy(
DBObjectNameWithSchemaProxy[NameType], TableLikeName, Generic[NameType]
):

def __init__(self, table_like_name: NameType, global_counter_value: int):
super().__init__(table_like_name, global_counter_value)
8 changes: 4 additions & 4 deletions exasol/analytics/query_handler/context/proxy/table_name.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from exasol.analytics.schema import TableName


from exasol.analytics.query_handler.context.proxy.table_like_name_proxy import TableLikeNameProxy
from exasol.analytics.query_handler.context.proxy.table_like_name_proxy import (
TableLikeNameProxy,
)
from exasol.analytics.query_handler.query.drop.table import DropTableQuery
from exasol.analytics.query_handler.query.interface import Query
from exasol.analytics.schema import TableName


class TableNameProxy(TableLikeNameProxy[TableName], TableName):
Expand Down
8 changes: 4 additions & 4 deletions exasol/analytics/query_handler/context/proxy/udf_name.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from exasol.analytics.schema import UDFName


from exasol.analytics.query_handler.context.proxy.db_object_name_with_schema_proxy import DBObjectNameWithSchemaProxy
from exasol.analytics.query_handler.context.proxy.db_object_name_with_schema_proxy import (
DBObjectNameWithSchemaProxy,
)
from exasol.analytics.query_handler.context.proxy.drop_udf_query import DropUDFQuery
from exasol.analytics.query_handler.query.interface import Query
from exasol.analytics.schema import UDFName


class UDFNameProxy(DBObjectNameWithSchemaProxy[UDFName], UDFName):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from exasol.analytics.schema import ViewName


from exasol.analytics.query_handler.context.proxy.table_like_name_proxy import TableLikeNameProxy
from exasol.analytics.query_handler.context.proxy.table_like_name_proxy import (
TableLikeNameProxy,
)
from exasol.analytics.query_handler.query.drop.view import DropViewQuery
from exasol.analytics.query_handler.query.interface import Query
from exasol.analytics.schema import ViewName


class ViewNameProxy(TableLikeNameProxy[ViewName], ViewName):
Expand Down
11 changes: 4 additions & 7 deletions exasol/analytics/query_handler/context/query_handler_context.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import abc
from abc import ABC

from exasol.analytics.schema import (
TableName,
UDFName,
ViewName,
)

from exasol.analytics.query_handler.context.connection_name import ConnectionName
from exasol.analytics.query_handler.context.proxy.bucketfs_location_proxy import BucketFSLocationProxy
from exasol.analytics.query_handler.context.proxy.bucketfs_location_proxy import (
BucketFSLocationProxy,
)
from exasol.analytics.schema import TableName, UDFName, ViewName


class QueryHandlerContext(ABC):
Expand Down
13 changes: 9 additions & 4 deletions exasol/analytics/query_handler/context/scope.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import enum
from abc import abstractmethod, ABC
from abc import ABC, abstractmethod

from exasol.analytics.query_handler.context.query_handler_context import QueryHandlerContext
from exasol.analytics.query_handler.context.proxy.object_proxy import ObjectProxy
from exasol.analytics.query_handler.context.query_handler_context import (
QueryHandlerContext,
)


class Connection(ABC):
Expand Down Expand Up @@ -42,8 +44,11 @@ def get_child_query_handler_context(self) -> "ScopeQueryHandlerContext":
pass

@abstractmethod
def transfer_object_to(self, object_proxy: ObjectProxy,
scope_query_handler_context: "ScopeQueryHandlerContext"):
def transfer_object_to(
self,
object_proxy: ObjectProxy,
scope_query_handler_context: "ScopeQueryHandlerContext",
):
"""
This function transfers the ownership of the object to a different context.
That means, that the object isn't released if this context is released,
Expand Down
Loading

0 comments on commit f4fef21

Please sign in to comment.