mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-11-03 23:33:41 +00:00 
			
		
		
		
	style: highligh __del__ methods in formatting
This commit is contained in:
		@ -122,7 +122,7 @@ Again, the most checks can be performed by `make check` command, though some add
 | 
			
		||||
        def __hash__(self) -> int: ...  # basically any magic (or look-alike) method
 | 
			
		||||
    ```
 | 
			
		||||
  
 | 
			
		||||
  Methods inside one group should be ordered alphabetically, the only exceptions are `__init__` (`__post_init__` for dataclasses) and `__new__` methods which should be defined first. For test methods it is recommended to follow the order in which functions are defined.
 | 
			
		||||
  Methods inside one group should be ordered alphabetically, the only exceptions are `__init__` (`__post_init__` for dataclasses), `__new__` and `__del__` methods which should be defined first. For test methods it is recommended to follow the order in which functions are defined.
 | 
			
		||||
 | 
			
		||||
  Though, we would like to highlight abstract methods (i.e. ones which raise `NotImplementedError`), we still keep in global order at the moment.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -31,6 +31,7 @@ class MethodTypeOrder(StrEnum):
 | 
			
		||||
 | 
			
		||||
    Attributes:
 | 
			
		||||
        Class(MethodTypeOrder): (class attribute) class method
 | 
			
		||||
        Delete(MethodTypeOrder): (class attribute) destructor-like methods
 | 
			
		||||
        Init(MethodTypeOrder): (class attribute) initialization method
 | 
			
		||||
        Magic(MethodTypeOrder): (class attribute) other magical methods
 | 
			
		||||
        New(MethodTypeOrder): (class attribute) constructor method
 | 
			
		||||
@ -40,6 +41,7 @@ class MethodTypeOrder(StrEnum):
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    Class = "classmethod"
 | 
			
		||||
    Delete = "del"
 | 
			
		||||
    Init = "init"
 | 
			
		||||
    Magic = "magic"
 | 
			
		||||
    New = "new"
 | 
			
		||||
@ -76,8 +78,9 @@ class DefinitionOrder(BaseRawFileChecker):
 | 
			
		||||
            "method-type-order",
 | 
			
		||||
            {
 | 
			
		||||
                "default": [
 | 
			
		||||
                    "new",
 | 
			
		||||
                    "init",
 | 
			
		||||
                    "new",
 | 
			
		||||
                    "del",
 | 
			
		||||
                    "property",
 | 
			
		||||
                    "classmethod",
 | 
			
		||||
                    "staticmethod",
 | 
			
		||||
@ -122,10 +125,12 @@ class DefinitionOrder(BaseRawFileChecker):
 | 
			
		||||
            MethodTypeOrder: resolved function type
 | 
			
		||||
        """
 | 
			
		||||
        # init methods
 | 
			
		||||
        if function.name in ("__new__",):
 | 
			
		||||
            return MethodTypeOrder.New
 | 
			
		||||
        if function.name in ("__init__", "__post_init__"):
 | 
			
		||||
            return MethodTypeOrder.Init
 | 
			
		||||
        if function.name in ("__new__",):
 | 
			
		||||
            return MethodTypeOrder.New
 | 
			
		||||
        if function.name in ("__del__",):
 | 
			
		||||
            return MethodTypeOrder.Delete
 | 
			
		||||
 | 
			
		||||
        # decorated methods
 | 
			
		||||
        decorators = []
 | 
			
		||||
 | 
			
		||||
@ -65,6 +65,14 @@ class TriggerLoader(LazyLogging):
 | 
			
		||||
        self._on_stop_requested = False
 | 
			
		||||
        self.triggers: list[Trigger] = []
 | 
			
		||||
 | 
			
		||||
    def __del__(self) -> None:
 | 
			
		||||
        """
 | 
			
		||||
        custom destructor object which calls on_stop in case if it was requested
 | 
			
		||||
        """
 | 
			
		||||
        if not self._on_stop_requested:
 | 
			
		||||
            return
 | 
			
		||||
        self.on_stop()
 | 
			
		||||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def load(cls, repository_id: RepositoryId, configuration: Configuration) -> Self:
 | 
			
		||||
        """
 | 
			
		||||
@ -257,11 +265,3 @@ class TriggerLoader(LazyLogging):
 | 
			
		||||
        for trigger in self.triggers:
 | 
			
		||||
            with self.__execute_trigger(trigger):
 | 
			
		||||
                trigger.on_stop()
 | 
			
		||||
 | 
			
		||||
    def __del__(self) -> None:
 | 
			
		||||
        """
 | 
			
		||||
        custom destructor object which calls on_stop in case if it was requested
 | 
			
		||||
        """
 | 
			
		||||
        if not self._on_stop_requested:
 | 
			
		||||
            return
 | 
			
		||||
        self.on_stop()
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user