From 4119d573ffba3b96d0dc84fa55eec23475c0d1eb Mon Sep 17 00:00:00 2001 From: g6s Date: Tue, 16 Apr 2024 17:28:24 -0600 Subject: [PATCH 1/4] support py3.10+ --- .pre-commit-config.yaml | 24 ++++++++++++------------ CHANGELOG.md | 10 ++++++++++ Makefile | 2 +- magic_admin/resources/token.py | 6 +++--- magic_admin/version.py | 2 +- requirements-dev.txt | 21 ++++++++++----------- requirements.txt | 3 ++- tests/unit/resources/token_test.py | 8 ++++---- 8 files changed, 43 insertions(+), 33 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e105bf..c9b8e71 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,28 +3,28 @@ repos: rev: v2.5.0 hooks: - id: flake8 - language_version: python3.6 + language_version: python3 args: [ --max-line-length=100, # We did some funky thing in __init__.py, skip them for now. --exclude=*__init__.py ] - id: trailing-whitespace - language_version: python3.6 + language_version: python3 - id: end-of-file-fixer - language_version: python3.6 + language_version: python3 - id: check-merge-conflict - language_version: python3.6 + language_version: python3 - id: requirements-txt-fixer - language_version: python3.6 + language_version: python3 - id: name-tests-test - language_version: python3.6 + language_version: python3 - id: double-quote-string-fixer - language_version: python3.6 + language_version: python3 - id: forbid-new-submodules - language_version: python3.6 + language_version: python3 - id: check-yaml - language_version: python3.6 + language_version: python3 files: (\.(yaml|yml|eyaml))$ - id: check-json files: \.(jshintrc|json)$ @@ -32,7 +32,7 @@ repos: rev: v1.5.1 hooks: - id: autopep8 - language_version: python3.6 + language_version: python3 - repo: https://github.com/asottile/add-trailing-comma rev: v2.0.1 hooks: @@ -41,11 +41,11 @@ repos: rev: v2.2.0 hooks: - id: reorder-python-imports - language_version: python3.6 + language_version: python3 - repo: https://github.com/asottile/pyupgrade rev: v2.1.1 hooks: - id: pyupgrade args: - --py3-plus - language_version: python3.6 + language_version: python3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 420499d..47cb593 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,16 @@ - ... +## `1.2.0` - 04/16/2024 + +#### Changed + +- Support for up to python 3.11: + - Bump web3 dependencies, bump some dev dependencies. + - Replace deprecated eth_account methods on the account recovery. + - Bump websockets to 10.0 to support python 3.10+ + + ## `1.0.0` - 07/05/2023 #### Added diff --git a/Makefile b/Makefile index ee70743..6ed17aa 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ development: virtualenv_run install_prod_requirements install_dev_requirements i .PHONY: virtualenv_run virtualenv_run: - virtualenv -p python3.6 virtualenv_run + virtualenv -p python3.11 virtualenv_run virtualenv_run/bin/pip install --upgrade pip .PHONY: install_prod_requirements diff --git a/magic_admin/resources/token.py b/magic_admin/resources/token.py index 3119f91..fdbc9b8 100644 --- a/magic_admin/resources/token.py +++ b/magic_admin/resources/token.py @@ -1,7 +1,7 @@ import base64 import json -from eth_account.messages import defunct_hash_message +from eth_account.messages import encode_defunct from web3.auto import w3 import magic_admin @@ -147,8 +147,8 @@ def validate(cls, did_token): 'with a suitable value.', ) - recovered_address = w3.eth.account.recoverHash( - defunct_hash_message( + recovered_address = w3.eth.account.recover_message( + encode_defunct( text=json.dumps(claim, separators=(',', ':')), ), signature=proof, diff --git a/magic_admin/version.py b/magic_admin/version.py index 1e5a605..ee65984 100644 --- a/magic_admin/version.py +++ b/magic_admin/version.py @@ -1 +1 @@ -VERSION = '1.0.0' +VERSION = '1.2.0' diff --git a/requirements-dev.txt b/requirements-dev.txt index a0781e1..88747f1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,9 +1,9 @@ appnope==0.1.0 aspy.yaml==1.3.0 -attrs==19.3.0 +attrs==22.2.0 backcall==0.1.0 cfgv==3.1.0 -coverage==4.5.1 +coverage==5.2.1 decorator==4.4.2 identify==1.4.14 importlib-metadata==1.6.0 @@ -14,26 +14,25 @@ ipython-genutils==0.2.0 jedi==0.16.0 more-itertools==8.2.0 nodeenv==1.3.5 -packaging==21.3 +packaging==23.2 parso==0.6.2 pexpect==4.8.0 pickleshare==0.7.5 -pluggy==0.13.1 +pluggy==1.4 pre-commit==1.21.0 pretend==1.0.8 prompt-toolkit==3.0.5 ptyprocess==0.6.0 -py==1.8.1 +py==1.11.0 Pygments==2.7.4 pyparsing==2.4.7 -pytest==5.4.1 -pytest-cov==2.8.1 -pytest-mock==3.6.1 -PyYAML==5.4.1 +pytest== 8.1.1 +pytest-cov==5.0.0 +pytest-mock==3.14.0 six==1.14.0 toml==0.10.0 -tox==3.0.0 +tox==4.14.0 traitlets==4.3.3 -virtualenv==16.7.9 +virtualenv==20.25 wcwidth==0.1.9 zipp==3.1.0 diff --git a/requirements.txt b/requirements.txt index de28156..12db4ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ requests >= 2.22.0, <3 -web3 >= 4.8.1, <6 +web3 >= 6 +websockets >= 10.0 diff --git a/tests/unit/resources/token_test.py b/tests/unit/resources/token_test.py index 1aebe0f..2f07597 100644 --- a/tests/unit/resources/token_test.py +++ b/tests/unit/resources/token_test.py @@ -151,8 +151,8 @@ class TestTokenValidate: 'proof', 'claim', 'decode', - 'recoverHash', - 'defunct_hash_message', + 'recover_message', + 'encode_defunct', 'get_public_address', 'epoch_time_now', 'apply_did_token_nbf_grace_period', @@ -173,10 +173,10 @@ def setup_mocks(self): 'decode', return_value=(proof, claim), ) as decode, mock.patch( - 'magic_admin.resources.token.w3.eth.account.recoverHash', + 'magic_admin.resources.token.w3.eth.account.recover_message', return_value=self.public_address, ) as recoverHash, mock.patch( - 'magic_admin.resources.token.defunct_hash_message', + 'magic_admin.resources.token.encode_defunct', ) as defunct_hash_message, mock.patch.object( Token, 'get_public_address', From 2eeeef3d6a831b6db5195492910722f7155914f9 Mon Sep 17 00:00:00 2001 From: g6s Date: Tue, 16 Apr 2024 18:02:58 -0600 Subject: [PATCH 2/4] fix tests and precommit config --- .pre-commit-config.yaml | 19 +++++++++++-------- CHANGELOG.md | 2 +- requirements-dev.txt | 2 +- tests/unit/resources/token_test.py | 4 ++-- tox.ini | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9b8e71..4d6c21a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.5.0 + rev: v4.4.0 hooks: - - id: flake8 - language_version: python3 - args: [ - --max-line-length=100, - # We did some funky thing in __init__.py, skip them for now. - --exclude=*__init__.py - ] - id: trailing-whitespace language_version: python3 - id: end-of-file-fixer @@ -28,6 +21,16 @@ repos: files: (\.(yaml|yml|eyaml))$ - id: check-json files: \.(jshintrc|json)$ +- repo: https://github.com/pycqa/flake8 + rev: '' + hooks: + - id: flake8 + language_version: python3 + args: [ + --max-line-length=100, + # We did some funky thing in __init__.py, skip them for now. + --exclude=*__init__.py + ] - repo: https://github.com/pre-commit/mirrors-autopep8 rev: v1.5.1 hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index 47cb593..8efed7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ #### Changed -- Support for up to python 3.11: +- Support for up to python 3.11: - Bump web3 dependencies, bump some dev dependencies. - Replace deprecated eth_account methods on the account recovery. - Bump websockets to 10.0 to support python 3.10+ diff --git a/requirements-dev.txt b/requirements-dev.txt index 88747f1..8c74560 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -19,7 +19,7 @@ parso==0.6.2 pexpect==4.8.0 pickleshare==0.7.5 pluggy==1.4 -pre-commit==1.21.0 +pre-commit==3.7.0 pretend==1.0.8 prompt-toolkit==3.0.5 ptyprocess==0.6.0 diff --git a/tests/unit/resources/token_test.py b/tests/unit/resources/token_test.py index 2f07597..aba9f4f 100644 --- a/tests/unit/resources/token_test.py +++ b/tests/unit/resources/token_test.py @@ -151,8 +151,8 @@ class TestTokenValidate: 'proof', 'claim', 'decode', - 'recover_message', - 'encode_defunct', + 'recoverHash', + 'defunct_hash_message', 'get_public_address', 'epoch_time_now', 'apply_did_token_nbf_grace_period', diff --git a/tox.ini b/tox.ini index 12f300d..8d85e3a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] -envlist = py36 +envlist = py311,py39,py310 skipsdist=True [testenv] -passenv = HOME SSH_AUTH_SOCK USER +passenv = HOME,SSH_AUTH_SOCK,USER envdir = .virtualenv_run_test commands = pip install -r requirements.txt From 2184b49a07d8c49d85891af950c06f2745cc5b1f Mon Sep 17 00:00:00 2001 From: g6s Date: Tue, 16 Apr 2024 18:11:06 -0600 Subject: [PATCH 3/4] update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 55f1152..38da7ae 100644 --- a/setup.py +++ b/setup.py @@ -53,14 +53,14 @@ def load_requirements(): ), zip_safe=False, install_requires=load_requirements(), - python_requires='>=3.6', + python_requires='>=3.11', project_urls={ 'Website': 'https://magic.link', }, classifiers=[ 'Development Status :: 3 - Alpha', 'Programming Language :: Python', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.11', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', From 0ff5c944506b18009dd17066ddb9a6c8abda1767 Mon Sep 17 00:00:00 2001 From: g6s Date: Tue, 16 Apr 2024 19:00:47 -0600 Subject: [PATCH 4/4] add manifest.in for building package --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f9bd145 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include requirements.txt