From b6b54a5bc8e0a8e4da85358a91eb7b3324667940 Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Tue, 30 Jun 2020 07:23:53 -0400 Subject: [PATCH 1/8] update support matrix drop PyMongo 3.3 and 3.4; drop MongoDB 3.4; drop Python 2.7 --- azure-pipelines.yml | 8 +++----- docs/index.rst | 4 ++-- tox.ini | 7 ++----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fa19092..8ac5e61 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ jobs: steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.7' + versionSpec: '3.8' architecture: 'x64' - script: | pip install tox @@ -15,14 +15,12 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: - Python27: - python.version: '2.7' - Python35: - python.version: '3.5' Python36: python.version: '3.6' Python37: python.version: '3.7' + Python38: + python.version: '3.8' maxParallel: 4 steps: diff --git a/docs/index.rst b/docs/index.rst index fa36ad3..b15d3ab 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -64,8 +64,8 @@ not be accepted, and future changes may break compatibility in older versions. Flask-PyMongo is tested against `supported versions -`_ of MongoDB, and Python 2.7 -and 3.5+. For the exact list of version combinations that are tested and +`_ of MongoDB, and Python +and 3.6+. For the exact list of version combinations that are tested and known to be compatible, see the `envlist` in `tox.ini `_. diff --git a/tox.ini b/tox.ini index b056721..558d3af 100644 --- a/tox.ini +++ b/tox.ini @@ -2,11 +2,10 @@ ; keep the pymongo list in sync with what's in .travis.yaml envlist= - pymongo{33,34,35,36,37,38,39}-mongo{34,36,40,42}-flask{0_12,10,11}, style + pymongo{35,36,37,38,39,310}-mongo{36,40,42}-flask{0_12,10,11}, style [testenv] docker = - mongo34: mongo:3.4 mongo36: mongo:3.6 mongo40: mongo:4.0 mongo42: mongo:4.2 @@ -14,13 +13,12 @@ docker = deps = pytest - pymongo33: pymongo>=3.3,<3.4 - pymongo34: pymongo>=3.4,<3.5 pymongo35: pymongo>=3.5,<3.6 pymongo36: pymongo>=3.6,<3.7 pymongo37: pymongo>=3.7,<3.8 pymongo38: pymongo>=3.8,<3.9 pymongo39: pymongo>=3.9,<3.10 + pymongo310: pymongo>=3.10,<3.11 flask0_12: flask>=0.12,<1.0 flask10: flask>=1.0,<1.1 @@ -30,7 +28,6 @@ commands = {envbindir}/py.test --tb=native {toxinidir} [testenv:style] -basepython = python2.7 skipsdist = true skip_install = true deps = From 7c45e15874bec1e73bf5a08efeeb25ffadf9ec65 Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Fri, 6 Aug 2021 10:14:09 -0400 Subject: [PATCH 2/8] update to latest/supported versions as of 8/6/2021 --- tox.ini | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index 558d3af..4d07108 100644 --- a/tox.ini +++ b/tox.ini @@ -2,27 +2,28 @@ ; keep the pymongo list in sync with what's in .travis.yaml envlist= - pymongo{35,36,37,38,39,310}-mongo{36,40,42}-flask{0_12,10,11}, style + pymongo{37,38,39,310,311,312}-mongo{40,42,44,50}-flask{10,11,20}, style [testenv] docker = - mongo36: mongo:3.6 mongo40: mongo:4.0 mongo42: mongo:4.2 + mongo44: mongo:4.4 + mongo50: mongo:5.0 deps = pytest - pymongo35: pymongo>=3.5,<3.6 - pymongo36: pymongo>=3.6,<3.7 pymongo37: pymongo>=3.7,<3.8 pymongo38: pymongo>=3.8,<3.9 pymongo39: pymongo>=3.9,<3.10 pymongo310: pymongo>=3.10,<3.11 + pymongo311: pymongo>=3.11,<3.12 + pymongo312: pymongo>=3.12,<3.13 - flask0_12: flask>=0.12,<1.0 flask10: flask>=1.0,<1.1 flask11: flask>=1.1,<1.2 + flask20: flask>=2.0,<2.1 commands = {envbindir}/py.test --tb=native {toxinidir} From 353830a544c48f764f08d87318645c806baa3df8 Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Fri, 6 Aug 2021 10:23:19 -0400 Subject: [PATCH 3/8] swap py39 for py36 --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8ac5e61..5282f0a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ jobs: steps: - task: UsePythonVersion@0 inputs: - versionSpec: '3.8' + versionSpec: '3.9' architecture: 'x64' - script: | pip install tox @@ -15,12 +15,12 @@ jobs: vmImage: 'ubuntu-16.04' strategy: matrix: - Python36: - python.version: '3.6' Python37: python.version: '3.7' Python38: python.version: '3.8' + Python39: + python.version: '3.9' maxParallel: 4 steps: From 12bd156c84b963dfc339da614f39c66cb81b45c9 Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Fri, 6 Aug 2021 10:25:18 -0400 Subject: [PATCH 4/8] remove py2 compatibility --- flask_pymongo/__init__.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/flask_pymongo/__init__.py b/flask_pymongo/__init__.py index 896c485..5e0fc14 100644 --- a/flask_pymongo/__init__.py +++ b/flask_pymongo/__init__.py @@ -28,7 +28,6 @@ from functools import partial from mimetypes import guess_type -import sys from flask import abort, current_app, request from gridfs import GridFS, NoFile @@ -40,17 +39,6 @@ from flask_pymongo.wrappers import MongoClient -PY2 = sys.version_info[0] == 2 - -# Python 3 compatibility -if PY2: - text_type = (str, unicode) - num_type = (int, long) -else: - text_type = str - num_type = int - - DESCENDING = pymongo.DESCENDING """Descending sort order.""" @@ -151,11 +139,11 @@ def get_upload(filename): :param int cache_for: number of seconds that browsers should be instructed to cache responses """ - if not isinstance(base, text_type): + if not isinstance(base, str): raise TypeError("'base' must be string or unicode") - if not isinstance(version, num_type): + if not isinstance(version, int): raise TypeError("'version' must be an integer") - if not isinstance(cache_for, num_type): + if not isinstance(cache_for, int): raise TypeError("'cache_for' must be an integer") storage = GridFS(self.db, base) @@ -200,7 +188,7 @@ def save_upload(filename): :param kwargs: extra attributes to be stored in the file's document, passed directly to :meth:`gridfs.GridFS.put` """ - if not isinstance(base, text_type): + if not isinstance(base, str): raise TypeError("'base' must be string or unicode") if not (hasattr(fileobj, "read") and callable(fileobj.read)): raise TypeError("'fileobj' must have read() method") From 7a4c3fd086764e6d0cf4a834fab414d153aa03cc Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Fri, 6 Aug 2021 10:37:59 -0400 Subject: [PATCH 5/8] tox-docker 2.x compatibility --- flask_pymongo/tests/util.py | 15 ++++++++++++++- tox.ini | 20 ++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/flask_pymongo/tests/util.py b/flask_pymongo/tests/util.py index 3ee5d4a..ff87bfc 100644 --- a/flask_pymongo/tests/util.py +++ b/flask_pymongo/tests/util.py @@ -15,7 +15,20 @@ class ToxDockerMixin(object): def setUp(self): super(ToxDockerMixin, self).setUp() - self.port = int(os.environ.get("MONGO_27017_TCP", 27017)) + # tox-docker could be running any version; find the env + # var that looks like what tox-docker would provide, but + # fail if there are more than one + env_vars = [ + (k, v) + for k, v in os.environ.items() + if k.startswith("MONGO") and k.endswith("_TCP_PORT") + ] + + self.port = 27017 + if len(env_vars) == 1: + self.port = int(env_vars[0][1]) + else: + assert len(env_vars) < 2, f"too many number of tox-docker mongo port env vars (found {len(env_vars)})" class FlaskRequestTest(ToxDockerMixin, unittest.TestCase): diff --git a/tox.ini b/tox.ini index 4d07108..9c47c45 100644 --- a/tox.ini +++ b/tox.ini @@ -6,10 +6,10 @@ envlist= [testenv] docker = - mongo40: mongo:4.0 - mongo42: mongo:4.2 - mongo44: mongo:4.4 - mongo50: mongo:5.0 + mongo40: mongo40 + mongo42: mongo42 + mongo44: mongo44 + mongo50: mongo50 deps = pytest @@ -49,3 +49,15 @@ import-order-style = fromsfirst ignore = D100,D104,D107 exclude = _version.py + +[docker:mongo40] +image = mongo:4.0 + +[docker:mongo42] +image = mongo:4.2 + +[docker:mongo44] +image = mongo:4.4 + +[docker:mongo50] +image = mongo:5.0 From 8023ea8ca3bdd09677130691da078edfa8903cbd Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Fri, 6 Aug 2021 10:39:46 -0400 Subject: [PATCH 6/8] update py versions in trove classifiers --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 847a2e6..428f63f 100644 --- a/setup.py +++ b/setup.py @@ -40,10 +40,9 @@ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" From fff23dc10d9a458d7d87e01eb0fff4d36047d85b Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Fri, 6 Aug 2021 10:41:13 -0400 Subject: [PATCH 7/8] wheel? --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5282f0a..4f9662c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,6 +30,7 @@ jobs: architecture: 'x64' - script: | + pip install wheel pip install tox tox-docker tox displayName: 'tox' From 2012d2888bd0d3d778f02395015cc38efaad3887 Mon Sep 17 00:00:00 2001 From: Dan Crosta Date: Fri, 6 Aug 2021 10:43:43 -0400 Subject: [PATCH 8/8] style --- flask_pymongo/tests/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flask_pymongo/tests/util.py b/flask_pymongo/tests/util.py index ff87bfc..a6e7496 100644 --- a/flask_pymongo/tests/util.py +++ b/flask_pymongo/tests/util.py @@ -28,7 +28,9 @@ def setUp(self): if len(env_vars) == 1: self.port = int(env_vars[0][1]) else: - assert len(env_vars) < 2, f"too many number of tox-docker mongo port env vars (found {len(env_vars)})" + self.fail( + f"too many tox-docker mongo port env vars (found {len(env_vars)})", + ) class FlaskRequestTest(ToxDockerMixin, unittest.TestCase):