test-fullautomation / python-jsonpreprocessor

A preprocessor for json files
Apache License 2.0
2 stars 2 forks source link

Error message (8) #255

Open HolQue opened 1 month ago

HolQue commented 1 month ago

With the last line of following code a new parameter name shall be created - based on a dictionary:

"keyParam" : "A",
"dictParam" : {"A" : 1},
"listParam" : ["A", "B"],
"${dictParam}" : 5

A dictionary cannot be used as name. Therefore I get the following error message:

Error: 'Found expression '${dictParam}' with at least one parameter of composite data type ('${dictParam}' is of type <class 'dict'>).
Because of this expression is the name of a parameter, only simple data types are allowed to be substituted inside.'!

This is correct.

Now I want to overwrite a key value of this dictionary. But by mistake I use the listParam instead of the keyParam.

${dictParam}[${listParam}] : 5

A list cannot be used as key name. Therefore also in this case an error message is expected. The error is:

Error: 'Found expression '${listParam}' with at least one parameter of composite data type ('${listParam}' is of type <class 'list'>).
Because of this expression is the name of a parameter, only simple data types are allowed to be substituted inside.'!

This is not completely wrong, but misleading. It's the same error message, but a complete different use case.

The error message belongs to a dollar operator expression, encapsulated in quotes, that would - if placed on the left hand side of the colon - create a new parameter name dynamically.

This error does not fit to the second code example. In second case I suggest to use the original error message from Python interpreter:

TypeError: unhashable type: 'list'

Or you provide an own interpretation, something like:

Dictionary keys are expected to be of type str or int.