ottowayi / pycomm3

A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.
MIT License
406 stars 88 forks source link

[FEATURE] - deprecate read/write in favor of read_one/read_many/write_one/write_many #307

Open Josh-2 opened 1 year ago

Josh-2 commented 1 year ago

Type of Feature Request

Feature Description I was planning on proposing overloads (see below) for read and write but:

    @overload
    def read(self, __tag: str) -> Tag: ...

    @overload
    def read(self, __tag: str, __tag_: str, *__tags: str) -> List[Tag]: ...

    @with_forward_open
    def read(self, *tags: str) -> ReadWriteReturnType:

    ...

    @overload
    def write(self, __tag: str, __value: TagValueType) -> Tag: ...

    @overload
    def write(self, __tags_values: Tuple[str, TagValueType]) -> Tag: ...

    @overload
    def write(self, __tags_value: Tuple[str, TagValueType],
        __tags_value_: Tuple[str, TagValueType],
        *__tags_values: Tuple[str, TagValueType]) -> List[Tag]: ...

    @with_forward_open
    def write(
        self, *tags_values: Union[str, TagValueType, Tuple[str, TagValueType]]
    ) -> ReadWriteReturnType:

Instead I am proposing the following changes.

Proposed Changes

I believe this change improves the readability and predictability of the code by making it clear what type each method will return.

@ottowayi I realize this is a very opinionated proposal. Is this something that you're interested in?