pkkid / python-plexapi

Python bindings for the Plex API.
BSD 3-Clause "New" or "Revised" License
1.13k stars 196 forks source link

Add Type Hints to Improve Codebase Readability and Maintainability #1296

Open Dr-Blank opened 10 months ago

Dr-Blank commented 10 months ago

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.

Dr-Blank commented 8 months ago

@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.