Changes made by ruff

This commit is contained in:
Amritanshu Agrawal 2023-12-25 10:53:21 +05:30
parent 8b65e85641
commit 2af766a8b3
8 changed files with 18 additions and 17 deletions

View File

@ -118,7 +118,7 @@ async def get_current_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:
if current_user.locked_out:
raise HTTPException(status_code=400, detail="Inactive user")

View File

@ -21,5 +21,7 @@ class Role:
name: Mapped[str] = mapped_column(Unicode, unique=True)
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]
)

View File

@ -26,7 +26,7 @@ router = APIRouter()
@router.post("", response_model=list[schemas.BatchIntegrity])
def post_check_batch_integrity(
user: UserToken = Security(get_user, scopes=["product-ledger"])
user: UserToken = Security(get_user, scopes=["product-ledger"]),
) -> list[schemas.BatchIntegrity]:
with SessionFuture() as db:
info = negative_batches(db) + batch_dates(db)

View File

@ -33,7 +33,8 @@ def get_duplicate_attendances(db: Session) -> int:
)
query: int = db.execute(
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()
return query

View File

@ -72,7 +72,8 @@ async def login_for_access_token(
)
db.execute(
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()
@ -90,9 +91,7 @@ async def login_for_access_token(
data={
"sub": user.name,
"scopes": ["authenticated"]
+ list(
set([p.name.replace(" ", "-").lower() for r in user.roles for p in r.permissions])
), # noqa: W503
+ list(set([p.name.replace(" ", "-").lower() for r in user.roles for p in r.permissions])), # noqa: W503
"userId": str(user.id),
"lockedOut": user.locked_out,
"ver": __version__.__version__,

View File

@ -59,7 +59,8 @@ def rebase(
def save_starred(date_: date, db: Session) -> list[uuid.UUID]:
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] = []
query = (

View File

@ -21,7 +21,7 @@ router = APIRouter()
@router.post("", response_model=list[schemas.NonContractPurchase])
def non_contract_purchases(
user: UserToken = Security(get_user, scopes=["product-ledger"])
user: UserToken = Security(get_user, scopes=["product-ledger"]),
) -> list[schemas.NonContractPurchase]:
with SessionFuture() as db:
return report(db)

12
lint.sh
View File

@ -8,11 +8,9 @@ cd "$parent_path/overlord" || exit
npx prettier --write src/app
npx ng lint --fix
cd "$parent_path/brewman" || exit
isort brewman
black brewman
flake8 brewman
# ruff check . # Lint all files in the current directory (and any subdirectories)
# bandit --recursive brewman
# bandit --recursive .
# safety check
ruff format brewman/
ruff check . # Lint all files in the current directory (and any subdirectories)
bandit --recursive brewman
bandit --recursive .
safety check