Skip to content

Commit

Permalink
Python: Remove MotorCommandCursor in import typing (#5222)
Browse files Browse the repository at this point in the history
### Motivation and Context
#4433 
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description
* If `tornado` is not installed, importing `MotorCommandCursor` will
fail due to the conditional import requirement. The fix is to import its
parent class `AgnosticCommandCursor`

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
  • Loading branch information
Jibola authored Mar 4, 2024
1 parent 3e67904 commit 3ea7fd4
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from importlib import metadata
from typing import Any, List, Mapping, Optional, Tuple

from motor import MotorCommandCursor, core, motor_asyncio
from motor import core, motor_asyncio
from numpy import ndarray
from pymongo import DeleteOne, ReadPreference, UpdateOne, results
from pymongo.driver_info import DriverInfo
Expand Down Expand Up @@ -272,7 +272,7 @@ async def get_nearest_matches(
if min_relevance_score is not None:
pipeline.append({"$match": {"score": {"$gte": min_relevance_score}}})

cursor: MotorCommandCursor = self.database[collection_name].aggregate(pipeline)
cursor = self.database[collection_name].aggregate(pipeline)

return [
(
Expand Down

0 comments on commit 3ea7fd4

Please sign in to comment.