Skip to content

Commit

Permalink
Merge pull request #288 from IlyaSkriblovsky/deprecation-warnings
Browse files Browse the repository at this point in the history
Deprecation warnings
  • Loading branch information
psi29a authored Sep 30, 2024
2 parents 90e141a + bd6a3b9 commit 3e2c57c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docs/source/NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Changelog
=========

Release UPCOMING (yyyy-mm-dd)
-----------------------------
Release 24.0.0 (2024-09-18)
---------------------------

API Changes
^^^^^^^^^^^

- This is the last release that supports Python <3.8 and MongoDB <4.0
- PyMongo 4+ is now supported. If you will migrate from PyMongo 3 to PyMongo 4, please be sure
to check their PyMongo's guide because newer version has a number of incompatible changes.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@

# General information about the project.
project = 'TxMongo'
copyright = '2021, Alexandre Fiori, Bret Curtis, Ilya Skriblovsky'
copyright = '2024, Alexandre Fiori, Bret Curtis, Ilya Skriblovsky'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '23.0.0'
version = '24.0.0'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
2 changes: 1 addition & 1 deletion python-txmongo.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: python-txmongo
Version: 23.0.0
Version: 24.0.0
Release: 1%{?dist}
Summary: Twisted driver for MongoDB

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="txmongo",
version="23.0.0",
version="24.0.0",
description="Asynchronous Python driver for MongoDB <http://www.mongodb.org>",
author="Alexandre Fiori, Bret Curtis",
author_email="[email protected], [email protected]",
Expand Down
6 changes: 6 additions & 0 deletions txmongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Use of this source code is governed by the Apache License that can be
# found in the LICENSE file.

import sys
import warnings

from txmongo.database import Database
from txmongo.protocol import MongoProtocol, Query
from txmongo.connection import MongoConnection, MongoConnectionPool, lazyMongoConnection, \
Expand All @@ -16,3 +19,6 @@
assert MongoConnectionPool
assert lazyMongoConnection
assert lazyMongoConnectionPool

if sys.version_info < (3, 8):
warnings.warn("Only Python 3.8+ will be supported in the next version of TxMongo", DeprecationWarning)
6 changes: 6 additions & 0 deletions txmongo/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by the Apache License that can be
# found in the LICENSE file.

import warnings

from bson.codec_options import DEFAULT_CODEC_OPTIONS
from pymongo.errors import AutoReconnect, ConfigurationError, OperationFailure
from pymongo.read_preferences import ReadPreference
Expand Down Expand Up @@ -119,6 +121,10 @@ def configure(self, proto):
proto.set_wire_versions(config.get("minWireVersion", 0),
config.get("maxWireVersion", 0))

# MongoDB < 4.0
if proto.max_wire_version < 7:
warnings.warn("MongoDB <4.0 support will be dropped in the next version of TxMongo", DeprecationWarning)

# Track the other hosts in the replica set.
hosts = config.get("hosts")
if isinstance(hosts, list) and hosts:
Expand Down

0 comments on commit 3e2c57c

Please sign in to comment.