Skip to content

Refactor function signatures to use kwargs #1141

Open
@asonnenschein

Description

@asonnenschein

Problem
A lot (most?) of the methods in the Python SDK use positional arguments in their signatures, which has proven to be prohibitive to maintaining feature parity between the SDK and Planet APIs when we need to add, remove, and/or change an argument from required to optional (or vice versa). For example, Subscriptions API and Orders API have a source type parameter that used to be a required parameter, but is now optional. Some SDK methods expect source type as a positional argument, sometimes in the first position. Making the source type argument in the SDK then becomes a breaking change, so we have to keep it and make it nullable which is an odd pattern. See #1107 for a real example of this issue.

Solution
Explore refactoring positional arguments in function signatures to keyword arguments, aka 'kwargs'. Python kwargs don't need to maintain order because their descriptor is the keyword. This means that moving forward we would be able to add, remove, change required parameters in the SDK to maintain feature parity with Planet APIs without introducing breaking changes to users.

A/C

  • Refactor all Planet API specific positional arguments in SDK methods to keyword arguments (e.g. source_type in Subscriptions API, feature_ref in Features API, etc).
  • Positional arguments that should never change (e.g. an HTTP request positional argument to a method that wraps an HTTP request) do not need to be converted to kwargs.
  • Update all tests that will be effected by this change.
  • Update docs.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions