Skip to content

Conversation

@henrylamchan
Copy link
Contributor

@henrylamchan henrylamchan commented Jan 2, 2020

Overview

Initial package with SSO functionality

@henrylamchan henrylamchan force-pushed the 201912_sso branch 2 times, most recently from 2245c60 to 61c3bc4 Compare January 2, 2020 21:47

class SSO(object):
def __init__(self):
required_settings = ['api_key', 'project_id', ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: don't think you need the trailing comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I typically would prefer it for lists and dicts, habit. For multiline dicts and lists, diffs are cleaner. For lists, this also protects us from accidental implicit string concatenation as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool sounds good 👍

Copy link
Member

Choose a reason for hiding this comment

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

Is there a linter/formatter we can use for our Python stuff so style comments don't need to come up in code reviews?

We use Rubocop for Ruby, which enforces and autofixes coding style. And on the Typescript side, we're using Prettier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be interesting to use black, I've heard the most yelling about that at klaviyo. Looks like it's modeled off of prettier. I think the draw to using black is the lack of configuration for the most part and how hard lined it is.

@codecov
Copy link

codecov bot commented Jan 7, 2020

Codecov Report

Merging #4 into master will decrease coverage by 6.49%.
The diff coverage is 93.5%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master      #4     +/-   ##
========================================
- Coverage     100%   93.5%   -6.5%     
========================================
  Files           1       5      +4     
  Lines           2      77     +75     
========================================
+ Hits            2      72     +70     
- Misses          0       5      +5
Impacted Files Coverage Δ
workos/__about__.py 100% <100%> (ø)
workos/resources/sso.py 100% <100%> (ø)
workos/client.py 100% <100%> (ø)
workos/exceptions.py 84.21% <84.21%> (ø)
workos/utils/request.py 93.33% <93.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0555a67...a00f5ec. Read the comment docs.

Copy link
Member

@marktran marktran left a comment

Choose a reason for hiding this comment

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

👍 not a Pythonista but this seems to cover SSO as far as I can tell

I'll leave it to @rjvani to approve

Copy link
Contributor

@rohanjadvani rohanjadvani left a comment

Choose a reason for hiding this comment

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

Few minor suggestions, but LGTM otherwise 🎉

README.md Outdated
# workos-python
API Client for WorkOS

Pyhon SDK to conveniently access the [WorkOS] API(https://workos.com).
Copy link
Contributor

Choose a reason for hiding this comment

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

Super nit, but I think for markdown you might need to do WorkOS API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops


def test_initialize_sso_missing_api_key(self, set_project_id):
with pytest.raises(ConfigurationException):
client.sso
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: don't have to, but can be more explicit if you want to case on the setting that's missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea

with pytest.raises(ConfigurationException):
client.sso


No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Can maybe also add a test if both are missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍


api_key = None
project_id = None
base_api_url = BASE_API_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really have a strong opinion here, but since the variable is used only once, can directly set base_api_url to the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd be down for that

Returns:
WorkOSProfile: The WorkOS profile of a User
'''
profile_data = response['profile']
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use get in case of potential KeyError?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how I'd want the user to encounter this just yet but I at the very least would want an exception because something I'm expecting isn't there


profile = cls()
for field in WorkOSProfile.OBJECT_FIELDS:
setattr(profile, field, profile_data[field])
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, would consider using get

@henrylamchan henrylamchan merged commit 4a0c888 into master Jan 15, 2020
@henrylamchan henrylamchan deleted the 201912_sso branch January 15, 2020 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants