Fix a few `ruff` linter errors

This commit is contained in:
Oystein Kristoffer Tveit 2023-08-30 00:06:58 +02:00
parent c219fa61ba
commit 58b4f7913f
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
5 changed files with 39 additions and 9 deletions

View File

@ -44,7 +44,7 @@ def search_product(string, session, find_hidden_products=True):
.filter(
or_(
Product.bar_code == string,
and_(Product.name == string, Product.hidden == False),
and_(Product.name == string, Product.hidden is False),
)
)
.first()
@ -68,7 +68,7 @@ def search_product(string, session, find_hidden_products=True):
.filter(
or_(
Product.bar_code.ilike(f"%{string}%"),
and_(Product.name.ilike(f"%{string}%"), Product.hidden == False),
and_(Product.name.ilike(f"%{string}%"), Product.hidden is False),
)
)
.all()
@ -103,14 +103,13 @@ def guess_data_type(string):
def argmax(d, all=False, value=None):
maxarg = None
maxargs = []
if value != None:
if value is not None:
dd = d
d = {}
for key in list(dd.keys()):
d[key] = value(dd[key])
for key in list(d.keys()):
if maxarg == None or d[key] > d[maxarg]:
if maxarg is None or d[key] > d[maxarg]:
maxarg = key
if all:
return [k for k in list(d.keys()) if d[k] == d[maxarg]]

View File

@ -283,10 +283,8 @@ def buildDatabaseFromDb(inputType, inputProduct, inputUser):
for transaction in transaction_list:
if transaction.purchase:
products = "¤".join([ent.product.name for ent in transaction.purchase.entries])
description = ""
else:
products = ""
description = transaction.description
line = line_format % (
"purchase",
transaction.time,

View File

@ -1,3 +1,28 @@
__all__ = [
"AddProductMenu",
"AddStockMenu",
"AddUserMenu",
"AdjustCreditMenu",
"AdjustStockMenu",
"BalanceMenu",
"BuyMenu",
"CleanupStockMenu",
"EditProductMenu",
"EditUserMenu",
"FAQMenu",
"LoggedStatisticsMenu",
"MainMenu",
"Menu",
"PrintLabelMenu",
"ProductListMenu",
"ProductPopularityMenu",
"ProductRevenueMenu",
"ProductSearchMenu",
"ShowUserMenu",
"TransferMenu",
"UserListMenu",
]
from .addstock import AddStockMenu
from .buymenu import BuyMenu
from .editing import (

View File

@ -5,10 +5,8 @@ from datetime import datetime
import math
from sqlalchemy import (
Boolean,
DateTime,
Integer,
String,
)
from sqlalchemy.orm import (
Mapped,

View File

@ -1,3 +1,13 @@
__all__ = [
'Base',
'Product',
'Purchase',
'PurchaseEntry',
'Transaction',
'User',
'UserProducts',
]
from .Base import Base
from .Product import Product
from .Purchase import Purchase