HealthITAU / pyconnectwise

A library for simplifying interactions with the ConnectWise Manage API in Python
https://healthit.com.au
GNU General Public License v3.0
42 stars 7 forks source link

:sparkles: Type improvements update (0.5.0) #16

Closed Yoshify closed 9 months ago

Yoshify commented 9 months ago

The goal of this PR is to enhance type checking (and thus DX) in the library. Efforts have been made to also improve testability.

This will be a mildly breaking change depending on how people have laid out their params as these will now be type checked, so a major version bump will be required (0.5.0)

Key features of this update are:

  1. Params are now TypedDicts, which gives us type hinting and control over them. This means when you write out your params, you'll be given autocomplete options for conditions, orderBy, columns, etc (key only).
  2. Patch data is now enforced to be a list of Patch TypedDicts, which gives us type hinting and control over what goes inside them. For example, the 'op' key of a patch is now enforced to be 'add', 'replace' or 'remove'. This solves #15
  3. Endpoint HTTP methods have been abstracted to interfaces that they inherit from as needed. This makes testing much easier - and allows us to make explicit type enforcements as needed (for example, PaginatedResponse now must receive an IPaginateable).

Update has been tested extensively on our local instance and shouldn't have any regressions.

Yoshify commented 9 months ago

Side note to this PR - documentation is again out of date in docstrings. These will be getting another pass in a future update.