From bcac6c428777ae8775de7ce3793ff18ef8dd231f Mon Sep 17 00:00:00 2001 From: Raffson Date: Sun, 9 Oct 2022 15:28:36 +0200 Subject: [PATCH] Skip & Log properties with 'None' as default value --- game/dcs/unitproperty.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/game/dcs/unitproperty.py b/game/dcs/unitproperty.py index d8702545..4a70158b 100644 --- a/game/dcs/unitproperty.py +++ b/game/dcs/unitproperty.py @@ -1,6 +1,7 @@ from __future__ import annotations import inspect +import logging from collections.abc import Iterator from dataclasses import dataclass from typing import Any, Generic, Type, TypeVar @@ -33,6 +34,11 @@ class UnitProperty(Generic[ValueT]): for name, attr in inspect.getmembers(props, inspect.isclass): if name.startswith("__"): continue + attr_values = getattr(attr, "Values", None) + if attr_values is None and unit_type.property_defaults[name] is None: + msg = f"Skipping property '{name}' for '{unit_type.id}': default value is None." + logging.warning(msg) + continue yield cls.property_from(attr, unit_type.property_defaults[name]) @classmethod