xero-python icon indicating copy to clipboard operation
xero-python copied to clipboard

Missing Type Annotations/Stubs (.pyi files) for xero-python SDK

Open jevonearth opened this issue 9 months ago • 2 comments

Problem

The xero-python SDK lacks proper type annotations and stub files (.pyi), causing issues with static type checkers, IDE autocompletion, and making it difficult to use the SDK with modern Python development practices.

Impact

Without proper type hints:

  • IDE autocompletion fails to suggest available methods/properties
  • Static type checkers (mypy, pyright) report false errors
  • SDK method signatures are unclear (esp. OAuth2Token and OAuth2 classes)
  • Developers must use defensive programming with hasattr() checks

Value Proposition

Adding type stubs would:

  • Improve developer experience with better IDE integration
  • Reduce runtime errors by catching type-related issues early
  • Make API changes more visible and less breaking
  • Reduce need for defensive programming patterns

Related Issues

Would help resolve:

  • #72 (TypeError in update_token arguments)
  • #93 (Non-serializable objects from to_dict)
  • #55 (PDF return type ambiguity)
  • #68 (Refresh token validation issues)
  • #142 (Breaking changes due to param ordering)

Proposed Solution

Add proper type annotations to the SDK or provide separate stub files (.pyi) that define the public API interface with appropriate types.

jevonearth avatar Apr 04 '25 16:04 jevonearth