Proof of concept: reject invalid inherited methods #783
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
AuthClient is gaining a number of methods related to authenticated usages which require token auth. These methods will not be functional for NativeAppAuthClient and ConfidentialAppAuthClient.
Because it is difficult to make a backwards-compatible change which alters the inheritance relationship for AuthClient and the other client types, it may be worth exploring other methods for ensuring that these "never functional" methods provide clear user-feedback that they do not work.
Possibly -- arguably -- the inheritance relationship that produces
isinstance(NativeAppAuthClient("foo"), AuthClient)
could be considered outside of our public interfaces. That would leave us free to make all three client types inherit from a new base (BaseAuthClient
?) and attach the new methods only toAuthClient
. However, if we consider this part of the public interface, then an alternative solution is needed.This changeset introduces a class decorator
(
globus_sdk.utils.replace_notimplemented_methods
) which replaces named inherited methods with stubs which raiseNotImplementedError
with a generated message. The result is a slightly awkward trace, but a clear error on bad usage:If the methodology is considered sound, we can decorate NativeAppAuthClient and ConfidentialAppAuthClient with known-unsupported method names for SDK v3.x and plan to change the inheritance structure in v4.0 . A full enumeration of supported and unsupported usages would be needed to make this feasible, along with a detailed changelog enumerating the now NotImplementedError-raising methods.
📚 Documentation preview 📚: https://globus-sdk-python--783.org.readthedocs.build/en/783/