ruff rule B

This commit is contained in:
thomas girod 2024-07-08 12:34:06 +02:00
parent 2ac578c3ad
commit c6d2ac9100
6 changed files with 15 additions and 9 deletions

View File

@ -68,5 +68,5 @@ class SignalRequestMiddleware:
self.get_response = get_response self.get_response = get_response
def __call__(self, request): def __call__(self, request):
setattr(_threadlocal, "request", request) _threadlocal.request = request
return self.get_response(request) return self.get_response(request)

View File

@ -434,7 +434,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
def sum_basket(self, request): def sum_basket(self, request):
total = 0 total = 0
for pid, infos in request.session["basket"].items(): for infos in request.session["basket"].values():
total += infos["price"] * infos["qty"] total += infos["price"] * infos["qty"]
return total / 100 return total / 100

View File

@ -72,7 +72,9 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
self.logger = logging.getLogger("main") self.logger = logging.getLogger("main")
if options["verbosity"] < 0 or 2 < options["verbosity"]: if options["verbosity"] < 0 or 2 < options["verbosity"]:
warnings.warn("verbosity level should be between 0 and 2 included") warnings.warn(
"verbosity level should be between 0 and 2 included", stacklevel=2
)
if options["verbosity"] == 2: if options["verbosity"] == 2:
self.logger.setLevel(logging.DEBUG) self.logger.setLevel(logging.DEBUG)

View File

@ -41,7 +41,9 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
logger = logging.getLogger("main") logger = logging.getLogger("main")
if options["verbosity"] < 0 or 2 < options["verbosity"]: if options["verbosity"] < 0 or 2 < options["verbosity"]:
warnings.warn("verbosity level should be between 0 and 2 included") warnings.warn(
"verbosity level should be between 0 and 2 included", stacklevel=2
)
if options["verbosity"] == 2: if options["verbosity"] == 2:
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)

View File

@ -86,7 +86,7 @@ def current_star(self) -> Optional[GalaxyStar]:
# Adding a shortcut to User class for getting its star belonging to the latest ruled Galaxy # Adding a shortcut to User class for getting its star belonging to the latest ruled Galaxy
setattr(User, "current_star", current_star) User.current_star = current_star
class GalaxyLane(models.Model): class GalaxyLane(models.Model):

View File

@ -71,13 +71,15 @@ version = "1.4.25"
[tool.ruff.lint] [tool.ruff.lint]
select = [ select = [
"I", # isort
"B",
"A", # shadowing of Python builtins "A", # shadowing of Python builtins
"F401", # unused import "B",
"C4", # use comprehensions when possible
"I", # isort
"DJ", # django-specific rules, "DJ", # django-specific rules,
"F401", # unused import
"FBT", # boolean trap
"UP008", # Use super() instead of super(__class__, self) "UP008", # Use super() instead of super(__class__, self)
"UP009" # utf-8 encoding declaration is unnecessary "UP009", # utf-8 encoding declaration is unnecessary
] ]
ignore = [ ignore = [