Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Josh-2
Copy link

@Josh-2 Josh-2 commented Nov 11, 2023

Type of Feature Request

  • missing feature
    • feature available in another library: please specify
  • change to API
  • enhancing a current feature
  • removal of a broken/unsupported/etc feature
  • other: please specify

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

  • they only help when the length of the arguments are known in advance.
  • they are complicated. They need to detect when two or more arguments are provided.
    @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

  • splitting the read and write methods into read_one, read_many, write_one, and write_many
  • deprecated read and write and update calls to use read_many and write_many while maintaining their existing functionality
  • updated documentation
  • updated tests
  • this should've been a separate issue... provide an option to raise errors instead of writing continuing to read / write tags.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant