@@ -372,7 +372,7 @@ def capital(self):
372372
373373
374374int_re = re .compile (
375- r"\b((int(eger)?)|size|length|max|min|num(ber)?)\b" , flags = re .IGNORECASE
375+ r"\b((int(eger)?)|size|length|max|min|( num(ber)?) )\b" , flags = re .IGNORECASE
376376)
377377str_re = re .compile (r"\bstr(ing)?\b" , flags = re .IGNORECASE )
378378float_re = re .compile (r"\b(float|decimal)\b" , flags = re .IGNORECASE )
@@ -385,8 +385,12 @@ def capital(self):
385385default_re = re .compile (
386386 r"default(?: value)?(?:[:=] ?| )([^ )\]]+)" , flags = re .IGNORECASE
387387)
388- float_re = re .compile (r"[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)" , flags = re .IGNORECASE )
389- int_re = re .compile (r"[+-]?([0-9]+[^.0-9])" , flags = re .IGNORECASE )
388+ #
389+ float_num_re = re .compile (
390+ r"[+-]?(([0-9]*\.[0-9]+)|((?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)))" ,
391+ flags = re .IGNORECASE
392+ )
393+ int_num_re = re .compile (r"([+-]?[0-9]+)" , flags = re .IGNORECASE )
390394
391395
392396def infer_type (string ) -> typing .Optional [cli_types .CliType ]:
@@ -417,7 +421,13 @@ def infer_type(string) -> typing.Optional[cli_types.CliType]:
417421 elif str_re .search (string ):
418422 return cli_types .CliString ()
419423 else :
420- return cli_types .CliString ()
424+ if float_num_re .search (string ):
425+ return cli_types .CliFloat ()
426+ elif int_num_re .search (string ):
427+ print ("int num" )
428+ return cli_types .CliInteger ()
429+ else :
430+ return cli_types .CliString ()
421431
422432
423433@yaml_object (yaml )
0 commit comments