11import logging
22from functools import cached_property
3- from typing import Annotated , Any , Final , Self
3+ from typing import Annotated , Any , Final
44
55from aiohttp import web
66from common_library .basic_types import DEFAULT_FACTORY
@@ -402,7 +402,7 @@ def _build_vcs_release_url_if_unset(cls, values):
402402
403403 @model_validator (mode = "before" )
404404 @classmethod
405- def _enable_only_if_dev_features_allowed (cls , data : Any ) -> Self :
405+ def _enable_only_if_dev_features_allowed (cls , data : Any ) -> Any :
406406 """Force disables plugins marked 'under development' when WEBSERVER_DEV_FEATURES_ENABLED=False"""
407407
408408 dev_features_allowed = TypeAdapter (bool ).validate_python (
@@ -411,17 +411,24 @@ def _enable_only_if_dev_features_allowed(cls, data: Any) -> Self:
411411
412412 if not dev_features_allowed :
413413 for field_name , field in cls .model_fields .items ():
414- if field .json_schema_extra and field .json_schema_extra .get (
415- _X_DEV_FEATURE_FLAG
416- ):
417- _logger .warning (
418- "'%s' is still under development and will be forcibly disabled [WEBSERVER_DEV_FEATURES_ENABLED=%s]." ,
419- field_name ,
420- dev_features_allowed ,
421- )
422- data [field_name ] = (
423- None if field_name and is_nullable (field ) else False
424- )
414+ if field .json_schema_extra :
415+ json_schema : dict [str , Any ] = {}
416+ if callable (field .json_schema_extra ):
417+ field .json_schema_extra (json_schema )
418+ else :
419+ json_schema = field .json_schema_extra
420+
421+ assert isinstance (json_schema , dict ) # nosec
422+
423+ if json_schema .get (_X_DEV_FEATURE_FLAG ):
424+ _logger .warning (
425+ "'%s' is still under development and will be forcibly disabled [WEBSERVER_DEV_FEATURES_ENABLED=%s]." ,
426+ field_name ,
427+ dev_features_allowed ,
428+ )
429+ data [field_name ] = (
430+ None if field_name and is_nullable (field ) else False
431+ )
425432
426433 return data
427434
0 commit comments