-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-3568 Intellisense highlights multiple PyMongo methods because of CodecOptions #1139
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
Changes from all commits
9d7ae96
598261b
52a5364
968f994
2fefac8
9b5bd67
7bcfcaf
f826b74
3571f3f
76b77df
c158f60
7dc82c7
aff48f5
84f682a
01bf36a
0ba5e7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2023-Present MongoDB, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Type aliases used by bson""" | ||
from typing import TYPE_CHECKING, Any, Mapping, MutableMapping, TypeVar, Union | ||
|
||
if TYPE_CHECKING: | ||
from array import array | ||
from mmap import mmap | ||
|
||
from bson.raw_bson import RawBSONDocument | ||
|
||
|
||
# Common Shared Types. | ||
_DocumentIn = Union[MutableMapping[str, Any], "RawBSONDocument"] | ||
_DocumentOut = _DocumentIn | ||
_DocumentType = TypeVar("_DocumentType", bound=Mapping[str, Any]) | ||
_DocumentTypeArg = TypeVar("_DocumentTypeArg", bound=Mapping[str, Any]) | ||
_ReadableBuffer = Union[bytes, memoryview, "mmap", "array"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ | |
InsertOneResult, | ||
UpdateResult, | ||
) | ||
from pymongo.typings import _CollationIn, _DocumentType, _Pipeline | ||
from pymongo.typings import _CollationIn, _DocumentType, _DocumentTypeArg, _Pipeline | ||
from pymongo.write_concern import WriteConcern | ||
|
||
_FIND_AND_MODIFY_DOC_FIELDS = {"value": 1} | ||
|
@@ -103,6 +103,7 @@ class ReturnDocument(object): | |
|
||
|
||
if TYPE_CHECKING: | ||
import bson | ||
from pymongo.client_session import ClientSession | ||
from pymongo.database import Database | ||
from pymongo.read_concern import ReadConcern | ||
|
@@ -116,7 +117,7 @@ def __init__( | |
database: "Database[_DocumentType]", | ||
name: str, | ||
create: Optional[bool] = False, | ||
codec_options: Optional[CodecOptions] = None, | ||
codec_options: Optional["CodecOptions[_DocumentTypeArg]"] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come this one can be "CodecOptions" not "bson.CodecOptions"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't make heads or tails of it, other than the fact that this a constructor. I tried removing the docstring from |
||
read_preference: Optional[_ServerMode] = None, | ||
write_concern: Optional[WriteConcern] = None, | ||
read_concern: Optional["ReadConcern"] = None, | ||
|
@@ -394,7 +395,7 @@ def database(self) -> "Database[_DocumentType]": | |
|
||
def with_options( | ||
self, | ||
codec_options: Optional[CodecOptions] = None, | ||
codec_options: Optional["bson.CodecOptions[_DocumentTypeArg]"] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What caused the change to add "bson." here? We don't need to do the same for ReadConcern/WriteConcern/etc.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was needed to satisfy sphinx:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's odd. I don't see those warning locally:
It would be great to avoid changing the type signature just because of a sphinx issue (bug?) if possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We needed to switch to strings because on Python 3.7 we were getting: |
||
read_preference: Optional[_ServerMode] = None, | ||
write_concern: Optional[WriteConcern] = None, | ||
read_concern: Optional["ReadConcern"] = None, | ||
|
Uh oh!
There was an error while loading. Please reload this page.