From 67222ec79c944ad3076fb516ed98d169c8c17651 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 17:40:00 -0800 Subject: [PATCH 01/12] Update to version 3. --- .circleci/config.yml | 10 +++++----- noxfile.py | 15 +++++++++------ pybadges/version.py | 2 +- server-example/requirements.txt | 2 +- server-example/test_app.py | 1 - setup.py | 14 ++++++-------- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9e8301a..a8ae75b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: Unit Test: docker: - - image: circleci/python:3.7.1 + - image: circleci/python:3.10.2 steps: - checkout @@ -13,7 +13,7 @@ jobs: nox -f noxfile.py -s unit Compatibility Test: docker: - - image: circleci/python:3.7.1 + - image: circleci/python:3.10.2 steps: - checkout @@ -24,7 +24,7 @@ jobs: nox -f noxfile.py -s compatibility Lint: docker: - - image: circleci/python:3.7.1 + - image: circleci/python:3.10.2 steps: - checkout @@ -35,7 +35,7 @@ jobs: nox -f noxfile.py -s lint Type Check: docker: - - image: circleci/python:3.7.1 + - image: circleci/python:3.10.2 steps: - checkout @@ -46,7 +46,7 @@ jobs: nox -f noxfile.py -s type_check Release: docker: - - image: circleci/python:3.7.1 + - image: circleci/python:3.10.2 steps: - checkout diff --git a/noxfile.py b/noxfile.py index cc10e47..4a1edc4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -14,6 +14,7 @@ """Nox config for running lint and unit tests.""" import nox +import sys def _run_tests(session): @@ -28,21 +29,21 @@ def lint(session): serious code quality issues. """ session.install('yapf') - session.run('python3', '-m', 'yapf', '--diff', '-r', '.') + session.run('yapf', '--diff', '-r', '.') @nox.session def unit(session): """Run the unit test suite.""" session.install('-e', '.[dev]') - session.install('-r', 'server-example/requirements-test.txt') + session.install('flask') _run_tests(session) -@nox.session(python=['3.4', '3.5', '3.6', '3.7', '3.8']) +@nox.session(python=['3.7', '3.8', '3.9', '3.10']) @nox.parametrize( 'install', - ['Jinja2==2.9.0', 'Pillow==5.0.0', 'requests==2.9.0', 'xmldiff==2.4']) + ['Jinja2==3.0.0', 'Pillow==6.0.0', 'requests==2.22.0', 'xmldiff==2.4']) def compatibility(session, install): """Run the unit test suite with each support library and Python version.""" @@ -52,10 +53,12 @@ def compatibility(session, install): _run_tests(session) -@nox.session(python=['3.6']) +@nox.session(python=['3.10']) def type_check(session): """Run type checking using pytype.""" + if sys.platform.startswith('win'): + session.skip('pytype not supported on Windows') session.install('-e', '.[dev]') session.install('pytype') - session.run('pytype', '--python-version=3.6', '--disable=pyi-error', + session.run('pytype', '--python-version=3.10', '--disable=pyi-error', 'pybadges') diff --git a/pybadges/version.py b/pybadges/version.py index ab8773b..401bd4f 100644 --- a/pybadges/version.py +++ b/pybadges/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = '2.3.0' # Also change in setup.py. +__version__ = '3.0.0' # Also change in setup.py. diff --git a/server-example/requirements.txt b/server-example/requirements.txt index 4ff2cec..f836b15 100644 --- a/server-example/requirements.txt +++ b/server-example/requirements.txt @@ -1,2 +1,2 @@ -Flask>1.1 +Flask>=2.0 pybadges diff --git a/server-example/test_app.py b/server-example/test_app.py index 41b9d34..39a383f 100644 --- a/server-example/test_app.py +++ b/server-example/test_app.py @@ -11,7 +11,6 @@ # 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. - "Tests for app" import pytest diff --git a/setup.py b/setup.py index 2c6109d..288cf6e 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ def get_long_description(): setup( name='pybadges', - version='2.3.0', # Also change in version.py. + version='3.0.0', # Also change in version.py. author='Brian Quinlan', author_email='brian@sweetapp.com', classifiers=[ @@ -49,10 +49,10 @@ setup( 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - '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 :: 3.10', 'Operating System :: OS Independent', ], description='A library and command-line tool for generating Github-style ' + @@ -66,11 +66,9 @@ setup( long_description=get_long_description(), long_description_content_type='text/markdown', python_requires='>=3.4', - install_requires=[ - 'Jinja2>=2.9.0,<3', 'MarkupSafe<2.1.0', 'requests>=2.9.0,<3' - ], + install_requires=['Jinja2>=3,<4', 'requests>=2.22.0,<3'], extras_require={ - 'pil-measurement': ['Pillow>=5,<6'], + 'pil-measurement': ['Pillow>=6,<10'], 'dev': [ 'fonttools>=3.26', 'nox', 'Pillow>=5', 'pytest>=3.6', 'xmldiff>=2.4' ], From 86b93d1eaad5242c0cfe62843deaec476b2695a5 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 17:46:35 -0800 Subject: [PATCH 02/12] Use cimg --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a8ae75b..4940b6b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: Unit Test: docker: - - image: circleci/python:3.10.2 + - image: cimg/python:3.10.2 steps: - checkout @@ -13,7 +13,7 @@ jobs: nox -f noxfile.py -s unit Compatibility Test: docker: - - image: circleci/python:3.10.2 + - image: cimg/python:3.10.2 steps: - checkout @@ -24,7 +24,7 @@ jobs: nox -f noxfile.py -s compatibility Lint: docker: - - image: circleci/python:3.10.2 + - image: cimg/python:3.10.2 steps: - checkout @@ -35,7 +35,7 @@ jobs: nox -f noxfile.py -s lint Type Check: docker: - - image: circleci/python:3.10.2 + - image: cimg/python:3.10.2 steps: - checkout @@ -46,7 +46,7 @@ jobs: nox -f noxfile.py -s type_check Release: docker: - - image: circleci/python:3.10.2 + - image: cimg/python:3.10.2 steps: - checkout From d209d53af2c1d9c5f4e543762caef37967cf4f3e Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 19:45:53 -0800 Subject: [PATCH 03/12] Add docker auth --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4940b6b..b83bb30 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,9 @@ jobs: Unit Test: docker: - image: cimg/python:3.10.2 - + auth: + username: $DOCKER_USERNAME + password: $DOCKER_PASSWORD steps: - checkout - run: From 3e9cf13e37ee02fae11a345200b951bbc3a1e0de Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:11:53 -0800 Subject: [PATCH 04/12] Remove sudo --- .circleci/config.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b83bb30..92455ef 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,8 +10,8 @@ jobs: - checkout - run: command: | - sudo pip install virtualenv - sudo pip install nox + pip install virtualenv + pip install nox nox -f noxfile.py -s unit Compatibility Test: docker: @@ -21,8 +21,8 @@ jobs: - checkout - run: command: | - sudo pip install virtualenv - sudo pip install nox + pip install virtualenv + pip install nox nox -f noxfile.py -s compatibility Lint: docker: @@ -32,8 +32,8 @@ jobs: - checkout - run: command: | - sudo pip install virtualenv - sudo pip install nox + pip install virtualenv + pip install nox nox -f noxfile.py -s lint Type Check: docker: @@ -43,8 +43,8 @@ jobs: - checkout - run: command: | - sudo pip install virtualenv - sudo pip install nox + pip install virtualenv + pip install nox nox -f noxfile.py -s type_check Release: docker: @@ -54,9 +54,9 @@ jobs: - checkout - run: command: | - sudo pip install --upgrade twine - sudo pip install --upgrade wheel - sudo pip install --upgrade setuptools + pip install --upgrade twine + pip install --upgrade wheel + pip install --upgrade setuptools source twine_upload.sh From eec9c92affec0d662402ed3c2d64ad34310b5816 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:18:59 -0800 Subject: [PATCH 05/12] Only test with newish pillow --- noxfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 4a1edc4..5ae0cc4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -43,7 +43,12 @@ def unit(session): @nox.session(python=['3.7', '3.8', '3.9', '3.10']) @nox.parametrize( 'install', - ['Jinja2==3.0.0', 'Pillow==6.0.0', 'requests==2.22.0', 'xmldiff==2.4']) + [ + 'Jinja2==3.0.0', + 'Pillow==8.3.2', # Oldest version that supports Python 3.7 to 3.10. + 'requests==2.22.0', + 'xmldiff==2.4' + ]) def compatibility(session, install): """Run the unit test suite with each support library and Python version.""" From 0ad0c865fe579ae53a09335814d16e93fd924a3f Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:20:51 -0800 Subject: [PATCH 06/12] Typec heck using an old Python version --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 92455ef..94cc033 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,7 +37,7 @@ jobs: nox -f noxfile.py -s lint Type Check: docker: - - image: cimg/python:3.10.2 + - image: cimg/python:3.7.12 steps: - checkout From ec0f05a166fdab62f86b1568491259573ac5c242 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:32:50 -0800 Subject: [PATCH 07/12] User CI to control python version --- .circleci/config.yml | 16 +++++++++++----- noxfile.py | 7 +++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 94cc033..8128ca0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,9 +3,6 @@ jobs: Unit Test: docker: - image: cimg/python:3.10.2 - auth: - username: $DOCKER_USERNAME - password: $DOCKER_PASSWORD steps: - checkout - run: @@ -13,10 +10,19 @@ jobs: pip install virtualenv pip install nox nox -f noxfile.py -s unit - Compatibility Test: + Compatibility Test 3.10: docker: - image: cimg/python:3.10.2 - + steps: + - checkout + - run: + command: | + pip install virtualenv + pip install nox + nox -f noxfile.py -s compatibility + Compatibility Test 3.9: + docker: + - image: cimg/python:3.9.10 steps: - checkout - run: diff --git a/noxfile.py b/noxfile.py index 5ae0cc4..1e72e33 100644 --- a/noxfile.py +++ b/noxfile.py @@ -40,7 +40,6 @@ def unit(session): _run_tests(session) -@nox.session(python=['3.7', '3.8', '3.9', '3.10']) @nox.parametrize( 'install', [ @@ -52,13 +51,13 @@ def unit(session): def compatibility(session, install): """Run the unit test suite with each support library and Python version.""" - session.install('-e', '.[dev]') - session.install('-r', 'server-example/requirements-test.txt') session.install(install) + session.install('-r', 'server-example/requirements-test.txt') + session.install('-e', '.[dev]') _run_tests(session) -@nox.session(python=['3.10']) +@nox.session(python=['3.7']) def type_check(session): """Run type checking using pytype.""" if sys.platform.startswith('win'): From 067e6874fe68d220c615d6603a1e0e9eeb15508a Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:33:53 -0800 Subject: [PATCH 08/12] Fix job references --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8128ca0..4ba498c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,7 +73,8 @@ workflows: - Lint - Unit Test - Type Check - - Compatibility Test + - Compatibility Test 3.10 + - Compatibility Test 3.9 release: jobs: - Release: From 1336303a82335e5eccc473709bd418ddfe926e05 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:35:03 -0800 Subject: [PATCH 09/12] Restore session --- noxfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/noxfile.py b/noxfile.py index 1e72e33..6a01977 100644 --- a/noxfile.py +++ b/noxfile.py @@ -40,6 +40,7 @@ def unit(session): _run_tests(session) +@nox.session @nox.parametrize( 'install', [ From e2dd4b988e424da37ff591e96c1fb59aadc15c72 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:39:44 -0800 Subject: [PATCH 10/12] Add tests for older Python versions --- .circleci/config.yml | 23 ++++++++++++++++++++++- noxfile.py | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ba498c..54cd85a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,10 +30,29 @@ jobs: pip install virtualenv pip install nox nox -f noxfile.py -s compatibility + Compatibility Test 3.8: + docker: + - image: cimg/python:3.8.12 + steps: + - checkout + - run: + command: | + pip install virtualenv + pip install nox + nox -f noxfile.py -s compatibility + Compatibility Test 3.7: + docker: + - image: cimg/python:3.7.12 + steps: + - checkout + - run: + command: | + pip install virtualenv + pip install nox + nox -f noxfile.py -s compatibility Lint: docker: - image: cimg/python:3.10.2 - steps: - checkout - run: @@ -75,6 +94,8 @@ workflows: - Type Check - Compatibility Test 3.10 - Compatibility Test 3.9 + - Compatibility Test 3.8 + - Compatibility Test 3.9 release: jobs: - Release: diff --git a/noxfile.py b/noxfile.py index 6a01977..6af11bf 100644 --- a/noxfile.py +++ b/noxfile.py @@ -65,5 +65,5 @@ def type_check(session): session.skip('pytype not supported on Windows') session.install('-e', '.[dev]') session.install('pytype') - session.run('pytype', '--python-version=3.10', '--disable=pyi-error', + session.run('pytype', '--python-version=3.7', '--disable=pyi-error', 'pybadges') From 1b02c3593c5ada699a5b5b642f975765e7efb430 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:40:35 -0800 Subject: [PATCH 11/12] Fix workflow typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 54cd85a..c1287c6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -95,7 +95,7 @@ workflows: - Compatibility Test 3.10 - Compatibility Test 3.9 - Compatibility Test 3.8 - - Compatibility Test 3.9 + - Compatibility Test 3.7 release: jobs: - Release: From b1d299c104520991ebd2787c03dce1956ca9be84 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 22 Feb 2022 20:44:11 -0800 Subject: [PATCH 12/12] Fix incorrect type annotation --- pybadges/precalculate_text.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pybadges/precalculate_text.py b/pybadges/precalculate_text.py index cac7c0a..b24e41d 100644 --- a/pybadges/precalculate_text.py +++ b/pybadges/precalculate_text.py @@ -104,10 +104,9 @@ def calculate_character_to_length_mapping( return char_to_length -def calculate_pair_to_kern_mapping( - measurer: text_measurer.TextMeasurer, char_to_length: Mapping[str, - float], - characters: Iterable[str]) -> Mapping[str, float]: +def calculate_pair_to_kern_mapping(measurer: text_measurer.TextMeasurer, + char_to_length: Mapping[str, float], + characters: str) -> Mapping[str, float]: """Returns a mapping between each *pair* of characters and their kerning. Args: