Skip to content

Commit

Permalink
Fix typing for GraphQL types attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ogenstad committed Sep 20, 2024
1 parent d0b7c51 commit 9add185
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/infrahub/core/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion backend/infrahub/graphql/types/attribute.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9add185

Please sign in to comment.