Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/infrahub/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import uuid
from datetime import UTC, datetime, timedelta
from enum import Enum
from enum import StrEnum
from typing import TYPE_CHECKING, Any

import bcrypt
Expand Down Expand Up @@ -35,7 +35,7 @@
log = get_logger()


class AuthType(str, Enum):
class AuthType(StrEnum):
NONE = "none"
JWT = "jwt"
API = "api"
Expand Down
6 changes: 3 additions & 3 deletions backend/infrahub/cli/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections import defaultdict
from csv import DictReader, DictWriter
from datetime import UTC, datetime
from enum import Enum
from enum import StrEnum
from pathlib import Path
from typing import TYPE_CHECKING, Any, Sequence

Expand Down Expand Up @@ -75,13 +75,13 @@ def get_timestamp_string() -> str:
PERMISSIONS_AVAILABLE = ["read", "write", "admin"]


class ConstraintAction(str, Enum):
class ConstraintAction(StrEnum):
SHOW = "show"
ADD = "add"
DROP = "drop"


class IndexAction(str, Enum):
class IndexAction(StrEnum):
SHOW = "show"
ADD = "add"
DROP = "drop"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from enum import Enum
from enum import StrEnum
from typing import Any

from rich import print as rprint
Expand All @@ -11,7 +11,7 @@
from infrahub.database import InfrahubDatabase


class SchemaFieldType(str, Enum):
class SchemaFieldType(StrEnum):
ATTRIBUTE = "attribute"
RELATIONSHIP = "relationship"

Expand Down
28 changes: 14 additions & 14 deletions backend/infrahub/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import os
import ssl
import sys
import tomllib
from dataclasses import dataclass
from enum import Enum
from enum import StrEnum
from pathlib import Path
from typing import TYPE_CHECKING, Any

import tomllib
from infrahub_sdk.utils import generate_uuid
from pydantic import (
AliasChoices,
Expand Down Expand Up @@ -48,28 +48,28 @@ def default_append_git_suffix_domains() -> list[str]:
return ["github.com", "gitlab.com"]


class EnterpriseFeatures(str, Enum):
class EnterpriseFeatures(StrEnum):
PROPOSED_CHANGE_REQUIRE_APPROVAL = "proposed_change_require_approval"
REVOKE_PROPOSED_CHANGE_APPROVALS = "revoke_proposed_change_approvals"


class UserInfoMethod(str, Enum):
class UserInfoMethod(StrEnum):
POST = "post"
GET = "get"


class SSOProtocol(str, Enum):
class SSOProtocol(StrEnum):
OAUTH2 = "oauth2"
OIDC = "oidc"


class Oauth2Provider(str, Enum):
class Oauth2Provider(StrEnum):
GOOGLE = "google"
PROVIDER1 = "provider1"
PROVIDER2 = "provider2"


class OIDCProvider(str, Enum):
class OIDCProvider(StrEnum):
GOOGLE = "google"
PROVIDER1 = "provider1"
PROVIDER2 = "provider2"
Expand Down Expand Up @@ -98,25 +98,25 @@ def token_path(self) -> str:
return f"/api/{self.protocol.value}/{self.name}/token"


class StorageDriver(str, Enum):
class StorageDriver(StrEnum):
FileSystemStorage = "local"
InfrahubS3ObjectStorage = "s3"


class TraceExporterType(str, Enum):
class TraceExporterType(StrEnum):
CONSOLE = "console"
OTLP = "otlp"
# JAEGER = "jaeger"
# ZIPKIN = "zipkin"


class TraceTransportProtocol(str, Enum):
class TraceTransportProtocol(StrEnum):
GRPC = "grpc"
HTTP_PROTOBUF = "http/protobuf"
# HTTP_JSON = "http/json"


class BrokerDriver(str, Enum):
class BrokerDriver(StrEnum):
RabbitMQ = "rabbitmq"
NATS = "nats"

Expand All @@ -137,7 +137,7 @@ def driver_class_name(self) -> str:
return "RabbitMQMessageBus"


class CacheDriver(str, Enum):
class CacheDriver(StrEnum):
Redis = "redis"
NATS = "nats"

Expand All @@ -158,12 +158,12 @@ def driver_class_name(self) -> str:
return "RedisCache"


class WorkflowDriver(str, Enum):
class WorkflowDriver(StrEnum):
LOCAL = "local"
WORKER = "worker"


class ExtraLogLevel(str, Enum):
class ExtraLogLevel(StrEnum):
CRITICAL = "CRITICAL"
ERROR = "ERROR"
WARNING = "WARNING"
Expand Down
10 changes: 5 additions & 5 deletions backend/infrahub/constants/database.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from enum import Enum
from enum import StrEnum


class DatabaseType(str, Enum):
class DatabaseType(StrEnum):
NEO4J = "neo4j"
MEMGRAPH = "memgraph"


class Neo4jRuntime(str, Enum):
class Neo4jRuntime(StrEnum):
DEFAULT = "default"
INTERPRETED = "interpreted"
SLOTTED = "slotted"
Expand All @@ -15,13 +15,13 @@ class Neo4jRuntime(str, Enum):
UNDEFINED = "undefined"


class IndexType(str, Enum):
class IndexType(StrEnum):
TEXT = "text"
RANGE = "range"
LOOKUP = "lookup"
NOT_APPLICABLE = "not_applicable"


class EntityType(str, Enum):
class EntityType(StrEnum):
NODE = "node"
RELATIONSHIP = "relationship"
4 changes: 2 additions & 2 deletions backend/infrahub/core/diff/model/diff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from enum import Enum
from enum import Enum, StrEnum
from typing import Any

from pydantic import BaseModel, ConfigDict, Field
Expand Down Expand Up @@ -271,7 +271,7 @@ def label(self) -> str:
return self.value


class DiffElementType(str, Enum):
class DiffElementType(StrEnum):
ATTRIBUTE = "Attribute"
RELATIONSHIP_ONE = "RelationshipOne"
RELATIONSHIP_MANY = "RelationshipMany"
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/graph/constraints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from enum import Enum
from enum import StrEnum
from typing import TYPE_CHECKING, ForwardRef, Optional, Union, get_origin

from pydantic import BaseModel
Expand All @@ -12,7 +12,7 @@
from infrahub.database import InfrahubDatabase


class GraphPropertyType(str, Enum):
class GraphPropertyType(StrEnum):
BOOLEAN = "BOOLEAN"
STRING = "STRING"
INTEGER = "INTEGER"
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def identify_node_class(node: NodeToProcess) -> type[Node]:
return Node


def get_schema(
def get_schema[SchemaProtocol](
db: InfrahubDatabase,
branch: Branch,
node_schema: type[SchemaProtocol] | MainSchemaTypes | str,
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/node/node_property_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import abstractmethod
from enum import Enum
from typing import TYPE_CHECKING, Any, Generic, TypeVar
from typing import TYPE_CHECKING, Any, TypeVar

from infrahub_sdk.template import Jinja2Template

Expand All @@ -21,7 +21,7 @@
T = TypeVar("T")


class NodePropertyAttribute(Generic[T]):
class NodePropertyAttribute[T]:
"""A node property attribute is a construct that seats between a property and an attribute.

View it as a property, set at the node level but stored in the database as an attribute. It usually is something computed from other components of
Expand Down
6 changes: 3 additions & 3 deletions backend/infrahub/core/schema/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import uuid
from typing import Any, TypeAlias
from typing import Any

from infrahub_sdk.utils import deep_merge_dict
from pydantic import BaseModel, ConfigDict, Field
Expand All @@ -21,8 +21,8 @@
from .relationship_schema import RelationshipSchema
from .template_schema import TemplateSchema

NonGenericSchemaTypes: TypeAlias = NodeSchema | ProfileSchema | TemplateSchema
MainSchemaTypes: TypeAlias = NonGenericSchemaTypes | GenericSchema
NonGenericSchemaTypes = NodeSchema | ProfileSchema | TemplateSchema
MainSchemaTypes = NonGenericSchemaTypes | GenericSchema


# -----------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/validators/enum.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum
from enum import StrEnum


class ConstraintIdentifier(str, Enum):
class ConstraintIdentifier(StrEnum):
ATTRIBUTE_PARAMETERS_REGEX_UPDATE = "attribute.parameters.regex.update"
ATTRIBUTE_PARAMETERS_MIN_LENGTH_UPDATE = "attribute.parameters.min_length.update"
ATTRIBUTE_PARAMETERS_MAX_LENGTH_UPDATE = "attribute.parameters.max_length.update"
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/dependencies/interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Generic, TypeVar
from typing import TypeVar

from infrahub.core.branch import Branch
from infrahub.database import InfrahubDatabase
Expand All @@ -14,7 +14,7 @@ class DependencyBuilderContext:
branch: Branch


class DependencyBuilder(ABC, Generic[T]):
class DependencyBuilder[T](ABC):
@classmethod
@abstractmethod
def build(cls, context: DependencyBuilderContext) -> T: ...
4 changes: 2 additions & 2 deletions backend/infrahub/events/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum
from enum import StrEnum

EVENT_NAMESPACE = "infrahub"


class EventSortOrder(str, Enum):
class EventSortOrder(StrEnum):
ASC = "asc"
DESC = "desc"
8 changes: 4 additions & 4 deletions backend/infrahub/graphql/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import deque
from copy import deepcopy
from dataclasses import dataclass, field
from enum import Enum
from enum import StrEnum
from functools import cached_property
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -49,13 +49,13 @@
from infrahub.core.schema.schema_branch import SchemaBranch


class MutateAction(str, Enum):
class MutateAction(StrEnum):
CREATE = "create"
DELETE = "delete"
UPDATE = "update"


class ContextType(str, Enum):
class ContextType(StrEnum):
EDGE = "edge"
NODE = "node"
DIRECT = "direct"
Expand All @@ -80,7 +80,7 @@ def from_relationship_cardinality(cls, cardinality: RelationshipCardinality) ->
return cls.NODE


class GraphQLOperation(str, Enum):
class GraphQLOperation(StrEnum):
QUERY = "query"
MUTATION = "mutation"
SUBSCRIPTION = "subscription"
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/graphql/mutations/relationship.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from enum import Enum
from enum import StrEnum
from typing import TYPE_CHECKING, Self

from graphene import Boolean, InputField, InputObjectType, List, Mutation, String
Expand Down Expand Up @@ -48,7 +48,7 @@
RELATIONSHIP_PEERS_TO_IGNORE = [InfrahubKind.NODE]


class GroupUpdateType(str, Enum):
class GroupUpdateType(StrEnum):
NONE = "none"
MEMBERS = "members"
MEMBER_OF_GROUPS = "member_of_groups"
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/patch/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum
from enum import StrEnum


class PatchPlanFilename(str, Enum):
class PatchPlanFilename(StrEnum):
VERTICES_TO_ADD = "vertices_to_add.json"
VERTICES_TO_UPDATE = "vertices_to_update.json"
VERTICES_TO_DELETE = "vertices_to_delete.json"
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/telemetry/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from enum import StrEnum

TELEMETRY_KIND: str = "community"
TELEMETRY_VERSION: str = "20250318"


class InfrahubType(str, Enum):
class InfrahubType(StrEnum):
COMMUNITY = "community"
ENTERPRISE = "enterprise"
Loading
Loading