From da78fbceff3744b3293d0b21b3766641b7d61400 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:08:55 +0200 Subject: [PATCH] use 'ABC' instead of 'ABCMeta' --- client/ayon_core/addon/base.py | 6 ++---- client/ayon_core/addon/interfaces.py | 5 +---- client/ayon_core/host/dirmap.py | 7 ++----- client/ayon_core/host/host.py | 6 ++---- client/ayon_core/host/interfaces.py | 6 ++---- client/ayon_core/lib/attribute_definitions.py | 3 +-- client/ayon_core/lib/local_settings.py | 6 ++---- client/ayon_core/pipeline/create/creator_plugins.py | 10 +++------- .../pipeline/publish/abstract_expected_files.py | 6 ++---- .../pipeline/workfile/workfile_template_builder.py | 9 +++------ client/ayon_core/plugins/publish/extract_review.py | 6 ++---- client/ayon_core/tools/common_models/hierarchy.py | 6 ++---- client/ayon_core/tools/launcher/abstract.py | 7 ++----- client/ayon_core/tools/loader/abstract.py | 6 ++---- client/ayon_core/tools/workfiles/abstract.py | 6 ++---- 15 files changed, 30 insertions(+), 65 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index b9ecff4233..308494b4d8 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -9,9 +9,8 @@ import logging import threading import collections from uuid import uuid4 -from abc import ABCMeta, abstractmethod +from abc import ABC, abstractmethod -import six import appdirs import ayon_api from semver import VersionInfo @@ -499,8 +498,7 @@ def is_func_marked(func): return getattr(func, _MARKING_ATTR, False) -@six.add_metaclass(ABCMeta) -class AYONAddon(object): +class AYONAddon(ABC): """Base class of AYON addon. Attributes: diff --git a/client/ayon_core/addon/interfaces.py b/client/ayon_core/addon/interfaces.py index 86e0c6e060..b273e7839b 100644 --- a/client/ayon_core/addon/interfaces.py +++ b/client/ayon_core/addon/interfaces.py @@ -1,7 +1,5 @@ from abc import ABCMeta, abstractmethod -import six - from ayon_core import resources @@ -15,8 +13,7 @@ class _AYONInterfaceMeta(ABCMeta): return str(self) -@six.add_metaclass(_AYONInterfaceMeta) -class AYONInterface: +class AYONInterface(metaclass=_AYONInterfaceMeta): """Base class of Interface that can be used as Mixin with abstract parts. This is way how AYON addon can define that contains specific predefined diff --git a/client/ayon_core/host/dirmap.py b/client/ayon_core/host/dirmap.py index b90b414240..19841845e7 100644 --- a/client/ayon_core/host/dirmap.py +++ b/client/ayon_core/host/dirmap.py @@ -7,18 +7,15 @@ exists is used. """ import os -from abc import ABCMeta, abstractmethod +from abc import ABC, abstractmethod import platform -import six - from ayon_core.lib import Logger from ayon_core.addon import AddonsManager from ayon_core.settings import get_project_settings -@six.add_metaclass(ABCMeta) -class HostDirmap(object): +class HostDirmap(ABC): """Abstract class for running dirmap on a workfile in a host. Dirmap is used to translate paths inside of host workfile from one diff --git a/client/ayon_core/host/host.py b/client/ayon_core/host/host.py index 081aafdbe3..5a29de6cd7 100644 --- a/client/ayon_core/host/host.py +++ b/client/ayon_core/host/host.py @@ -1,15 +1,13 @@ import os import logging import contextlib -from abc import ABCMeta, abstractproperty -import six +from abc import ABC, abstractproperty # NOTE can't import 'typing' because of issues in Maya 2020 # - shiboken crashes on 'typing' module import -@six.add_metaclass(ABCMeta) -class HostBase(object): +class HostBase(ABC): """Base of host implementation class. Host is pipeline implementation of DCC application. This class should help diff --git a/client/ayon_core/host/interfaces.py b/client/ayon_core/host/interfaces.py index 7157ad6f7e..c077dfeae9 100644 --- a/client/ayon_core/host/interfaces.py +++ b/client/ayon_core/host/interfaces.py @@ -1,5 +1,4 @@ -from abc import ABCMeta, abstractmethod -import six +from abc import ABC, abstractmethod class MissingMethodsError(ValueError): @@ -106,8 +105,7 @@ class ILoadHost: return self.get_containers() -@six.add_metaclass(ABCMeta) -class IWorkfileHost: +class IWorkfileHost(ABC): """Implementation requirements to be able use workfile utils and tool.""" @staticmethod diff --git a/client/ayon_core/lib/attribute_definitions.py b/client/ayon_core/lib/attribute_definitions.py index 0a9d38ab65..979ecf246f 100644 --- a/client/ayon_core/lib/attribute_definitions.py +++ b/client/ayon_core/lib/attribute_definitions.py @@ -91,8 +91,7 @@ class AbstractAttrDefMeta(ABCMeta): return obj -@six.add_metaclass(AbstractAttrDefMeta) -class AbstractAttrDef(object): +class AbstractAttrDef(metaclass=AbstractAttrDefMeta): """Abstraction of attribute definition. Each attribute definition must have implemented validation and diff --git a/client/ayon_core/lib/local_settings.py b/client/ayon_core/lib/local_settings.py index fd255c997f..54432265d9 100644 --- a/client/ayon_core/lib/local_settings.py +++ b/client/ayon_core/lib/local_settings.py @@ -4,7 +4,7 @@ import os import json import platform from datetime import datetime -from abc import ABCMeta, abstractmethod +from abc import ABC, abstractmethod # disable lru cache in Python 2 try: @@ -24,7 +24,6 @@ try: except ImportError: import ConfigParser as configparser -import six import appdirs import ayon_api @@ -133,8 +132,7 @@ class AYONSecureRegistry: keyring.delete_password(self._name, name) -@six.add_metaclass(ABCMeta) -class ASettingRegistry(): +class ASettingRegistry(ABC): """Abstract class defining structure of **SettingRegistry** class. It is implementing methods to store secure items into keyring, otherwise diff --git a/client/ayon_core/pipeline/create/creator_plugins.py b/client/ayon_core/pipeline/create/creator_plugins.py index 0e6025ad3b..624f1c9588 100644 --- a/client/ayon_core/pipeline/create/creator_plugins.py +++ b/client/ayon_core/pipeline/create/creator_plugins.py @@ -3,9 +3,7 @@ import copy import collections from typing import TYPE_CHECKING, Optional -from abc import ABCMeta, abstractmethod - -import six +from abc import ABC, abstractmethod from ayon_core.settings import get_project_settings from ayon_core.lib import Logger @@ -38,8 +36,7 @@ class CreatorError(Exception): super(CreatorError, self).__init__(message) -@six.add_metaclass(ABCMeta) -class ProductConvertorPlugin(object): +class ProductConvertorPlugin(ABC): """Helper for conversion of instances created using legacy creators. Conversion from legacy creators would mean to lose legacy instances, @@ -152,8 +149,7 @@ class ProductConvertorPlugin(object): self._create_context.remove_convertor_item(self.identifier) -@six.add_metaclass(ABCMeta) -class BaseCreator: +class BaseCreator(ABC): """Plugin that create and modify instance data before publishing process. We should maybe find better name as creation is only one part of its logic diff --git a/client/ayon_core/pipeline/publish/abstract_expected_files.py b/client/ayon_core/pipeline/publish/abstract_expected_files.py index f9f3c17ef5..fffe723739 100644 --- a/client/ayon_core/pipeline/publish/abstract_expected_files.py +++ b/client/ayon_core/pipeline/publish/abstract_expected_files.py @@ -1,11 +1,9 @@ # -*- coding: utf-8 -*- """Abstract ExpectedFile class definition.""" -from abc import ABCMeta, abstractmethod -import six +from abc import ABC, abstractmethod -@six.add_metaclass(ABCMeta) -class ExpectedFiles: +class ExpectedFiles(ABC): """Class grouping functionality for all supported renderers. Attributes: diff --git a/client/ayon_core/pipeline/workfile/workfile_template_builder.py b/client/ayon_core/pipeline/workfile/workfile_template_builder.py index 4a1f3a84da..33413b465b 100644 --- a/client/ayon_core/pipeline/workfile/workfile_template_builder.py +++ b/client/ayon_core/pipeline/workfile/workfile_template_builder.py @@ -15,9 +15,8 @@ import os import re import collections import copy -from abc import ABCMeta, abstractmethod +from abc import ABC, abstractmethod -import six from ayon_api import ( get_folders, get_folder_by_path, @@ -82,8 +81,7 @@ class TemplateLoadFailed(Exception): pass -@six.add_metaclass(ABCMeta) -class AbstractTemplateBuilder(object): +class AbstractTemplateBuilder(ABC): """Abstraction of Template Builder. Builder cares about context, shared data, cache, discovery of plugins @@ -941,8 +939,7 @@ class AbstractTemplateBuilder(object): ) -@six.add_metaclass(ABCMeta) -class PlaceholderPlugin(object): +class PlaceholderPlugin(ABC): """Plugin which care about handling of placeholder items logic. Plugin create and update placeholders in scene and populate them on diff --git a/client/ayon_core/plugins/publish/extract_review.py b/client/ayon_core/plugins/publish/extract_review.py index 1891c25521..c2793f98a2 100644 --- a/client/ayon_core/plugins/publish/extract_review.py +++ b/client/ayon_core/plugins/publish/extract_review.py @@ -4,9 +4,8 @@ import copy import json import shutil import subprocess -from abc import ABCMeta, abstractmethod +from abc import ABC, abstractmethod -import six import clique import speedcopy import pyblish.api @@ -1661,8 +1660,7 @@ class ExtractReview(pyblish.api.InstancePlugin): return vf_back -@six.add_metaclass(ABCMeta) -class _OverscanValue: +class _OverscanValue(ABC): def __repr__(self): return "<{}> {}".format(self.__class__.__name__, str(self)) diff --git a/client/ayon_core/tools/common_models/hierarchy.py b/client/ayon_core/tools/common_models/hierarchy.py index f92563db20..6bccb0f468 100644 --- a/client/ayon_core/tools/common_models/hierarchy.py +++ b/client/ayon_core/tools/common_models/hierarchy.py @@ -1,18 +1,16 @@ import time import collections import contextlib -from abc import ABCMeta, abstractmethod +from abc import ABC, abstractmethod import ayon_api -import six from ayon_core.lib import NestedCacheItem HIERARCHY_MODEL_SENDER = "hierarchy.model" -@six.add_metaclass(ABCMeta) -class AbstractHierarchyController: +class AbstractHierarchyController(ABC): @abstractmethod def emit_event(self, topic, data, source): pass diff --git a/client/ayon_core/tools/launcher/abstract.py b/client/ayon_core/tools/launcher/abstract.py index 921fe7bc5b..63ba4cd717 100644 --- a/client/ayon_core/tools/launcher/abstract.py +++ b/client/ayon_core/tools/launcher/abstract.py @@ -1,10 +1,7 @@ -from abc import ABCMeta, abstractmethod - -import six +from abc import ABC, abstractmethod -@six.add_metaclass(ABCMeta) -class AbstractLauncherCommon(object): +class AbstractLauncherCommon(ABC): @abstractmethod def register_event_callback(self, topic, callback): """Register event callback. diff --git a/client/ayon_core/tools/loader/abstract.py b/client/ayon_core/tools/loader/abstract.py index 3a1a23edd7..6a68af1eb5 100644 --- a/client/ayon_core/tools/loader/abstract.py +++ b/client/ayon_core/tools/loader/abstract.py @@ -1,5 +1,4 @@ -from abc import ABCMeta, abstractmethod -import six +from abc import ABC, abstractmethod from ayon_core.lib.attribute_definitions import ( AbstractAttrDef, @@ -347,8 +346,7 @@ class ActionItem: return cls(**data) -@six.add_metaclass(ABCMeta) -class _BaseLoaderController(object): +class _BaseLoaderController(ABC): """Base loader controller abstraction. Abstract base class that is required for both frontend and backed. diff --git a/client/ayon_core/tools/workfiles/abstract.py b/client/ayon_core/tools/workfiles/abstract.py index e949915ab2..b78e987032 100644 --- a/client/ayon_core/tools/workfiles/abstract.py +++ b/client/ayon_core/tools/workfiles/abstract.py @@ -1,7 +1,6 @@ import os -from abc import ABCMeta, abstractmethod +from abc import ABC, abstractmethod -import six from ayon_core.style import get_default_entity_icon_color @@ -335,8 +334,7 @@ class WorkareaFilepathResult: self.filepath = filepath -@six.add_metaclass(ABCMeta) -class AbstractWorkfilesCommon(object): +class AbstractWorkfilesCommon(ABC): @abstractmethod def is_host_valid(self): """Host is valid for workfiles tool work.