Changes made by ruff
This commit is contained in:
parent
8b65e85641
commit
2af766a8b3
@ -118,7 +118,7 @@ async def get_current_user(
|
|||||||
|
|
||||||
|
|
||||||
async def get_current_active_user(
|
async def get_current_active_user(
|
||||||
current_user: UserToken = Security(get_current_user, scopes=["authenticated"])
|
current_user: UserToken = Security(get_current_user, scopes=["authenticated"]),
|
||||||
) -> UserToken:
|
) -> UserToken:
|
||||||
if current_user.locked_out:
|
if current_user.locked_out:
|
||||||
raise HTTPException(status_code=400, detail="Inactive user")
|
raise HTTPException(status_code=400, detail="Inactive user")
|
||||||
|
@ -21,5 +21,7 @@ class Role:
|
|||||||
name: Mapped[str] = mapped_column(Unicode, unique=True)
|
name: Mapped[str] = mapped_column(Unicode, unique=True)
|
||||||
|
|
||||||
permissions: Mapped[list["Permission"]] = relationship(
|
permissions: Mapped[list["Permission"]] = relationship(
|
||||||
"Permission", secondary=RolePermission.__table__, back_populates="roles" # type: ignore[attr-defined]
|
"Permission",
|
||||||
|
secondary=RolePermission.__table__,
|
||||||
|
back_populates="roles", # type: ignore[attr-defined]
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ router = APIRouter()
|
|||||||
|
|
||||||
@router.post("", response_model=list[schemas.BatchIntegrity])
|
@router.post("", response_model=list[schemas.BatchIntegrity])
|
||||||
def post_check_batch_integrity(
|
def post_check_batch_integrity(
|
||||||
user: UserToken = Security(get_user, scopes=["product-ledger"])
|
user: UserToken = Security(get_user, scopes=["product-ledger"]),
|
||||||
) -> list[schemas.BatchIntegrity]:
|
) -> list[schemas.BatchIntegrity]:
|
||||||
with SessionFuture() as db:
|
with SessionFuture() as db:
|
||||||
info = negative_batches(db) + batch_dates(db)
|
info = negative_batches(db) + batch_dates(db)
|
||||||
|
@ -33,7 +33,8 @@ def get_duplicate_attendances(db: Session) -> int:
|
|||||||
)
|
)
|
||||||
query: int = db.execute(
|
query: int = db.execute(
|
||||||
select(func.count(Attendance.id)).where(
|
select(func.count(Attendance.id)).where(
|
||||||
~Attendance.id.in_(sub_query), Attendance.is_valid == True # noqa: E712
|
~Attendance.id.in_(sub_query),
|
||||||
|
Attendance.is_valid == True, # noqa: E712
|
||||||
)
|
)
|
||||||
).scalar_one()
|
).scalar_one()
|
||||||
return query
|
return query
|
||||||
|
@ -72,7 +72,8 @@ async def login_for_access_token(
|
|||||||
)
|
)
|
||||||
db.execute(
|
db.execute(
|
||||||
delete(Client).where(
|
delete(Client).where(
|
||||||
Client.creation_date < datetime.utcnow() - timedelta(days=3), Client.enabled == False # noqa: E712
|
Client.creation_date < datetime.utcnow() - timedelta(days=3),
|
||||||
|
Client.enabled == False, # noqa: E712
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
@ -90,9 +91,7 @@ async def login_for_access_token(
|
|||||||
data={
|
data={
|
||||||
"sub": user.name,
|
"sub": user.name,
|
||||||
"scopes": ["authenticated"]
|
"scopes": ["authenticated"]
|
||||||
+ list(
|
+ list(set([p.name.replace(" ", "-").lower() for r in user.roles for p in r.permissions])), # noqa: W503
|
||||||
set([p.name.replace(" ", "-").lower() for r in user.roles for p in r.permissions])
|
|
||||||
), # noqa: W503
|
|
||||||
"userId": str(user.id),
|
"userId": str(user.id),
|
||||||
"lockedOut": user.locked_out,
|
"lockedOut": user.locked_out,
|
||||||
"ver": __version__.__version__,
|
"ver": __version__.__version__,
|
||||||
|
@ -59,7 +59,8 @@ def rebase(
|
|||||||
|
|
||||||
def save_starred(date_: date, db: Session) -> list[uuid.UUID]:
|
def save_starred(date_: date, db: Session) -> list[uuid.UUID]:
|
||||||
accounts = [
|
accounts = [
|
||||||
i.id for i in db.execute(select(AccountBase.id).where(AccountBase.is_starred == True)).all() # noqa: E712
|
i.id
|
||||||
|
for i in db.execute(select(AccountBase.id).where(AccountBase.is_starred == True)).all() # noqa: E712
|
||||||
]
|
]
|
||||||
vouchers: list[uuid.UUID] = []
|
vouchers: list[uuid.UUID] = []
|
||||||
query = (
|
query = (
|
||||||
|
@ -21,7 +21,7 @@ router = APIRouter()
|
|||||||
|
|
||||||
@router.post("", response_model=list[schemas.NonContractPurchase])
|
@router.post("", response_model=list[schemas.NonContractPurchase])
|
||||||
def non_contract_purchases(
|
def non_contract_purchases(
|
||||||
user: UserToken = Security(get_user, scopes=["product-ledger"])
|
user: UserToken = Security(get_user, scopes=["product-ledger"]),
|
||||||
) -> list[schemas.NonContractPurchase]:
|
) -> list[schemas.NonContractPurchase]:
|
||||||
with SessionFuture() as db:
|
with SessionFuture() as db:
|
||||||
return report(db)
|
return report(db)
|
||||||
|
12
lint.sh
12
lint.sh
@ -8,11 +8,9 @@ cd "$parent_path/overlord" || exit
|
|||||||
npx prettier --write src/app
|
npx prettier --write src/app
|
||||||
npx ng lint --fix
|
npx ng lint --fix
|
||||||
cd "$parent_path/brewman" || exit
|
cd "$parent_path/brewman" || exit
|
||||||
isort brewman
|
|
||||||
black brewman
|
|
||||||
flake8 brewman
|
|
||||||
|
|
||||||
# ruff check . # Lint all files in the current directory (and any subdirectories)
|
ruff format brewman/
|
||||||
# bandit --recursive brewman
|
ruff check . # Lint all files in the current directory (and any subdirectories)
|
||||||
# bandit --recursive .
|
bandit --recursive brewman
|
||||||
# safety check
|
bandit --recursive .
|
||||||
|
safety check
|
Loading…
x
Reference in New Issue
Block a user