Skip to content

Commit 6b08777

Browse files
Lotramryneeverett
authored andcommitted
Add comment about _MissingServiceDiscriminator
1 parent 1cca9fc commit 6b08777

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

bugwarrior/config/validation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import sys
3-
from typing import TYPE_CHECKING, Annotated, Any, Literal, NoReturn, Union
3+
from typing import Annotated, Any, Literal, NoReturn, Union
44

55
from pydantic import Field, TypeAdapter, ValidationError
66
from pydantic_core import ErrorDetails
@@ -14,10 +14,6 @@
1414
get_service,
1515
)
1616

17-
if TYPE_CHECKING:
18-
ServiceConfigType = ServiceConfig
19-
20-
2117
log = logging.getLogger(__name__)
2218

2319

@@ -124,10 +120,15 @@ def raise_validation_error(
124120

125121

126122
class _MissingServiceDiscriminator(BaseConfig):
127-
"""Placeholder schema used to report missing service discriminators."""
123+
"""
124+
Placeholder schema used to report missing service discriminators.
125+
126+
We need 'service' to be a Literal, so we can use it in a discriminator Field.
127+
Regular ServiceConfig base class defines it as a plain str, which does not work
128+
with discriminators.
129+
"""
128130

129131
service: Literal["__bugwarrior_missing_service__"]
130-
target: str
131132

132133

133134
def get_service_config_union_type(services: list[dict[str, Any]]) -> Any:
@@ -149,7 +150,6 @@ def get_service_config_union_type(services: list[dict[str, Any]]) -> Any:
149150
)
150151
or _MissingServiceDiscriminator
151152
)
152-
153153
return Annotated[Union[service_config_classes], Field(discriminator="service")]
154154

155155

0 commit comments

Comments
 (0)