Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the prevalence of None as a return value #178

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

kurtmckee
Copy link
Member

Supersedes #152

Changes

  • AuthState.introspect_token() will no longer return None if the token is not active.

    Instead, a new exception, InactiveTokenError, will be raised.
    InactiveTokenError is a subclass of ValueError.

    Existing code that calls AuthState.introspect_token() no longer returns None, either,
    but will instead raise ValueError, a subclass of ValueError,
    or a globus_sdk.GlobusAPIError:

    • AuthState.get_authorizer_for_scope
    • AuthState.effective_identity
    • AuthState.identities

Copy link
Member

@sirosen sirosen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor tweaks to apply, but I want to hold off on approving and merging until after we do a release.

Although we're now fairly certain that this won't cause impactful changes for known AP Tools users, I think including it in the next release would not match some of the messages I've sent to other teams about what to expect out of our next two releases.

``InactiveTokenError`` is a subclass of ``ValueError``.

Existing code that calls ``AuthState.introspect_token()`` no longer returns ``None``, either,
but will instead raise ``ValueError``, a subclass of ``ValueError``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! This is why they pay me the looks at his bank balance ... does that count as "big bucks"? 😛

Suggested change
but will instead raise ``ValueError``, a subclass of ``ValueError``,
but will instead raise ``ValueError``,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InactiveTokenError and InvalidTokenScopesError are subclasses of ValueError...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but the text says that ValueError is a subclass of ValueError, unless I'm very confused. (And if I am, I'll count that as a request for a rephrase!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I see now. It's a list of options, of length 3,

  • ValueError
  • a subclass of ValueError
  • globus_sdk.GlobusAPIError

I thought it was a list of length 2,

  • ValueError, a subclass of ValueError
  • globus_sdk.GlobusAPIError

Can we scratch "a subclass of ValueError" from the list, but now on different grounds, which is that it's unnecessary to specify?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last alternate:

ValueError (or a subclass) or globus_sdk.GlobusAPIError

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My approval should speak for itself.

But since it doesn't seem to speak up, "yes!" and "w00t!" and other exclamations of joy. I now understand the text and it says everything you wanted it to say!

src/globus_action_provider_tools/authentication.py Outdated Show resolved Hide resolved
src/globus_action_provider_tools/authentication.py Outdated Show resolved Hide resolved
src/globus_action_provider_tools/authentication.py Outdated Show resolved Hide resolved
Co-authored-by: Stephen Rosen <1300022+sirosen@users.noreply.github.com>
@kurtmckee kurtmckee merged commit f25640e into main Oct 18, 2024
13 checks passed
@kurtmckee kurtmckee deleted the eliminate-none-return-values branch October 18, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants