diff --git a/src/debugpy/common/json.py b/src/debugpy/common/json.py index 3502b09f..7e1b317b 100644 --- a/src/debugpy/common/json.py +++ b/src/debugpy/common/json.py @@ -7,9 +7,8 @@ import builtins import json -import operator -import string import numbers +import operator JsonDecoder = json.JSONDecoder @@ -108,16 +107,14 @@ def of_type(*classinfo, **kwargs): def validate(value): if (optional and value == ()) or isinstance(value, classinfo): return value - elif ( - isinstance(value, str) - and all(x in string.digits + "." for x in value) - and any(issubclass(x, numbers.Number) for x in classinfo) - ): - try: - return int(value) - except ValueError: - return float(value) else: + for one_info in classinfo: + if issubclass(one_info, numbers.Number): + try: + return one_info(value) + except ValueError: + pass + if not optional and value == (): raise ValueError("must be specified") raise TypeError("must be " + " or ".join(t.__name__ for t in classinfo))