Autogenerated code is too sensitive to small changes

This commit is contained in:
doctorpangloss 2024-06-19 09:42:14 -07:00
parent 6015c4132f
commit 68f410b8da
5 changed files with 62 additions and 32 deletions

View File

@ -878,3 +878,13 @@ init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
# Disable specific messages for specific files
[file:paths/view/get/query_parameters.py]
disable=duplicate-bases
[file:paths/view/get/parameters/parameter_1/schema.py]
disable=no-self-argument
[file:schemas/schema.py]
disable=no-self-argument,bad-super-call

View File

@ -13,22 +13,19 @@ from comfy.api.shared_imports.schema_imports import * # pyright: ignore [report
class SchemaEnums:
@classmethod
def output(cls) -> typing.Literal["output"]:
@schemas.classproperty
def OUTPUT(cls) -> typing.Literal["output"]:
return Schema.validate("output")
@classmethod
def input(cls) -> typing.Literal["input"]:
@schemas.classproperty
def INPUT(cls) -> typing.Literal["input"]:
return Schema.validate("input")
@classmethod
def temp(cls) -> typing.Literal["temp"]:
@schemas.classproperty
def TEMP(cls) -> typing.Literal["temp"]:
return Schema.validate("temp")
OUTPUT = property(output)
INPUT = property(input)
TEMP = property(temp)
@dataclasses.dataclass(frozen=True)
class Schema(

View File

@ -15,19 +15,32 @@ AdditionalProperties: typing_extensions.TypeAlias = schemas.NotAnyTypeSchema
from comfy.api.paths.view.get.parameters.parameter_0 import schema
from comfy.api.paths.view.get.parameters.parameter_1 import schema as schema_3
from comfy.api.paths.view.get.parameters.parameter_2 import schema as schema_2
class Properties(typing.TypedDict):
filename: typing.Type[schema.Schema]
subfolder: typing.Type[schema_2.Schema]
type: typing.Type[schema_3.Schema]
class QueryParametersRequiredDictInput(typing.TypedDict):
filename: str
class QueryParametersOptionalDictInput(typing.TypedDict, total=False):
subfolder: str
type: typing.Literal["output", "input", "temp"]
Properties = typing.TypedDict(
'Properties',
{
"filename": typing.Type[schema.Schema],
"subfolder": typing.Type[schema_2.Schema],
"type": typing.Type[schema_3.Schema],
}
)
QueryParametersRequiredDictInput = typing.TypedDict(
'QueryParametersRequiredDictInput',
{
"filename": str,
}
)
QueryParametersOptionalDictInput = typing.TypedDict(
'QueryParametersOptionalDictInput',
{
"subfolder": str,
"type": typing.Literal[
"output",
"input",
"temp"
],
},
total=False
)
class QueryParametersDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):

View File

@ -14,6 +14,7 @@ import typing_extensions
from .schema import (
get_class,
none_type_,
classproperty,
Bool,
FileIO,
Schema,
@ -103,6 +104,7 @@ def raise_if_key_known(
__all__ = [
'get_class',
'none_type_',
'classproperty',
'Bool',
'FileIO',
'Schema',

View File

@ -96,6 +96,17 @@ class FileIO(io.FileIO):
pass
class classproperty(typing.Generic[W]):
def __init__(self, method: typing.Callable[..., W]):
self.__method = method
functools.update_wrapper(self, method) # type: ignore
def __get__(self, obj, cls=None) -> W:
if cls is None:
cls = type(obj)
return self.__method(cls)
class Bool:
_instances: typing.Dict[typing.Tuple[type, bool], Bool] = {}
"""
@ -128,16 +139,13 @@ class Bool:
return f'<Bool: True>'
return f'<Bool: False>'
@classmethod
def true(cls):
@classproperty
def TRUE(cls):
return cls(True) # type: ignore
@classmethod
def false(cls):
@classproperty
def FALSE(cls):
return cls(False) # type: ignore
TRUE = property(true)
FALSE = property(false)
@functools.lru_cache()
def __bool__(self) -> bool:
@ -395,11 +403,11 @@ class Schema(typing.Generic[T, U], validation.SchemaValidator, metaclass=Singlet
return used_arg
output_cls = type_to_output_cls[arg_type]
if arg_type is tuple:
inst = tuple.__new__(output_cls, used_arg) # type: ignore
inst = super(output_cls, output_cls).__new__(output_cls, used_arg) # type: ignore
inst = typing.cast(U, inst)
return inst
assert issubclass(output_cls, validation.immutabledict)
inst = validation.immutabledict.__new__(output_cls, used_arg) # type: ignore
inst = super(output_cls, output_cls).__new__(output_cls, used_arg) # type: ignore
inst = typing.cast(T, inst)
return inst