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

feat: add create user param to sign in (Sourcery refactored) #76

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Jan 20, 2022

Pull Request #75 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the feat/add-create-user-param-to-sign-in branch, then run:

git fetch origin sourcery/feat/add-create-user-param-to-sign-in
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from leynier January 20, 2022 07:21
self.api = api if api else AsyncGoTrueAPI(**args)
self.api = api or AsyncGoTrueAPI(**args)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function AsyncGoTrueClient.__init__ refactored with the following changes:

elif email and password:
elif email:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function AsyncGoTrueClient.sign_in refactored with the following changes:

Comment on lines -573 to +582
if expires_at < time_now:
if self.auto_refresh_token and session.refresh_token:
try:
await self._call_refresh_token(refresh_token=session.refresh_token)
except APIError:
await self._remove_session()
else:
if (
expires_at < time_now
and self.auto_refresh_token
and session.refresh_token
):
try:
await self._call_refresh_token(refresh_token=session.refresh_token)
except APIError:
await self._remove_session()
elif not session or not session.user:
elif expires_at < time_now or not session or not session.user:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function AsyncGoTrueClient._recover_and_refresh refactored with the following changes:

self.api = api if api else SyncGoTrueAPI(**args)
self.api = api or SyncGoTrueAPI(**args)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function SyncGoTrueClient.__init__ refactored with the following changes:

elif email and password:
elif email:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function SyncGoTrueClient.sign_in refactored with the following changes:

response = self._call_refresh_token()
return response
return self._call_refresh_token()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function SyncGoTrueClient.refresh_session refactored with the following changes:

Comment on lines -529 to -534
response = self.api.get_url_for_provider(
return self.api.get_url_for_provider(
provider=provider,
redirect_to=redirect_to,
scopes=scopes,
)
return response
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function SyncGoTrueClient._handle_provider_sign_in refactored with the following changes:

Comment on lines -571 to +578
if expires_at < time_now:
if self.auto_refresh_token and session.refresh_token:
try:
self._call_refresh_token(refresh_token=session.refresh_token)
except APIError:
self._remove_session()
else:
if (
expires_at < time_now
and self.auto_refresh_token
and session.refresh_token
):
try:
self._call_refresh_token(refresh_token=session.refresh_token)
except APIError:
self._remove_session()
elif not session or not session.user:
elif expires_at < time_now or not session or not session.user:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function SyncGoTrueClient._recover_and_refresh refactored with the following changes:

@sourcery-ai
Copy link
Contributor Author

sourcery-ai bot commented Jan 20, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.14%.

Quality metrics Before After Change
Complexity 5.11 ⭐ 4.72 ⭐ -0.39 👍
Method Length 45.08 ⭐ 44.74 ⭐ -0.34 👍
Working memory 7.71 🙂 7.83 🙂 0.12 👎
Quality 74.24% 🙂 74.38% 🙂 0.14% 👍
Other metrics Before After Change
Lines 1210 1210 0
Changed files Quality Before Quality After Quality Change
gotrue/_async/client.py 74.10% 🙂 74.31% 🙂 0.21% 👍
gotrue/_sync/client.py 74.38% 🙂 74.45% 🙂 0.07% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gotrue/_async/client.py AsyncGoTrueClient.get_session_from_url 15 🙂 219 ⛔ 14 😞 36.39% 😞 Try splitting into smaller methods. Extract out complex expressions
gotrue/_sync/client.py SyncGoTrueClient.get_session_from_url 15 🙂 217 ⛔ 14 😞 36.53% 😞 Try splitting into smaller methods. Extract out complex expressions
gotrue/_async/client.py AsyncGoTrueClient.sign_in 9 🙂 117 🙂 11 😞 56.08% 🙂 Extract out complex expressions
gotrue/_sync/client.py SyncGoTrueClient.sign_in 9 🙂 110 🙂 11 😞 56.98% 🙂 Extract out complex expressions
gotrue/_async/client.py AsyncGoTrueClient.__init__ 3 ⭐ 88 🙂 16 ⛔ 58.70% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@leynier leynier merged commit a226b9f into feat/add-create-user-param-to-sign-in Jan 20, 2022
leynier added a commit that referenced this pull request Jan 20, 2022
* feat: add create user param to sign in

ref: supabase/auth#318

* 'Refactored by Sourcery' (#76)

Co-authored-by: Sourcery AI <>

* chore: format code

* chore: format code

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
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.

None yet

1 participant