From 9268f55b144e84e6543184de4cc2c150f27a1ad7 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 May 2024 11:58:51 +0400 Subject: [PATCH 1/4] Support Python 3.8 - 3.12 (#80) --- .github/workflows/ci.yml | 25 ++++++++++--------------- .readthedocs.yml | 16 +++++++++------- ci.sh | 6 ++---- setup.py | 5 +++-- src/unasync/__init__.py | 2 +- tests/data/async/fstring.py | 5 +++++ tests/data/sync/fstring.py | 5 +++++ 7 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 tests/data/async/fstring.py create mode 100644 tests/data/sync/fstring.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 518b8c3..2ad8243 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,13 +9,13 @@ jobs: strategy: fail-fast: false matrix: - python: ['3.7', '3.8', '3.9', '3.10'] + python: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} cache: pip @@ -34,7 +34,7 @@ jobs: strategy: fail-fast: false matrix: - python: ['3.7', '3.8', '3.9', '3.10', '3.11-dev'] + python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] check_formatting: ['0'] extra_name: [''] include: @@ -43,19 +43,14 @@ jobs: extra_name: ', check formatting' steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 - if: "!endsWith(matrix.python, '-dev')" + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} + allow-prereleases: true cache: pip cache-dependency-path: test-requirements.txt - - name: Setup python (dev) - uses: deadsnakes/action@v2.0.2 - if: endsWith(matrix.python, '-dev') - with: - python-version: '${{ matrix.python }}' - name: Run tests run: ./ci.sh env: @@ -70,12 +65,12 @@ jobs: strategy: fail-fast: false matrix: - python: ['3.7', '3.8', '3.9', '3.10'] + python: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} cache: pip diff --git a/.readthedocs.yml b/.readthedocs.yml index da6abdf..917704b 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,10 +1,12 @@ -# https://docs.readthedocs.io/en/latest/yaml-config.html -formats: - - htmlzip - - epub +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.12" -requirements_file: ci/rtd-requirements.txt python: - version: 3 - pip_install: True + install: + - requirements: ci/rtd-requirements.txt + - path: . diff --git a/ci.sh b/ci.sh index 9934548..abf5b67 100755 --- a/ci.sh +++ b/ci.sh @@ -2,7 +2,7 @@ set -ex -BLACK_VERSION=22.6.0 +BLACK_VERSION=24.4.2 python -m pip install -U pip setuptools wheel @@ -55,6 +55,4 @@ fi # Actual tests pip install -Ur test-requirements.txt -pytest -W error -ra -v tests --cov --cov-config=.coveragerc - -bash <(curl -s https://codecov.io/bash) +pytest -W error -ra -v tests --cov --cov-config=.coveragerc --cov-fail-under=93 diff --git a/setup.py b/setup.py index 88f3ecc..32c15df 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ include_package_data=True, packages=find_packages("src"), package_dir={"": "src"}, - install_requires=["tokenize_rt"], + install_requires=["tokenize_rt", "setuptools"], keywords=["async"], python_requires=">=3.7", classifiers=[ @@ -27,10 +27,11 @@ "Operating System :: POSIX :: Linux", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ], diff --git a/src/unasync/__init__.py b/src/unasync/__init__.py index ffc9205..e669b9a 100644 --- a/src/unasync/__init__.py +++ b/src/unasync/__init__.py @@ -67,7 +67,7 @@ def _unasync_file(self, filepath): with open(filepath, "rb") as f: encoding, _ = std_tokenize.detect_encoding(f.readline) - with open(filepath, "rt", encoding=encoding) as f: + with open(filepath, encoding=encoding) as f: tokens = tokenize_rt.src_to_tokens(f.read()) tokens = self._unasync_tokens(tokens) result = tokenize_rt.tokens_to_src(tokens) diff --git a/tests/data/async/fstring.py b/tests/data/async/fstring.py new file mode 100644 index 0000000..e58f2c8 --- /dev/null +++ b/tests/data/async/fstring.py @@ -0,0 +1,5 @@ +similarity_algo = f""" +if (dotProduct < 0) {{ + return 1; +}} +""" diff --git a/tests/data/sync/fstring.py b/tests/data/sync/fstring.py new file mode 100644 index 0000000..e58f2c8 --- /dev/null +++ b/tests/data/sync/fstring.py @@ -0,0 +1,5 @@ +similarity_algo = f""" +if (dotProduct < 0) {{ + return 1; +}} +""" From 3c49b09c236ec524f18a54fcf85af02d86e1d28c Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 May 2024 14:55:54 +0400 Subject: [PATCH 2/4] Fix python_requires value --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 32c15df..16e3ec4 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ package_dir={"": "src"}, install_requires=["tokenize_rt", "setuptools"], keywords=["async"], - python_requires=">=3.7", + python_requires=">=3.8", classifiers=[ "License :: OSI Approved :: MIT License", "License :: OSI Approved :: Apache Software License", From 2f6d97d8ddb745f16d80068e869d74b6349ee163 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 May 2024 15:01:59 +0400 Subject: [PATCH 3/4] Release 0.6.0 --- docs/source/history.rst | 8 ++++++++ src/unasync/_version.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 6b4518c..30e8d37 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -4,3 +4,11 @@ Release history .. currentmodule:: unasync .. towncrier release notes start + +unasync 0.6.0 (2024-05-03) +-------------------------- + +* Drop support for Python 2.7, 3.5, 3.6 and 3.7 +* Add support for Python 3.9, 3.10, 3.11 and 3.12 +* Replace ``tokenize`` with ``tokenize-rt`` which roundtrips correctly and + handles Python 3.12 f-strings correctly. diff --git a/src/unasync/_version.py b/src/unasync/_version.py index 0a95219..ae10048 100644 --- a/src/unasync/_version.py +++ b/src/unasync/_version.py @@ -1,3 +1,3 @@ # This file is imported from __init__.py and exec'd from setup.py -__version__ = "0.5.0+dev" +__version__ = "0.6.0" From 34703c6dd902906f39ea6d06ea8e3f4ba887cb84 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 May 2024 15:15:49 +0400 Subject: [PATCH 4/4] Bump version to 0.6.0+dev --- src/unasync/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unasync/_version.py b/src/unasync/_version.py index ae10048..dff3253 100644 --- a/src/unasync/_version.py +++ b/src/unasync/_version.py @@ -1,3 +1,3 @@ # This file is imported from __init__.py and exec'd from setup.py -__version__ = "0.6.0" +__version__ = "0.6.0+dev"