feat: add default inference behavior for basic types #13

Closed
gremond wants to merge 10 commits from basic_types_inference into develop
Member

feature only available for the basic types, that is for these types:

{str: "string", int: "number", bool: "boolean", float: "float"}

feature only available for the basic types, that is for these types: ```{str: "string", int: "number", bool: "boolean", float: "float"}```
gremond added 1 commit 2024-04-09 11:59:32 +02:00
egarette reviewed 2024-04-09 12:09:51 +02:00
@ -65,0 +66,4 @@
types = {str: "string", int: "number", bool: "boolean", float: "float"}
# variable's type inference with a default value with a basic type
if multi is False and variable.type == "string" and type(variable.default) != str:
Owner

This line is not correct to me.

Example:

my_var:
  type: string
  default: 3

is an invalid dictionary.

This line is not correct to me. Example: ``` my_var: type: string default: 3 ``` is an invalid dictionary.
gremond added 1 commit 2024-04-30 10:38:43 +02:00
preparation of moving the calculation of the variable's type
from the class Variable to a dynamic calculation in the annotations
(mainly in `annotator/value.py`)
gremond added 1 commit 2024-04-30 15:20:44 +02:00
egarette reviewed 2024-05-03 08:02:29 +02:00
@ -65,0 +68,4 @@
# - version: 1.0, the default value is of type "string" by default
if variable.type is None:
variable.type = "string"
elif variable.version == "1.1":
Owner

Not only 1.1, should be "else:"

Not only 1.1, should be "else:"
egarette reviewed 2024-05-03 08:05:41 +02:00
@ -65,0 +75,4 @@
variable.type = basic_types[type(variable.default)]
else:
# XXX FIXME strange. weird. not good
variable.type = "string"
Owner

If variable.type is "number" it will override by "string".

Multi value should be supported too (raise if type are different in this case).

If variable.type is "number" it will override by "string". Multi value should be supported too (raise if type are different in this case).
gremond added 1 commit 2024-05-21 15:40:25 +02:00
gremond added 1 commit 2024-06-04 12:05:21 +02:00
gremond added 1 commit 2024-06-04 16:22:14 +02:00
in case the "multi" attribute is not set, infers the type
gremond added 1 commit 2024-06-18 16:02:41 +02:00
gremond added 1 commit 2024-06-18 17:25:14 +02:00
gremond added 1 commit 2024-06-18 18:01:52 +02:00
gnunux added 1 commit 2024-06-19 15:29:50 +02:00
gremond changed title from WIP: feat: add default inference behavior for basic types to feat: add default inference behavior for basic types 2024-07-01 10:16:42 +02:00
gremond closed this pull request 2024-07-01 10:17:01 +02:00
gremond deleted branch basic_types_inference 2024-07-01 10:19:42 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: stove/rougail#13
No description provided.