fix: Fix the errors showing up after setting up mypy type checker. (#74)

This commit is contained in:
Anubhav Dhawan
2024-11-15 03:34:24 +05:30
committed by GitHub
parent 751228a774
commit 522bbefa7b
2 changed files with 16 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional, Type
from typing import Any, Optional, Type, cast
import yaml
from aiohttp import ClientSession
@@ -51,10 +51,13 @@ def _schema_to_model(model_name: str, schema: list[ParameterSchema]) -> Type[Bas
"""
field_definitions = {}
for field in schema:
field_definitions[field.name] = (
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
field_definitions[field.name] = cast(
Any,
(
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
),
)
return create_model(model_name, **field_definitions)

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional, Type
from typing import Any, Optional, Type, cast
import yaml
from aiohttp import ClientSession
@@ -51,10 +51,13 @@ def _schema_to_model(model_name: str, schema: list[ParameterSchema]) -> Type[Bas
"""
field_definitions = {}
for field in schema:
field_definitions[field.name] = (
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
field_definitions[field.name] = cast(
Any,
(
# TODO: Remove the hardcoded optional types once optional fields are supported by Toolbox.
Optional[_parse_type(field.type)],
Field(description=field.description),
),
)
return create_model(model_name, **field_definitions)