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:
Hayden
2022-11-30 20:20:28 -09:00
committed by GitHub
parent fd0e02a5c6
commit 82dc586bac
62 changed files with 362 additions and 536 deletions

View File

@@ -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 *

View File

@@ -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

View File

@@ -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