Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 0 additions & 180 deletions .style.yapf

This file was deleted.

82 changes: 0 additions & 82 deletions CHEATSHEET.rst

This file was deleted.

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include README.rst CHEATSHEET.rst LICENSE* CODE_OF_CONDUCT* CONTRIBUTING*
include .coveragerc .style.yapf
include .coveragerc
include test-requirements.txt
recursive-include docs *
recursive-include tests *
Expand Down
10 changes: 4 additions & 6 deletions ci/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

set -ex

YAPF_VERSION=0.22.0

if [ "$TRAVIS_OS_NAME" = "osx" ]; then
curl -Lo macpython.pkg https://www.python.org/ftp/python/${MACPYTHON}/python-${MACPYTHON}-macosx10.6.pkg
sudo installer -pkg macpython.pkg -target /
Expand Down Expand Up @@ -56,16 +54,16 @@ fi
pip install -U pip setuptools wheel

if [ "$CHECK_FORMATTING" = "1" ]; then
pip install yapf==${YAPF_VERSION}
if ! yapf -rpd setup.py src tests; then
pip install black
if ! black --diff setup.py src tests; then
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Formatting problems were found (listed above). To fix them, run

pip install yapf==${YAPF_VERSION}
yapf -rpi setup.py src tests
pip install black
black setup.py src tests

in your local checkout.

Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
description="The async transformation code.",
url="https://github.com/RatanShreshtha/unasync",
long_description=LONG_DESC,
long_description_content_type='text/x-rst',
long_description_content_type="text/x-rst",
author="Ratan Kulshreshtha",
author_email="ratan.shreshtha@gmail.com",
license="MIT -or- Apache License 2.0",
include_package_data=True,
packages=find_packages('src'),
package_dir={'': 'src'},
packages=find_packages("src"),
package_dir={"": "src"},
install_requires=[],
keywords=['async'],
keywords=["async"],
python_requires=">=3.5",
classifiers=[
"License :: OSI Approved :: MIT License",
Expand Down
28 changes: 14 additions & 14 deletions src/unasync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from tokenize import NAME, NEWLINE, NL, STRING, ENCODING

ASYNC_TO_SYNC = {
'__aenter__': '__enter__',
'__aexit__': '__exit__',
'__aiter__': '__iter__',
'__anext__': '__next__',
"__aenter__": "__enter__",
"__aexit__": "__exit__",
"__aiter__": "__iter__",
"__anext__": "__next__",
# TODO StopIteration is still accepted in Python 2, but the right change
# is 'raise StopAsyncIteration' -> 'return' since we want to use unasynced
# code in Python 3.7+
'StopAsyncIteration': 'StopIteration',
"StopAsyncIteration": "StopIteration",
}


Expand All @@ -27,13 +27,13 @@ def tokenize(f):
continue

if last_end[0] < tok.start[0]:
yield ('', STRING, ' \\\n')
yield ("", STRING, " \\\n")
last_end = (tok.start[0], 0)

space = ''
space = ""
if tok.start > last_end:
assert tok.start[0] == last_end[0]
space = ' ' * (tok.start[1] - last_end[1])
space = " " * (tok.start[1] - last_end[1])
yield (space, tok.type, tok.string)

last_end = tok.end
Expand Down Expand Up @@ -61,20 +61,20 @@ def unasync_tokens(tokens):


def untokenize(tokens):
return ''.join(space + tokval for space, tokval in tokens)
return "".join(space + tokval for space, tokval in tokens)


def unasync_file(filepath, fromdir, todir):
with open(filepath, 'rb') as f:
with open(filepath, "rb") as f:
encoding, _ = std_tokenize.detect_encoding(f.readline)
f.seek(0)
tokens = tokenize(f)
tokens = unasync_tokens(tokens)
result = untokenize(tokens)
outfilepath = filepath.replace(fromdir, todir)
os.makedirs(os.path.dirname(outfilepath), exist_ok=True)
with open(outfilepath, 'w', encoding=encoding) as f:
print(result, file=f, end='')
with open(outfilepath, "w", encoding=encoding) as f:
print(result, file=f, end="")


class build_py(build_py):
Expand All @@ -94,8 +94,8 @@ def run(self):
self.build_package_data()

for f in self._updated_files:
if os.sep + '_async' + os.sep in f:
unasync_file(f, '_async', '_sync')
if os.sep + "_async" + os.sep in f:
unasync_file(f, "_async", "_sync")

# Remaining base class code
self.byte_compile(self.get_outputs(include_bytecode=0))
Expand Down
Loading