From 65a02f7d32ccfb096b1a2f1bd3d3964ca9a0f00c Mon Sep 17 00:00:00 2001 From: Bowen Liang Date: Wed, 7 Feb 2024 16:28:45 +0800 Subject: [PATCH] chore: apply F811 linter rule to eliminate redefined imports and methods (#2412) --- .../service_api/dataset/document.py | 1 - .../model_providers/spark/llm/_client.py | 1 - api/core/third_party/spark/spark_llm.py | 1 - api/libs/gmpy2_pkcs10aep_cipher.py | 38 ------------------- api/pyproject.toml | 1 + 5 files changed, 1 insertion(+), 41 deletions(-) diff --git a/api/controllers/service_api/dataset/document.py b/api/controllers/service_api/dataset/document.py index c997edc234..cbe0517ed3 100644 --- a/api/controllers/service_api/dataset/document.py +++ b/api/controllers/service_api/dataset/document.py @@ -1,7 +1,6 @@ import json from flask import request -from flask_login import current_user from flask_restful import marshal, reqparse from sqlalchemy import desc from werkzeug.exceptions import NotFound diff --git a/api/core/model_runtime/model_providers/spark/llm/_client.py b/api/core/model_runtime/model_providers/spark/llm/_client.py index 9390f4351b..a4659454ee 100644 --- a/api/core/model_runtime/model_providers/spark/llm/_client.py +++ b/api/core/model_runtime/model_providers/spark/llm/_client.py @@ -1,5 +1,4 @@ import base64 -import datetime import hashlib import hmac import json diff --git a/api/core/third_party/spark/spark_llm.py b/api/core/third_party/spark/spark_llm.py index ff7f04c396..5c97bba530 100644 --- a/api/core/third_party/spark/spark_llm.py +++ b/api/core/third_party/spark/spark_llm.py @@ -1,5 +1,4 @@ import base64 -import datetime import hashlib import hmac import json diff --git a/api/libs/gmpy2_pkcs10aep_cipher.py b/api/libs/gmpy2_pkcs10aep_cipher.py index e4af4309ab..26d1179ac3 100644 --- a/api/libs/gmpy2_pkcs10aep_cipher.py +++ b/api/libs/gmpy2_pkcs10aep_cipher.py @@ -238,41 +238,3 @@ def new(key, hashAlgo=None, mgfunc=None, label=b'', randfunc=None): if randfunc is None: randfunc = Random.get_random_bytes return PKCS1OAEP_Cipher(key, hashAlgo, mgfunc, label, randfunc) - - -def new(key, hashAlgo=None, mgfunc=None, label=b'', randfunc=None): - """Return a cipher object :class:`PKCS1OAEP_Cipher` that can be used to perform PKCS#1 OAEP encryption or decryption. - - :param key: - The key object to use to encrypt or decrypt the message. - Decryption is only possible with a private RSA key. - :type key: RSA key object - - :param hashAlgo: - The hash function to use. This can be a module under `Crypto.Hash` - or an existing hash object created from any of such modules. - If not specified, `Crypto.Hash.SHA1` is used. - :type hashAlgo: hash object - - :param mgfunc: - A mask generation function that accepts two parameters: a string to - use as seed, and the lenth of the mask to generate, in bytes. - If not specified, the standard MGF1 consistent with ``hashAlgo`` is used (a safe choice). - :type mgfunc: callable - - :param label: - A label to apply to this particular encryption. If not specified, - an empty string is used. Specifying a label does not improve - security. - :type label: bytes/bytearray/memoryview - - :param randfunc: - A function that returns random bytes. - The default is `Random.get_random_bytes`. - :type randfunc: callable - """ - - if randfunc is None: - randfunc = Random.get_random_bytes - return PKCS1OAEP_Cipher(key, hashAlgo, mgfunc, label, randfunc) - diff --git a/api/pyproject.toml b/api/pyproject.toml index 2061092ef5..9c12f58527 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -14,4 +14,5 @@ select = [ "F401", # unused-import "I001", # unsorted-imports "I002", # missing-required-import + "F811", # redefined-while-unused ]