🚨 Fixed deepsource issues
This commit is contained in:
@@ -20,6 +20,7 @@ class Memory(BaseModel):
|
||||
|
||||
|
||||
class Markdown(BaseModel):
|
||||
# skipcq: PTC-W0052
|
||||
markdown: str
|
||||
|
||||
|
||||
|
||||
@@ -24,16 +24,6 @@ async def rememberme_middleware(request: Request, call_next):
|
||||
rememberme_cookie = request.cookies.get("rememberme_token")
|
||||
bearer_token = request.cookies.get("access_token")
|
||||
conditions_to_handle_met = True
|
||||
# print(bearer_token)
|
||||
# if bearer_token is not None:
|
||||
# bearer_token = bearer_token.replace("Bearer ", "")
|
||||
# test = jws.verify(bearer_token, settings.secret_key, algorithms=["HS256"])
|
||||
# try:
|
||||
# jwt.decode(bearer_token, settings.secret_key, algorithms=["HS256"])
|
||||
# print("jwt ok")
|
||||
# except JWTError as e:
|
||||
# print("jwt failed")
|
||||
# print(test)
|
||||
|
||||
scheme, param = get_authorization_scheme_param(bearer_token)
|
||||
|
||||
@@ -71,7 +61,6 @@ async def rememberme_middleware(request: Request, call_next):
|
||||
response: Response = await call_next(request)
|
||||
return response
|
||||
access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||
# access_token_expires = timedelta(seconds=1)
|
||||
access_token = create_access_token(data={"sub": user_session.user.email}, expires_delta=access_token_expires)
|
||||
await user_session.update(last_seen=datetime.now())
|
||||
request.state.access_token = f"Bearer {access_token}"
|
||||
|
||||
@@ -111,7 +111,7 @@ async def websocket_endpoint(ws: WebSocket, game_id: str, id: str):
|
||||
try:
|
||||
if id in wss_clients:
|
||||
await ws.close(code=status.WS_1001_GOING_AWAY)
|
||||
print("Client {} already exists.".format(id))
|
||||
print(f"Client {id} already exists.")
|
||||
return
|
||||
|
||||
await ws.accept()
|
||||
@@ -146,8 +146,8 @@ async def websocket_endpoint(ws: WebSocket, game_id: str, id: str):
|
||||
continue
|
||||
|
||||
await submit_answer_fn(answer_index, game_pin, player_id, now)
|
||||
print("Data from client {}: {}".format(id, data))
|
||||
print(f"Data from client {id}: {data}")
|
||||
|
||||
except WebSocketDisconnect as ex:
|
||||
print("Client {} is disconnected: {}".format(id, ex))
|
||||
print(f"Client {id} is disconnected: {ex}")
|
||||
wss_clients.pop(id, None)
|
||||
|
||||
@@ -161,7 +161,10 @@ async def upload_raw_file(request: Request, user: User = Depends(get_current_use
|
||||
)
|
||||
# https://github.com/VirusTotal/vt-py/issues/119#issuecomment-1261246867
|
||||
await storage.upload(
|
||||
file_name=file_id.hex, file_data=data_file._file, mime_type=request.headers.get("Content-Type")
|
||||
# skipcq: PYL-W0212
|
||||
file_name=file_id.hex,
|
||||
file_data=data_file._file,
|
||||
mime_type=request.headers.get("Content-Type"),
|
||||
)
|
||||
await file_obj.save()
|
||||
await arq.enqueue_job("calculate_hash", file_id.hex)
|
||||
@@ -231,8 +234,7 @@ async def list_images(
|
||||
|
||||
@router.get("/list/last")
|
||||
async def get_latest_images(count: int = 50, user: User = Depends(get_current_user)) -> list[PrivateStorageItem]:
|
||||
if count > 50:
|
||||
count = 50
|
||||
count = min(count, 50)
|
||||
items = (
|
||||
await StorageItem.objects.filter(user=user)
|
||||
.limit(count)
|
||||
|
||||
@@ -252,8 +252,8 @@ class ReturnQuestion(QuizQuestion):
|
||||
raise ValueError("Answers can't be none if type is ABCD")
|
||||
if values["type"] == QuizQuestionType.RANGE and type(v) != RangeQuizAnswerWithoutSolution:
|
||||
raise ValueError("Answer must be from type RangeQuizAnswer if type is RANGE")
|
||||
# skipcq: PTC-W0047
|
||||
if values["type"] == QuizQuestionType.VOTING and type(v[0]) != VotingQuizAnswer:
|
||||
# skipcq: PTC-W0047
|
||||
pass
|
||||
return v
|
||||
|
||||
@@ -362,10 +362,7 @@ async def submit_answer(sid: str, data: dict):
|
||||
for i, a in enumerate(game_data.questions[int(float(data.question_index))].answers):
|
||||
if a.right:
|
||||
correct_string += str(i)
|
||||
if correct_string == data.answer:
|
||||
answer_right = True
|
||||
else:
|
||||
answer_right = False
|
||||
answer_right = bool(correct_string == data.answer)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
latency = int(float((await sio.get_session(sid))["ping"]))
|
||||
|
||||
@@ -21,7 +21,6 @@ async def shutdown(ctx):
|
||||
|
||||
|
||||
class WorkerSettings:
|
||||
# functions = [add_track]
|
||||
functions = [calculate_hash, quiz_update]
|
||||
cron_jobs = [cron(clean_editor_images_up, hour={0, 6, 12, 18}, minute=0)]
|
||||
on_startup = startup
|
||||
|
||||
@@ -40,8 +40,11 @@ export const getContrast = (foregroundColor: RGB, backgroundColor: RGB) => {
|
||||
export const getRgbColorFromHex = (hex: string): RGB => {
|
||||
hex = hex.slice(1);
|
||||
const value = parseInt(hex, 16);
|
||||
// skipcq: JS-C1002
|
||||
const r = (value >> 16) & 255;
|
||||
// skipcq: JS-C1002
|
||||
const g = (value >> 8) & 255;
|
||||
// skipcq: JS-C1002
|
||||
const b = value & 255;
|
||||
|
||||
return [r, g, b] as RGB;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { signedIn } from '$lib/stores';
|
||||
import type { LayoutServerLoad } from './$types';
|
||||
|
||||
export const load: LayoutServerLoad = async ({ locals }) => {
|
||||
export const load: LayoutServerLoad = ({ locals }) => {
|
||||
if (locals.email) {
|
||||
signedIn.set(true);
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load = (async ({ setHeaders }) => {
|
||||
export const load = (({ setHeaders }) => {
|
||||
setHeaders({
|
||||
'Cross-Origin-Embedder-Policy': 'require-corp',
|
||||
'Cross-Origin-Opener-Policy': 'same-origin'
|
||||
|
||||
Reference in New Issue
Block a user