Skip to content

Commit

Permalink
Merge branch 'master' into unasync-remove
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 authored Aug 2, 2024
2 parents 415991b + 3d7a369 commit 2c92ed6
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 29 deletions.
25 changes: 10 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['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
Expand All @@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['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:
Expand All @@ -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/[email protected]
if: endsWith(matrix.python, '-dev')
with:
python-version: '${{ matrix.python }}'
- name: Run tests
run: ./ci.sh
env:
Expand All @@ -70,12 +65,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['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
Expand Down
16 changes: 9 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -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: .
6 changes: 2 additions & 4 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ex

BLACK_VERSION=22.6.0
BLACK_VERSION=24.4.2

python -m pip install -U pip setuptools wheel

Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions docs/source/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.8",
classifiers=[
Expand All @@ -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",
],
Expand Down
2 changes: 2 additions & 0 deletions src/unasync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _unasync_file(self, filepath):
with open(filepath, "rt", encoding=encoding) as f:
contents = f.read()
tokens = self._unasync_tokenize(contents=contents, filename=filepath)
tokens = self._unasync_tokens(tokens)
result = tokenize_rt.tokens_to_src(tokens)
outfilepath = filepath.replace(self.fromdir, self.todir)
os.makedirs(os.path.dirname(outfilepath), exist_ok=True)
Expand Down Expand Up @@ -100,6 +101,7 @@ def _unasync_tokenize(self, contents, filename):
# find all lines related to each node and mark those lines for removal
lines_to_remove.add(lineno)

def _unasync_tokens(self, tokens):
skip_next = False
for token in tokens:
if token.line in lines_to_remove:
Expand Down
2 changes: 1 addition & 1 deletion src/unasync/_version.py
Original file line number Diff line number Diff line change
@@ -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+dev"
5 changes: 5 additions & 0 deletions tests/data/async/fstring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
similarity_algo = f"""
if (dotProduct < 0) {{
return 1;
}}
"""
5 changes: 5 additions & 0 deletions tests/data/sync/fstring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
similarity_algo = f"""
if (dotProduct < 0) {{
return 1;
}}
"""

0 comments on commit 2c92ed6

Please sign in to comment.