From 9add185a777d5f74b724d71f179faf0bf49423ae Mon Sep 17 00:00:00 2001 From: Patrick Ogenstad Date: Fri, 20 Sep 2024 07:26:05 +0200 Subject: [PATCH] Fix typing for GraphQL types attributes --- backend/infrahub/core/registry.py | 2 +- backend/infrahub/graphql/types/attribute.py | 4 +++- pyproject.toml | 5 ----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/backend/infrahub/core/registry.py b/backend/infrahub/core/registry.py index c3969c074c..610a576bd9 100644 --- a/backend/infrahub/core/registry.py +++ b/backend/infrahub/core/registry.py @@ -35,7 +35,7 @@ class Registry: _default_branch: Optional[str] = None _default_ipnamespace: Optional[str] = None _schema: Optional[SchemaManager] = None - default_graphql_type: dict[str, InfrahubObject] = field(default_factory=dict) + default_graphql_type: dict[str, InfrahubObject | type[BaseAttribute]] = field(default_factory=dict) graphql_type: dict = field(default_factory=lambda: defaultdict(dict)) data_type: dict[str, type[InfrahubDataType]] = field(default_factory=dict) input_type: dict[str, Union[BaseAttributeCreate, BaseAttributeUpdate]] = field(default_factory=dict) diff --git a/backend/infrahub/graphql/types/attribute.py b/backend/infrahub/graphql/types/attribute.py index dcb0b4252d..3dfd2af491 100644 --- a/backend/infrahub/graphql/types/attribute.py +++ b/backend/infrahub/graphql/types/attribute.py @@ -1,5 +1,7 @@ from __future__ import annotations +from typing import Any + from graphene import BigInt, Boolean, DateTime, Field, InputObjectType, Int, List, ObjectType, String from graphene.types.generic import GenericScalar @@ -70,7 +72,7 @@ class BaseAttribute(ObjectType): is_from_profile = Field(Boolean) @classmethod - def __init_subclass__(cls, **kwargs): + def __init_subclass__(cls, **kwargs: dict[str, Any]) -> None: super().__init_subclass__(**kwargs) registry.default_graphql_type[cls.__name__] = cls diff --git a/pyproject.toml b/pyproject.toml index eff6ef414b..31947d12cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -329,11 +329,6 @@ ignore_errors = true module = "infrahub.graphql.subscription" ignore_errors = true - -[[tool.mypy.overrides]] -module = "infrahub.graphql.types.attribute" -ignore_errors = true - [[tool.mypy.overrides]] module = "infrahub.graphql.types.standard_node" ignore_errors = true