Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bson/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

from __future__ import annotations

from collections.abc import Mapping
from typing import Any
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections.abc import Mapping


def _setstate_slots(self: Any, state: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion bson/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import struct
import warnings
from collections.abc import Sequence
from enum import Enum
from typing import TYPE_CHECKING, Any, Self, overload
from uuid import UUID
Expand Down Expand Up @@ -64,6 +63,7 @@

if TYPE_CHECKING:
from array import array as _array
from collections.abc import Sequence
from mmap import mmap as _mmap

import numpy as np
Expand Down
6 changes: 4 additions & 2 deletions bson/dbref.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

from __future__ import annotations

from collections.abc import Mapping
from copy import deepcopy
from typing import Any
from typing import TYPE_CHECKING, Any

from bson._helpers import _getstate_slots, _setstate_slots
from bson.son import SON

if TYPE_CHECKING:
from collections.abc import Mapping


class DBRef:
"""A reference to a document stored in MongoDB."""
Expand Down
5 changes: 3 additions & 2 deletions gridfs/asynchronous/grid_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import io
import math
from collections import abc
from collections.abc import Iterable, Mapping
from types import TracebackType
from typing import TYPE_CHECKING, Any, NoReturn, Self, cast

from bson.int64 import Int64
Expand Down Expand Up @@ -62,6 +60,9 @@
from pymongo.read_preferences import ReadPreference, _ServerMode

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping
from types import TracebackType

from pymongo.asynchronous.client_session import AsyncClientSession

_IS_SYNC = False
Expand Down
5 changes: 3 additions & 2 deletions gridfs/synchronous/grid_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import io
import math
from collections import abc
from collections.abc import Iterable, Mapping
from types import TracebackType
from typing import TYPE_CHECKING, Any, NoReturn, Self, cast

from bson.int64 import Int64
Expand Down Expand Up @@ -62,6 +60,9 @@
from pymongo.synchronous.helpers import next

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping
from types import TracebackType

from pymongo.synchronous.client_session import ClientSession

_IS_SYNC = True
Expand Down
6 changes: 4 additions & 2 deletions pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

from __future__ import annotations

from contextlib import AbstractContextManager

__all__ = [
"ASCENDING",
"DESCENDING",
Expand Down Expand Up @@ -114,6 +112,10 @@
from pymongo import collection # noqa: F401
from pymongo import command_cursor # noqa: F401
from pymongo import database # noqa: F401
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from contextlib import AbstractContextManager
# isort: on

version = __version__
Expand Down
8 changes: 5 additions & 3 deletions pymongo/_asyncio_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
import collections
import threading
from asyncio import events, exceptions
from collections.abc import Coroutine
from types import TracebackType
from typing import Any
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections.abc import Coroutine
from types import TracebackType

_global_lock = threading.Lock()

Expand Down
3 changes: 2 additions & 1 deletion pymongo/_client_bulk_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from __future__ import annotations

from collections.abc import Mapping, MutableMapping
from typing import TYPE_CHECKING, Any, NoReturn

from bson.objectid import ObjectId
Expand All @@ -32,6 +31,8 @@
from pymongo.message import _ClientBulkWriteContext

if TYPE_CHECKING:
from collections.abc import Mapping, MutableMapping

from pymongo.typings import _AgnosticMongoClient, _DocumentOut, _Pipeline
from pymongo.write_concern import WriteConcern

Expand Down
3 changes: 2 additions & 1 deletion pymongo/_csot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
from collections.abc import Callable, MutableMapping
from contextlib import AbstractContextManager
from contextvars import ContextVar, Token
from types import TracebackType
from typing import TYPE_CHECKING, Any, TypeVar, cast

if TYPE_CHECKING:
from types import TracebackType

from pymongo.write_concern import WriteConcern

TIMEOUT: ContextVar[float | None] = ContextVar("TIMEOUT", default=None)
Expand Down
6 changes: 4 additions & 2 deletions pymongo/_op_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

from contextlib import AbstractContextManager
from contextvars import ContextVar
from types import TracebackType
from typing import Any
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from types import TracebackType

OP_ID: ContextVar[int | None] = ContextVar("OP_ID", default=None)

Expand Down
5 changes: 3 additions & 2 deletions pymongo/_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
from __future__ import annotations

import datetime
import queue
import time
from collections.abc import MutableMapping
from typing import TYPE_CHECKING, Any

from pymongo import _op_id
Expand All @@ -39,6 +37,9 @@
from pymongo.message import _randint

if TYPE_CHECKING:
import queue
from collections.abc import MutableMapping

from bson.objectid import ObjectId
from pymongo.hello import Hello
from pymongo.monitoring import _EventListeners
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from __future__ import annotations

from collections.abc import Callable, Mapping, MutableMapping
from typing import TYPE_CHECKING, Any

from pymongo import common
Expand All @@ -25,6 +24,8 @@
from pymongo.read_preferences import ReadPreference, _AggWritePref

if TYPE_CHECKING:
from collections.abc import Callable, Mapping, MutableMapping

from pymongo.asynchronous.client_session import AsyncClientSession
from pymongo.asynchronous.collection import AsyncCollection
from pymongo.asynchronous.command_cursor import AsyncCommandCursor
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import hmac
import socket
from base64 import standard_b64decode, standard_b64encode
from collections.abc import Callable, Coroutine, Mapping
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -49,6 +48,8 @@
from pymongo.saslprep import saslprep

if TYPE_CHECKING:
from collections.abc import Callable, Coroutine, Mapping

from pymongo.asynchronous.pool import AsyncConnection

HAVE_KERBEROS = True
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/auth_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any

import bson
from bson.binary import Binary
from pymongo.errors import ConfigurationError, OperationFailure

if TYPE_CHECKING:
from collections.abc import Mapping

from bson.typings import _ReadableBuffer
from pymongo.asynchronous.pool import AsyncConnection
from pymongo.auth_shared import MongoCredential
Expand Down
5 changes: 3 additions & 2 deletions pymongo/asynchronous/auth_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
from __future__ import annotations

import asyncio
import threading
import time
from collections.abc import Mapping, MutableMapping
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any

Expand All @@ -41,6 +39,9 @@
from pymongo.lock import Lock, _async_create_lock

if TYPE_CHECKING:
import threading
from collections.abc import Mapping, MutableMapping

from pymongo.asynchronous.pool import AsyncConnection
from pymongo.auth_shared import MongoCredential

Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from __future__ import annotations

import copy
from collections.abc import Iterator, Mapping, MutableMapping
from itertools import islice
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -56,6 +55,8 @@
from pymongo.write_concern import WriteConcern

if TYPE_CHECKING:
from collections.abc import Iterator, Mapping, MutableMapping

from pymongo.asynchronous.client_session import AsyncClientSession
from pymongo.asynchronous.collection import AsyncCollection
from pymongo.asynchronous.mongo_client import AsyncMongoClient
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/change_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from __future__ import annotations

from types import TracebackType
from typing import TYPE_CHECKING

from bson import _bson_to_dict
Expand All @@ -43,6 +42,8 @@
_IS_SYNC = False

if TYPE_CHECKING:
from types import TracebackType

from pymongo.asynchronous.client_session import AsyncClientSession
from pymongo.asynchronous.collection import AsyncCollection
from pymongo.asynchronous.database import AsyncDatabase
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/client_bulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from __future__ import annotations

import copy
from collections.abc import Mapping, MutableMapping
from itertools import islice
from typing import (
TYPE_CHECKING,
Expand All @@ -38,6 +37,8 @@
from pymongo.asynchronous.helpers import _handle_reauth

if TYPE_CHECKING:
from collections.abc import Mapping, MutableMapping

from pymongo.asynchronous.client_session import AsyncClientSession
from pymongo.asynchronous.mongo_client import AsyncMongoClient
from pymongo.asynchronous.pool import AsyncConnection
Expand Down
4 changes: 2 additions & 2 deletions pymongo/asynchronous/client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@
import asyncio
import random
import time
from collections.abc import Awaitable, Callable
from contextlib import AbstractAsyncContextManager
from contextvars import ContextVar, Token
from typing import (
TYPE_CHECKING,
Expand Down Expand Up @@ -174,6 +172,8 @@
from pymongo.write_concern import WriteConcern

if TYPE_CHECKING:
from collections.abc import Awaitable, Callable
from contextlib import AbstractAsyncContextManager
from types import TracebackType

from pymongo.asynchronous.mongo_client import AsyncMongoClient
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/command_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from __future__ import annotations

from collections import deque
from collections.abc import AsyncIterator, Mapping
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -33,6 +32,8 @@
from pymongo.typings import _Address, _DocumentType

if TYPE_CHECKING:
from collections.abc import AsyncIterator, Mapping

from pymongo.asynchronous.client_session import AsyncClientSession
from pymongo.asynchronous.collection import AsyncCollection
from pymongo.asynchronous.pool import AsyncConnection
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

import datetime
import time
from collections.abc import Callable, Mapping, MutableMapping, Sequence
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -54,6 +53,8 @@
from pymongo.monitoring import _is_speculative_authenticate

if TYPE_CHECKING:
from collections.abc import Callable, Mapping, MutableMapping, Sequence

from bson import CodecOptions
from bson.objectid import ObjectId
from pymongo.asynchronous.client_session import AsyncClientSession
Expand Down
3 changes: 2 additions & 1 deletion pymongo/asynchronous/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from __future__ import annotations

from collections import deque
from collections.abc import Mapping
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -47,6 +46,8 @@
from pymongo.typings import _DocumentOut, _DocumentType

if TYPE_CHECKING:
from collections.abc import Mapping

from bson.codec_options import CodecOptions
from pymongo.asynchronous.collection import AsyncCollection

Expand Down
5 changes: 3 additions & 2 deletions pymongo/asynchronous/cursor_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from __future__ import annotations

from abc import abstractmethod
from collections.abc import Mapping, Sequence
from types import TracebackType
from typing import TYPE_CHECKING, Any, cast

from pymongo import _csot
Expand All @@ -31,6 +29,9 @@
from pymongo.typings import _DocumentOut, _DocumentType

if TYPE_CHECKING:
from collections.abc import Mapping, Sequence
from types import TracebackType

from pymongo.asynchronous.client_session import AsyncClientSession
from pymongo.asynchronous.pool import AsyncConnection
from pymongo.read_preferences import _ServerMode
Expand Down
Loading
Loading