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

Use isinstance instead of boolean checks #36

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

charmoniumQ
Copy link
Contributor

Instead of request.requiresOnlineAPIAccess(), it's better to do isinstance(request, OnlineRoutineRequest) for three reasons:

  1. It helps you know that the request will have the attributes that OnlineRoutineRequests should have, e.g. getCredentials().
  2. It helps static type-checkers know the type of that variable. A future PR will implement Mypy type annotations for this codebase, and the isinstance checks tell Mypy that the type of that variable, allowing the code to typecheck successfully.
  3. It results less code (this commit is net negative LoC)

This PR is based on #31, #32, #34, and #35.

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.

1 participant