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

Fix #747 by updating async SQLAlchemy OAuth example code #748

Closed
wants to merge 3 commits into from

Conversation

ntarora
Copy link
Contributor

@ntarora ntarora commented Oct 23, 2022

This pull request resolves #747

@CLAassistant
Copy link

CLAassistant commented Oct 23, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ntarora
❌ Neel Arora


Neel Arora seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor Author

@ntarora ntarora left a comment

Choose a reason for hiding this comment

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

Add is_enterprise_install to example

@ntarora
Copy link
Contributor Author

ntarora commented Oct 23, 2022

fix #747

@ntarora ntarora changed the title fix-issue-747 SQLAlchemy async oauth example: fix-issue-747 Oct 23, 2022
@seratch seratch self-assigned this Oct 24, 2022
@seratch seratch added docs Improvements or additions to documentation area:async area:examples issues related to example or sample code labels Oct 24, 2022
@seratch seratch added this to the 1.15.3 milestone Oct 24, 2022
@seratch seratch changed the title SQLAlchemy async oauth example: fix-issue-747 Fix #747 by updating async SQLAlchemy OAuth example code Oct 24, 2022
@@ -63,11 +63,11 @@ async def async_save(self, installation: Installation):
b["client_id"] = self.client_id
await database.execute(self.bots.insert(), b)

async def async_find_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str]) -> Optional[Bot]:
async def async_find_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str], is_enterprise_install: Optional[bool]) -> Optional[Bot]:
Copy link
Member

Choose a reason for hiding this comment

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

flake8 detects lint errors. Can you these lines shorter than 125 chars?

Successfully installed flake8-5.0.4 mccabe-0.7.0 pycodestyle-2.9.1 pyflakes-2.5.0
examples/sqlalchemy/async_oauth_app.py:66:126: E501 line too long (148 > 125 characters)
examples/sqlalchemy/async_oauth_app.py:70:126: E501 line too long (130 > 125 characters)
Error: Process completed with exit code 1.

Copy link
Member

Choose a reason for hiding this comment

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

You can fix these warnings by the following changes:

diff --git a/examples/sqlalchemy/async_oauth_app.py b/examples/sqlalchemy/async_oauth_app.py
index 5ec7be0..a2c52f0 100644
--- a/examples/sqlalchemy/async_oauth_app.py
+++ b/examples/sqlalchemy/async_oauth_app.py
@@ -63,11 +63,23 @@ class AsyncSQLAlchemyInstallationStore(AsyncInstallationStore):
                 b["client_id"] = self.client_id
                 await database.execute(self.bots.insert(), b)
 
-    async def async_find_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str], is_enterprise_install: Optional[bool]) -> Optional[Bot]:
+    async def async_find_bot(
+        self,
+        *,
+        enterprise_id: Optional[str],
+        team_id: Optional[str],
+        is_enterprise_install: Optional[bool],
+    ) -> Optional[Bot]:
         c = self.bots.c
         query = (
             self.bots.select()
-            .where(and_(c.enterprise_id == enterprise_id, c.team_id == team_id, c.is_enterprise_install == is_enterprise_install))
+            .where(
+                and_(
+                    c.enterprise_id == enterprise_id,
+                    c.team_id == team_id,
+                    c.is_enterprise_install == is_enterprise_install,
+                )
+            )
             .order_by(desc(c.installed_at))
             .limit(1)
         )

Copy link
Member

Choose a reason for hiding this comment

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

@ntarora Could you push the fix if you have a chance?

@codecov
Copy link

codecov bot commented Oct 24, 2022

Codecov Report

Merging #748 (415719d) into main (82a98f6) will not change coverage.
The diff coverage is n/a.

❗ Current head 415719d differs from pull request most recent head b0a6fdb. Consider uploading reports for the commit b0a6fdb to get more accurate results

@@           Coverage Diff           @@
##             main     #748   +/-   ##
=======================================
  Coverage   92.06%   92.06%           
=======================================
  Files         172      172           
  Lines        5875     5875           
=======================================
  Hits         5409     5409           
  Misses        466      466           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ntarora
Copy link
Contributor Author

ntarora commented Oct 26, 2022 via email

@seratch
Copy link
Member

seratch commented Nov 4, 2022

Thanks for your contribution! Your changes are merged at f5b40c7 and then I've added an additional commit to resolve the flake8 issue on my end.

@seratch seratch closed this Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:async area:examples issues related to example or sample code docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLAlchemy example for async_find_bot out of date
3 participants