Add missing Optional on a few nullable fields (#4076)

## What type of PR is this? (check all applicable)

- [x] Refactor

## Have you discussed this change with the InvokeAI team?
- [ ] Yes
- [x] No, because: trivial

## Description

Adds a few obviously missing `Optional` on fields that default to
`None`.
This commit is contained in:
Kent Keirsey 2023-07-31 16:56:10 -04:00 committed by GitHub
commit ae0f4efcca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,6 @@
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) # Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
from typing import Optional
from logging import Logger from logging import Logger
import os import os
from invokeai.app.services.board_image_record_storage import ( from invokeai.app.services.board_image_record_storage import (
@ -54,7 +55,7 @@ logger = InvokeAILogger.getLogger()
class ApiDependencies: class ApiDependencies:
"""Contains and initializes all dependencies for the API""" """Contains and initializes all dependencies for the API"""
invoker: Invoker = None invoker: Optional[Invoker] = None
@staticmethod @staticmethod
def initialize(config: InvokeAIAppConfig, event_handler_id: int, logger: Logger = logger): def initialize(config: InvokeAIAppConfig, event_handler_id: int, logger: Logger = logger):

View File

@ -7,7 +7,7 @@ import warnings
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from typing import List, Dict, Callable, Union, Set, Optional from typing import Optional, List, Dict, Callable, Union, Set
import requests import requests
from diffusers import DiffusionPipeline from diffusers import DiffusionPipeline
@ -86,8 +86,8 @@ class ModelLoadInfo:
name: str name: str
model_type: ModelType model_type: ModelType
base_type: BaseModelType base_type: BaseModelType
path: Path = None path: Optional[Path] = None
repo_id: str = None repo_id: Optional[str] = None
description: str = "" description: str = ""
installed: bool = False installed: bool = False
recommended: bool = False recommended: bool = False

View File

@ -276,7 +276,7 @@ class ModelInfo:
hash: str hash: str
location: Union[Path, str] location: Union[Path, str]
precision: torch.dtype precision: torch.dtype
_cache: ModelCache = None _cache: Optional[ModelCache] = None
def __enter__(self): def __enter__(self):
return self.context.__enter__() return self.context.__enter__()