From bddd19b898f1742828e84393ae91445a3ddda702 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 May 2024 11:36:18 +0400 Subject: [PATCH] Support Python 3.8+ --- .github/workflows/ci.yml | 7 ++++--- ci.sh | 2 +- setup.py | 5 +++-- src/unasync/__init__.py | 2 +- tests/data/async/fstring.py | 5 +++++ tests/data/sync/fstring.py | 5 +++++ 6 files changed, 19 insertions(+), 7 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..6f81f89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ 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 @@ -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: @@ -49,6 +49,7 @@ jobs: if: "!endsWith(matrix.python, '-dev')" with: python-version: ${{ matrix.python }} + allow-prereleases: true cache: pip cache-dependency-path: test-requirements.txt - name: Setup python (dev) @@ -70,7 +71,7 @@ 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 diff --git a/ci.sh b/ci.sh index 9934548..95b917f 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 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..6358db5 --- /dev/null +++ b/tests/data/sync/fstring.py @@ -0,0 +1,5 @@ +similarity_algo = f""" +if (dotProduct < 0) { + return 1; +} +"""