pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.25k stars 921 forks source link

Use a TypedDict for simulator type hints #2085

Closed alexrudd2 closed 5 months ago

alexrudd2 commented 7 months ago

See https://github.com/pymodbus-dev/pymodbus/pull/2084. This is mostly a demonstration of how TypedDict could be used.

However, it made me question whether we should remove the Label abstraction.
What is the purpose for cases where the label is identical to the key? e.g. Label.value == 'value'.

Would it not be easier to only use it when they differ e.g. Label.co_size == 'co size'?

Could the labels be generated programmatically? (It looks like replacing a space with an underscore and remove type_ prefix would work in all cases).

janiversen commented 7 months ago

The reason for

Label.value = 'value'

is so the program can use Label.value, while the configuration json uses 'value', that is needed unless you come up with an alternative.

janiversen commented 7 months ago

The label can possible be done programmatically....however Label is an enum, and should stay that way.

Apart from that, the whole simulator configuration is way to complex, and it is on my list to make a new version.

janiversen commented 7 months ago

But as usual I am open to suggestions....

janiversen commented 7 months ago

Just request review when you think it is ready.

alexrudd2 commented 7 months ago

I just tried the simulator for the first time today, so hopefully I have a better understanding soon.

github-actions[bot] commented 5 months ago

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] commented 5 months ago

This PR was closed because it has been stalled for 10 days with no activity.