-
Notifications
You must be signed in to change notification settings - Fork 1
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
Remove ApiToken and pass api_key as a string #48
Conversation
Reviewer's Guide by SourceryThis pull request removes the ApiToken class and refactors the codebase to pass the api_key as a string. Significant changes include updating the Client and RestClient classes, modifying tests, and updating documentation and examples to reflect this change. File-Level Changes
Tips
|
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.
Hey @mnbf9rca - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 2 issues found
- 🟢 Complexity: all looks good
- 🟡 Documentation: 1 issue found
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
@@ -38,10 +37,10 @@ | |||
class Client: | |||
"""Client | |||
|
|||
:param ApiToken api_token: API token to access TfL unified API | |||
:param str api_token: API token to access TfL unified 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.
suggestion: Update docstring to reflect new parameter name.
The docstring should be updated to reflect the new parameter name 'api_token' instead of 'api_token' to avoid confusion.
@@ -109,7 +108,7 @@ def test_create_model_with_expiry( | |||
"api_token, expected_client_type, expected_models", | |||
[ | |||
(None, RestClient, {"test_model"}), | |||
(ApiToken("valid_token", "valid_key"), RestClient, {"test_model"}), | |||
( "valid_key", RestClient, {"test_model"}), |
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.
suggestion (testing): Add test for invalid API key in parameterized test
Consider adding an additional parameterized test case for an invalid API key to ensure that the client handles invalid keys correctly.
( "valid_key", RestClient, {"test_model"}), | |
("valid_key", RestClient, {"test_model"}), | |
("invalid_key", RestClient, {"test_model"}), |
README.md
Outdated
|
||
app_id = 'APPLICATION ID' | ||
app_key = 'APPLICATION KEY' | ||
|
||
token = ApiToken(app_id, app_key) | ||
token = "your_secret_token" |
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.
suggestion (documentation): Consider adding a note explaining the change from ApiToken to a direct token string.
To avoid confusion for users familiar with the previous method, consider adding a note or comment explaining the change from ApiToken(app_id, app_key)
to token = "your_secret_token"
.
token = "your_secret_token" | |
# Note: Changed from ApiToken(app_id, app_key) to a direct token string for simplicity | |
token = "your_secret_token" |
if self.api_token is not None: | ||
request_headers.update(self.api_token) | ||
if self.app_key is not None: | ||
request_headers.update(self.app_key) |
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.
suggestion (code-quality): Merge dictionary updates via the union operator (dict-assign-update-to-union
)
request_headers.update(self.app_key) | |
request_headers |= self.app_key |
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Summary by Sourcery
This pull request refactors the API token handling by removing the ApiToken class and passing the API key directly as a string. It includes updates to the documentation and tests to reflect this change.