diff --git a/docs/changelog/next_release/69.feature.rst b/docs/changelog/next_release/69.feature.rst new file mode 100644 index 0000000..3a1aa19 --- /dev/null +++ b/docs/changelog/next_release/69.feature.rst @@ -0,0 +1,3 @@ +Improve typing: +* Fix Pylance (VS Code) complained ``"SomeClass" is not exported from module "etl_entities.module". Import from "etl_entities.module.submodule" instead``. +* Mark old HWM classes with ``typing_extensions.deprecated`` decorator diff --git a/etl_entities/__init__.py b/etl_entities/__init__.py index e8e61a7..af74b16 100644 --- a/etl_entities/__init__.py +++ b/etl_entities/__init__.py @@ -16,6 +16,8 @@ from etl_entities.plugins import import_plugins from etl_entities.version import __version__ +__all__ = ["__version__"] + def plugins_auto_import(): """ diff --git a/etl_entities/hwm/__init__.py b/etl_entities/hwm/__init__.py index a3fcb2e..46c5b5d 100644 --- a/etl_entities/hwm/__init__.py +++ b/etl_entities/hwm/__init__.py @@ -20,3 +20,15 @@ from etl_entities.hwm.file.file_list_hwm import FileListHWM from etl_entities.hwm.hwm import HWM from etl_entities.hwm.hwm_type_registry import HWMTypeRegistry, register_hwm_type + +__all__ = [ + "HWM", + "ColumnHWM", + "ColumnDateHWM", + "ColumnDateTimeHWM", + "ColumnIntHWM", + "FileHWM", + "FileListHWM", + "HWMTypeRegistry", + "register_hwm_type", +] diff --git a/etl_entities/hwm/hwm_type_registry.py b/etl_entities/hwm/hwm_type_registry.py index 1a8d5a4..590a6e1 100644 --- a/etl_entities/hwm/hwm_type_registry.py +++ b/etl_entities/hwm/hwm_type_registry.py @@ -176,7 +176,7 @@ class MyHWM(HWM): """ - def wrapper(klass: type[HWM]): + def wrapper(klass): HWMTypeRegistry.add(type_name, klass) return klass diff --git a/etl_entities/hwm_store/__init__.py b/etl_entities/hwm_store/__init__.py index 94fe3b5..35d8d76 100644 --- a/etl_entities/hwm_store/__init__.py +++ b/etl_entities/hwm_store/__init__.py @@ -20,3 +20,12 @@ from etl_entities.hwm_store.hwm_store_detect import detect_hwm_store from etl_entities.hwm_store.hwm_store_stack_manager import HWMStoreStackManager from etl_entities.hwm_store.memory_hwm_store import MemoryHWMStore + +__all__ = [ + "BaseHWMStore", + "HWMStoreClassRegistry", + "register_hwm_store_class", + "detect_hwm_store", + "HWMStoreStackManager", + "MemoryHWMStore", +] diff --git a/etl_entities/instance/__init__.py b/etl_entities/instance/__init__.py index a40d85f..f382b7e 100644 --- a/etl_entities/instance/__init__.py +++ b/etl_entities/instance/__init__.py @@ -16,3 +16,12 @@ from etl_entities.instance.host import Host from etl_entities.instance.path import AbsolutePath, GenericPath, RelativePath from etl_entities.instance.url import GenericURL + +__all__ = [ + "Cluster", + "Host", + "AbsolutePath", + "GenericPath", + "RelativePath", + "GenericURL", +] diff --git a/etl_entities/old_hwm/__init__.py b/etl_entities/old_hwm/__init__.py index 3e1be68..631d32e 100644 --- a/etl_entities/old_hwm/__init__.py +++ b/etl_entities/old_hwm/__init__.py @@ -19,3 +19,10 @@ from etl_entities.old_hwm.file_list_hwm import FileListHWM from etl_entities.old_hwm.hwm import HWM from etl_entities.old_hwm.int_hwm import IntHWM + +__all__ = [ + "DateHWM", + "DateTimeHWM", + "FileListHWM", + "IntHWM", +] diff --git a/etl_entities/old_hwm/column_hwm.py b/etl_entities/old_hwm/column_hwm.py index fe3ca90..a351a28 100644 --- a/etl_entities/old_hwm/column_hwm.py +++ b/etl_entities/old_hwm/column_hwm.py @@ -30,6 +30,7 @@ class ColumnHWM(HWM[Optional[ColumnValueType], str], GenericModel, Generic[Colum """Base column HWM type .. deprecated:: 2.0.0 + Use :obj:`etl_entities.hwm.column.column_hwm.ColumnHWM>` instead Parameters ---------- diff --git a/etl_entities/old_hwm/date_hwm.py b/etl_entities/old_hwm/date_hwm.py index feec3a5..254350d 100644 --- a/etl_entities/old_hwm/date_hwm.py +++ b/etl_entities/old_hwm/date_hwm.py @@ -17,6 +17,7 @@ from datetime import date from typing import Optional +import typing_extensions from pydantic import validator from pydantic.validators import strict_str_validator @@ -24,11 +25,16 @@ from etl_entities.old_hwm.column_hwm import ColumnHWM +@typing_extensions.deprecated( + "Deprecated in v2.0, will be removed in v3.0", + category=UserWarning, +) @register_hwm_type("old_column_date") class DateHWM(ColumnHWM[date]): """Date HWM type .. deprecated:: 2.0.0 + Use :obj:`ColumnDateHWM ` instead Parameters ---------- diff --git a/etl_entities/old_hwm/datetime_hwm.py b/etl_entities/old_hwm/datetime_hwm.py index 9c0f9b5..bb5338f 100644 --- a/etl_entities/old_hwm/datetime_hwm.py +++ b/etl_entities/old_hwm/datetime_hwm.py @@ -17,6 +17,7 @@ from datetime import datetime from typing import Optional +import typing_extensions from pydantic import validator from pydantic.validators import strict_str_validator @@ -24,11 +25,16 @@ from etl_entities.old_hwm.column_hwm import ColumnHWM +@typing_extensions.deprecated( + "Deprecated in v2.0, will be removed in v3.0", + category=UserWarning, +) @register_hwm_type("old_column_datetime") class DateTimeHWM(ColumnHWM[datetime]): """DateTime HWM type .. deprecated:: 2.0.0 + Use :obj:`ColumnDateTimeHWM ` instead Parameters ---------- diff --git a/etl_entities/old_hwm/file_hwm.py b/etl_entities/old_hwm/file_hwm.py index 91f09c2..3c105d6 100644 --- a/etl_entities/old_hwm/file_hwm.py +++ b/etl_entities/old_hwm/file_hwm.py @@ -35,6 +35,7 @@ class FileHWM( """Basic file HWM type .. deprecated:: 2.0.0 + Use :obj:`etl_entities.hwm.column.file.file_hwm.FileHWM` instead Parameters ---------- diff --git a/etl_entities/old_hwm/file_list_hwm.py b/etl_entities/old_hwm/file_list_hwm.py index 25a9ce0..dc4049a 100644 --- a/etl_entities/old_hwm/file_list_hwm.py +++ b/etl_entities/old_hwm/file_list_hwm.py @@ -18,6 +18,7 @@ from pathlib import PurePosixPath from typing import FrozenSet, Iterable, List +import typing_extensions from pydantic import Field, validator from etl_entities.hwm import FileListHWM as NewFileListHWM @@ -28,11 +29,16 @@ FileListType = FrozenSet[RelativePath] +@typing_extensions.deprecated( + "Deprecated in v2.0, will be removed in v3.0", + category=UserWarning, +) @register_hwm_type("old_file_list") class FileListHWM(FileHWM[FileListType, List[str]]): """File List HWM type .. deprecated:: 2.0.0 + Use :obj:`etl_entities.hwm.column.file.file_list_hwm.FileListHWM` instead Parameters ---------- diff --git a/etl_entities/old_hwm/hwm.py b/etl_entities/old_hwm/hwm.py index 3132521..fe4cce5 100644 --- a/etl_entities/old_hwm/hwm.py +++ b/etl_entities/old_hwm/hwm.py @@ -34,6 +34,7 @@ class HWM(ABC, Entity, GenericModel, Generic[ValueType, SerializedType]): """Generic HWM type .. deprecated:: 2.0.0 + Use :obj:`etl_entities.hwm.HWM` instead Parameters ---------- diff --git a/etl_entities/old_hwm/int_hwm.py b/etl_entities/old_hwm/int_hwm.py index 9cf5911..20ba557 100644 --- a/etl_entities/old_hwm/int_hwm.py +++ b/etl_entities/old_hwm/int_hwm.py @@ -16,6 +16,7 @@ from typing import Optional +import typing_extensions from pydantic import validator from pydantic.types import StrictInt from pydantic.validators import int_validator @@ -24,11 +25,16 @@ from etl_entities.old_hwm.column_hwm import ColumnHWM +@typing_extensions.deprecated( + "Deprecated in v2.0, will be removed in v3.0", + category=UserWarning, +) @register_hwm_type("old_column_int") class IntHWM(ColumnHWM[StrictInt]): """Integer HWM type .. deprecated:: 2.0.0 + Use :obj:`ColumnIntHWM ` instead Parameters ---------- diff --git a/etl_entities/plugins/__init__.py b/etl_entities/plugins/__init__.py index d60c1a2..e328110 100644 --- a/etl_entities/plugins/__init__.py +++ b/etl_entities/plugins/__init__.py @@ -1 +1,17 @@ +# Copyright 2023 MTS (Mobile Telesystems) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from etl_entities.plugins.import_plugins import import_plugins + +__all__ = ["import_plugins"] diff --git a/etl_entities/process/__init__.py b/etl_entities/process/__init__.py index aff2c87..aef014f 100644 --- a/etl_entities/process/__init__.py +++ b/etl_entities/process/__init__.py @@ -14,3 +14,5 @@ from etl_entities.process.process import Process from etl_entities.process.process_stack_manager import ProcessStackManager + +__all__ = ["Process", "ProcessStackManager"] diff --git a/etl_entities/source/__init__.py b/etl_entities/source/__init__.py index 022b0a3..76a7cd2 100644 --- a/etl_entities/source/__init__.py +++ b/etl_entities/source/__init__.py @@ -14,3 +14,5 @@ from etl_entities.source.db import Column, Table from etl_entities.source.file import RemoteFolder + +__all__ = ["Column", "Table", "RemoteFolder"] diff --git a/requirements.txt b/requirements.txt index 4cff938..570657e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ bidict importlib_metadata>=3.6.0 psutil pydantic<2 +typing-extensions>=4.5.0 diff --git a/setup.cfg b/setup.cfg index d26d45f..363097a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -192,7 +192,9 @@ ignore = # RST307: Error in "code" directive RST307 # Q000 Single quotes found but double quotes preferred (doesn't work in version < 3.12) - Q000 + Q000, +# WPS410 Found wrong metadata variable: __all__ + WPS410 # http://flake8.pycqa.org/en/latest/user/options.html?highlight=per-file-ignores#cmdoption-flake8-per-file-ignores per-file-ignores =