Skip to content

Add Type Hints to Improve Codebase Readability and Maintainability #1296

Open

Description

@Dr-Blank

What is your feature request?

I suggest adding type hints throughout the codebase to enhance its clarity and maintainability. Type hints provide several benefits:

  1. Readability: Type hints serve as documentation, making it easier for developers to understand the code and its intended usage.

  2. Early Detection of Errors: Type hints enable static type checking tools to catch potential issues at compile-time, reducing the likelihood of runtime errors.

  3. Tooling Support: Type hints improve IDE support, enabling better autocompletion, refactoring, and overall developer experience.

  4. Improved Collaboration: With type hints, developers can more easily collaborate on the project, as the code becomes more self-explanatory.

  5. Reduced Debugging Time: Type hints can help identify and resolve issues more quickly during the development process.

  6. Enhanced Code Quality: The addition of type hints promotes better coding practices and can lead to a more robust and maintainable codebase.

Are there any workarounds?

No response

Code Snippets

No response

Additional Context

If this proposal resonates with the community, I am willing to contribute to the implementation of type hints. I believe this enhancement will significantly benefit both current and future contributors.

Thank you for considering this improvement.

Activity

  1. Dr-Blank commented on Jan 16, 2024

    @Dr-Blank
    ContributorAuthor

    @JonnyWong16

    can attr key be None in any case? if so, for which cases and is key=None useful? as I believe all media items must have a key, hence key can not be None for all of those cases. correct me if I am wrong, but if that is the case, a base class for those items should make it key compulsory and for objects that have key as None should not inherit from this class with attr key in it.

    I am saying this as it will save a ton of if self.key is None checks in methods which actually use key.

    other option is to make it default to an empty string instead of None but that is risky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions