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

PYTHON-4590 - Make type guards more compatible #1850

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

NoahStapp
Copy link
Contributor

No description provided.

@@ -230,8 +230,8 @@ def __init__(
raise TypeError("name must be an instance of str")
from pymongo.asynchronous.database import AsyncDatabase

if not isinstance(database, AsyncDatabase):
raise TypeError(f"AsyncCollection requires an AsyncDatabase but {type(database)} given")
if not isinstance(database, AsyncDatabase) and type(database).__name__ != "AsyncDatabase":
Copy link
Member

Choose a reason for hiding this comment

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

What I meant in the other ticket is something like:

if not isinstance(database, AsyncDatabase:
        if not any(cls.__name__ == "AsyncDatabase" for cls in __mro__):
               raise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh got it, let me see how it goes.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM!

@NoahStapp NoahStapp merged commit 039db2f into mongodb:master Sep 11, 2024
33 of 34 checks passed
@NoahStapp NoahStapp deleted the PYTHON-4590-2 branch September 11, 2024 12:46
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.

2 participants