From 038fc48ac0dd50e0ec5483809e15b316e8806e12 Mon Sep 17 00:00:00 2001 From: Michael Poluektov Date: Wed, 14 Aug 2024 13:39:53 +0100 Subject: [PATCH] replace == None with is None --- backend/apps/images/main.py | 8 ++++---- backend/apps/rag/main.py | 8 ++++---- backend/apps/webui/models/tags.py | 2 +- backend/apps/webui/routers/documents.py | 2 +- backend/apps/webui/routers/functions.py | 2 +- backend/apps/webui/routers/prompts.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/apps/images/main.py b/backend/apps/images/main.py index f4dfc8a73..d2f5ddd5d 100644 --- a/backend/apps/images/main.py +++ b/backend/apps/images/main.py @@ -94,7 +94,7 @@ app.state.config.COMFYUI_FLUX_FP8_CLIP = COMFYUI_FLUX_FP8_CLIP def get_automatic1111_api_auth(): - if app.state.config.AUTOMATIC1111_API_AUTH == None: + if app.state.config.AUTOMATIC1111_API_AUTH is None: return "" else: auth1111_byte_string = app.state.config.AUTOMATIC1111_API_AUTH.encode("utf-8") @@ -145,7 +145,7 @@ async def get_engine_url(user=Depends(get_admin_user)): async def update_engine_url( form_data: EngineUrlUpdateForm, user=Depends(get_admin_user) ): - if form_data.AUTOMATIC1111_BASE_URL == None: + if form_data.AUTOMATIC1111_BASE_URL is None: app.state.config.AUTOMATIC1111_BASE_URL = AUTOMATIC1111_BASE_URL else: url = form_data.AUTOMATIC1111_BASE_URL.strip("/") @@ -156,7 +156,7 @@ async def update_engine_url( except Exception as e: raise HTTPException(status_code=400, detail=ERROR_MESSAGES.INVALID_URL) - if form_data.COMFYUI_BASE_URL == None: + if form_data.COMFYUI_BASE_URL is None: app.state.config.COMFYUI_BASE_URL = COMFYUI_BASE_URL else: url = form_data.COMFYUI_BASE_URL.strip("/") @@ -168,7 +168,7 @@ async def update_engine_url( except Exception as e: raise HTTPException(status_code=400, detail=ERROR_MESSAGES.INVALID_URL) - if form_data.AUTOMATIC1111_API_AUTH == None: + if form_data.AUTOMATIC1111_API_AUTH is None: app.state.config.AUTOMATIC1111_API_AUTH = AUTOMATIC1111_API_AUTH else: app.state.config.AUTOMATIC1111_API_AUTH = form_data.AUTOMATIC1111_API_AUTH diff --git a/backend/apps/rag/main.py b/backend/apps/rag/main.py index 8b7cf2dab..bd181c5f7 100644 --- a/backend/apps/rag/main.py +++ b/backend/apps/rag/main.py @@ -1185,7 +1185,7 @@ def store_doc( f.close() f = open(file_path, "rb") - if collection_name == None: + if collection_name is None: collection_name = calculate_sha256(f)[:63] f.close() @@ -1238,7 +1238,7 @@ def process_doc( f = open(file_path, "rb") collection_name = form_data.collection_name - if collection_name == None: + if collection_name is None: collection_name = calculate_sha256(f)[:63] f.close() @@ -1296,7 +1296,7 @@ def store_text( ): collection_name = form_data.collection_name - if collection_name == None: + if collection_name is None: collection_name = calculate_sha256_string(form_data.content) result = store_text_in_vector_db( @@ -1339,7 +1339,7 @@ def scan_docs_dir(user=Depends(get_admin_user)): sanitized_filename = sanitize_filename(filename) doc = Documents.get_doc_by_name(sanitized_filename) - if doc == None: + if doc is None: doc = Documents.insert_new_doc( user.id, DocumentForm( diff --git a/backend/apps/webui/models/tags.py b/backend/apps/webui/models/tags.py index 58c0218ea..63a8cb4ca 100644 --- a/backend/apps/webui/models/tags.py +++ b/backend/apps/webui/models/tags.py @@ -109,7 +109,7 @@ class TagTable: self, user_id: str, form_data: ChatIdTagForm ) -> Optional[ChatIdTagModel]: tag = self.get_tag_by_name_and_user_id(form_data.tag_name, user_id) - if tag == None: + if tag is None: tag = self.insert_new_tag(form_data.tag_name, user_id) id = str(uuid.uuid4()) diff --git a/backend/apps/webui/routers/documents.py b/backend/apps/webui/routers/documents.py index 2299b2fee..5043959c7 100644 --- a/backend/apps/webui/routers/documents.py +++ b/backend/apps/webui/routers/documents.py @@ -46,7 +46,7 @@ async def get_documents(user=Depends(get_verified_user)): @router.post("/create", response_model=Optional[DocumentResponse]) async def create_new_doc(form_data: DocumentForm, user=Depends(get_admin_user)): doc = Documents.get_doc_by_name(form_data.name) - if doc == None: + if doc is None: doc = Documents.insert_new_doc(user.id, form_data) if doc: diff --git a/backend/apps/webui/routers/functions.py b/backend/apps/webui/routers/functions.py index 94238208b..3e7737c04 100644 --- a/backend/apps/webui/routers/functions.py +++ b/backend/apps/webui/routers/functions.py @@ -63,7 +63,7 @@ async def create_new_function( form_data.id = form_data.id.lower() function = Functions.get_function_by_id(form_data.id) - if function == None: + if function is None: function_path = os.path.join(FUNCTIONS_DIR, f"{form_data.id}.py") try: with open(function_path, "w") as function_file: diff --git a/backend/apps/webui/routers/prompts.py b/backend/apps/webui/routers/prompts.py index c674590e9..bdab6d556 100644 --- a/backend/apps/webui/routers/prompts.py +++ b/backend/apps/webui/routers/prompts.py @@ -31,7 +31,7 @@ async def get_prompts(user=Depends(get_verified_user)): @router.post("/create", response_model=Optional[PromptModel]) async def create_new_prompt(form_data: PromptForm, user=Depends(get_admin_user)): prompt = Prompts.get_prompt_by_command(form_data.command) - if prompt == None: + if prompt is None: prompt = Prompts.insert_new_prompt(user.id, form_data) if prompt: