Skip to content

Commit 0dbe2fa

Browse files
authored
Merge pull request #29 from RatanShreshtha/black
Added formatting with black instead of yapf
2 parents a73a26c + 9dffed2 commit 0dbe2fa

File tree

8 files changed

+32
-302
lines changed

8 files changed

+32
-302
lines changed

.style.yapf

Lines changed: 0 additions & 180 deletions
This file was deleted.

CHEATSHEET.rst

Lines changed: 0 additions & 82 deletions
This file was deleted.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include README.rst CHEATSHEET.rst LICENSE* CODE_OF_CONDUCT* CONTRIBUTING*
2-
include .coveragerc .style.yapf
2+
include .coveragerc
33
include test-requirements.txt
44
recursive-include docs *
55
recursive-include tests *

ci/travis.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
set -ex
44

5-
YAPF_VERSION=0.22.0
6-
75
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
86
curl -Lo macpython.pkg https://www.python.org/ftp/python/${MACPYTHON}/python-${MACPYTHON}-macosx10.6.pkg
97
sudo installer -pkg macpython.pkg -target /
@@ -56,16 +54,16 @@ fi
5654
pip install -U pip setuptools wheel
5755

5856
if [ "$CHECK_FORMATTING" = "1" ]; then
59-
pip install yapf==${YAPF_VERSION}
60-
if ! yapf -rpd setup.py src tests; then
57+
pip install black
58+
if ! black --diff setup.py src tests; then
6159
cat <<EOF
6260
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6361
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6462
6563
Formatting problems were found (listed above). To fix them, run
6664
67-
pip install yapf==${YAPF_VERSION}
68-
yapf -rpi setup.py src tests
65+
pip install black
66+
black setup.py src tests
6967
7068
in your local checkout.
7169

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
description="The async transformation code.",
1111
url="https://github.com/RatanShreshtha/unasync",
1212
long_description=LONG_DESC,
13-
long_description_content_type='text/x-rst',
13+
long_description_content_type="text/x-rst",
1414
author="Ratan Kulshreshtha",
1515
author_email="ratan.shreshtha@gmail.com",
1616
license="MIT -or- Apache License 2.0",
1717
include_package_data=True,
18-
packages=find_packages('src'),
19-
package_dir={'': 'src'},
18+
packages=find_packages("src"),
19+
package_dir={"": "src"},
2020
install_requires=[],
21-
keywords=['async'],
21+
keywords=["async"],
2222
python_requires=">=3.5",
2323
classifiers=[
2424
"License :: OSI Approved :: MIT License",

src/unasync/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
from tokenize import NAME, NEWLINE, NL, STRING, ENCODING
1010

1111
ASYNC_TO_SYNC = {
12-
'__aenter__': '__enter__',
13-
'__aexit__': '__exit__',
14-
'__aiter__': '__iter__',
15-
'__anext__': '__next__',
12+
"__aenter__": "__enter__",
13+
"__aexit__": "__exit__",
14+
"__aiter__": "__iter__",
15+
"__anext__": "__next__",
1616
# TODO StopIteration is still accepted in Python 2, but the right change
1717
# is 'raise StopAsyncIteration' -> 'return' since we want to use unasynced
1818
# code in Python 3.7+
19-
'StopAsyncIteration': 'StopIteration',
19+
"StopAsyncIteration": "StopIteration",
2020
}
2121

2222

@@ -27,13 +27,13 @@ def tokenize(f):
2727
continue
2828

2929
if last_end[0] < tok.start[0]:
30-
yield ('', STRING, ' \\\n')
30+
yield ("", STRING, " \\\n")
3131
last_end = (tok.start[0], 0)
3232

33-
space = ''
33+
space = ""
3434
if tok.start > last_end:
3535
assert tok.start[0] == last_end[0]
36-
space = ' ' * (tok.start[1] - last_end[1])
36+
space = " " * (tok.start[1] - last_end[1])
3737
yield (space, tok.type, tok.string)
3838

3939
last_end = tok.end
@@ -61,20 +61,20 @@ def unasync_tokens(tokens):
6161

6262

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

6666

6767
def unasync_file(filepath, fromdir, todir):
68-
with open(filepath, 'rb') as f:
68+
with open(filepath, "rb") as f:
6969
encoding, _ = std_tokenize.detect_encoding(f.readline)
7070
f.seek(0)
7171
tokens = tokenize(f)
7272
tokens = unasync_tokens(tokens)
7373
result = untokenize(tokens)
7474
outfilepath = filepath.replace(fromdir, todir)
7575
os.makedirs(os.path.dirname(outfilepath), exist_ok=True)
76-
with open(outfilepath, 'w', encoding=encoding) as f:
77-
print(result, file=f, end='')
76+
with open(outfilepath, "w", encoding=encoding) as f:
77+
print(result, file=f, end="")
7878

7979

8080
class build_py(build_py):
@@ -94,8 +94,8 @@ def run(self):
9494
self.build_package_data()
9595

9696
for f in self._updated_files:
97-
if os.sep + '_async' + os.sep in f:
98-
unasync_file(f, '_async', '_sync')
97+
if os.sep + "_async" + os.sep in f:
98+
unasync_file(f, "_async", "_sync")
9999

100100
# Remaining base class code
101101
self.byte_compile(self.get_outputs(include_bytecode=0))

0 commit comments

Comments
 (0)