lint: tidying up code in block tasks

This commit is contained in:
Iain Learmonth 2022-06-17 12:42:42 +01:00
parent a0da4d4641
commit ac5a604587
8 changed files with 86 additions and 49 deletions

View file

@ -1,3 +1,4 @@
import logging
from abc import abstractmethod
from datetime import datetime
from typing import Union, List, Optional, Any
@ -78,9 +79,13 @@ class AbstractResource(db.Model): # type: ignore
raise NotImplementedError()
def deprecate(self, *, reason: str) -> None:
self.deprecated = datetime.utcnow()
self.deprecation_reason = reason
self.updated = datetime.utcnow()
if self.deprecated is not None:
logging.info("Deprecating %s (reason=%s)", (self.brn, reason))
self.deprecated = datetime.utcnow()
self.deprecation_reason = reason
self.updated = datetime.utcnow()
else:
logging.info("Not deprecating %s (reason=%s) because it's already deprecated", (self.brn, reason))
def destroy(self) -> None:
if self.deprecated is None: