mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-15 13:31:19 -05:00
chores: updates-and-linters (#1868)
* switch to ruff * add ruff * run ruff --fix * update ruff * resolve ruff errors * drop isort from CI * fix decorator order
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
"""
|
||||
This package containers helpful development tools to be used for development and testing. It shouldn't be used for or imported
|
||||
in production
|
||||
"""
|
||||
|
||||
from .lifespan_tracker import *
|
||||
from .timer import *
|
||||
@@ -1,26 +0,0 @@
|
||||
import time
|
||||
|
||||
|
||||
# log_lifetime is a class decorator that logs the creation and destruction of a class
|
||||
# It is used to track the lifespan of a class during development or testing.
|
||||
# It SHOULD NOT be used in production code.
|
||||
def log_lifetime(cls):
|
||||
class LifeTimeClass(cls):
|
||||
def __init__(self, *args, **kwargs):
|
||||
print(f"Creating an instance of {cls.__name__}") # noqa: T001
|
||||
self.__lifespan_timer_start = time.perf_counter()
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __del__(self):
|
||||
toc = time.perf_counter()
|
||||
print(f"Downloaded the tutorial in {toc - self.__lifespan_timer_start:0.4f} seconds") # noqa: T001
|
||||
|
||||
print(f"Deleting an instance of {cls.__name__}") # noqa: T001
|
||||
|
||||
try:
|
||||
super().__del__()
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
return LifeTimeClass
|
||||
@@ -1,12 +0,0 @@
|
||||
import time
|
||||
|
||||
|
||||
def timer(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
start = time.time()
|
||||
result = func(*args, **kwargs)
|
||||
end = time.time()
|
||||
print(f"{func.__name__} took {end - start} seconds") # noqa: T001
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
Reference in New Issue
Block a user