-
Notifications
You must be signed in to change notification settings - Fork 23
Initial WorkOS package with SSO #4
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
Conversation
2245c60 to
61c3bc4
Compare
|
|
||
| class SSO(object): | ||
| def __init__(self): | ||
| required_settings = ['api_key', 'project_id', ] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool sounds good 👍
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 Report
@@ 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
Continue to review full report at Codecov.
|
89d2f1b to
2ff9b49
Compare
2ff9b49 to
0799ebe
Compare
marktran
left a comment
There was a problem hiding this 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
rohanjadvani
left a comment
There was a problem hiding this 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). |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
tests/test_client.py
Outdated
| with pytest.raises(ConfigurationException): | ||
| client.sso | ||
|
|
||
|
No newline at end of file |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
workos/__init__.py
Outdated
|
|
||
| api_key = None | ||
| project_id = None | ||
| base_api_url = BASE_API_URL |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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
Overview
Initial package with SSO functionality