Skip to content

Commit 32c4edb

Browse files
committed
apply black formatting
1 parent 4d6f917 commit 32c4edb

File tree

4 files changed

+31
-40
lines changed

4 files changed

+31
-40
lines changed

src/unasync/__init__.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,19 @@ def _unasync_tokenize(self, contents, filename):
8383
comment_lines_locations = []
8484
for token in tokens:
8585
# find line numbers where "unasync: remove" comments are found
86-
if token.name == 'COMMENT' and 'unasync: remove' in token.src: # XXX: maybe make this a little more strict
86+
if (
87+
token.name == "COMMENT" and "unasync: remove" in token.src
88+
): # XXX: maybe make this a little more strict
8789
comment_lines_locations.append(token.line)
8890

8991
lines_to_remove = set()
90-
if comment_lines_locations: # only parse ast if we actually have "unasync: remove" comments
92+
if (
93+
comment_lines_locations
94+
): # only parse ast if we actually have "unasync: remove" comments
9195
tree = ast.parse(contents, filename=filename)
9296
for node in ast.walk(tree):
9397
# find nodes whose line number (start line) intersect with unasync: remove comments
94-
if hasattr(node, 'lineno') and node.lineno in comment_lines_locations:
98+
if hasattr(node, "lineno") and node.lineno in comment_lines_locations:
9599
for lineno in range(node.lineno, node.end_lineno + 1):
96100
# find all lines related to each node and mark those lines for removal
97101
lines_to_remove.add(lineno)

tests/data/async/removals.py

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
from common import (
2-
a, b , c # these should stick around
3-
)
1+
from common import a, b, c # these should stick around
42

53
# these imports should be removed
6-
from async_only import ( # unasync: remove
7-
async_a, async_b,
8-
async_c
9-
)
4+
from async_only import async_a, async_b, async_c # unasync: remove
5+
6+
CONST = "foo"
7+
ASYNC_CONST = "bar" # unasync: remove
108

11-
CONST = 'foo'
12-
ASYNC_CONST = 'bar' # unasync: remove
139

1410
async def foo():
15-
print('this function should stick around')
11+
print("this function should stick around")
12+
1613

17-
async def async_only(): # unasync: remove
18-
print('this function will be removed entirely')
14+
async def async_only(): # unasync: remove
15+
print("this function will be removed entirely")
1916

2017

21-
class AsyncOnly: # unasync: remove
18+
class AsyncOnly: # unasync: remove
2219
async def foo(self):
23-
print('the entire class should be removed')
20+
print("the entire class should be removed")
2421

2522

2623
class Foo:
2724
async def foobar(self):
28-
print('This method should stick around')
25+
print("This method should stick around")
2926

30-
async def async_only_method(self): # unasync: remove
31-
print('only this method should be removed')
27+
async def async_only_method(self): # unasync: remove
28+
print("only this method should be removed")
3229

3330
async def another_method(self):
34-
print('This line should stick around')
35-
await self.something("the content in this line should be removed") # unasync: remove
36-
31+
print("This line should stick around")
32+
await self.something( # unasync: remove
33+
"the content in this line should be removed"
34+
)

tests/data/sync/removals.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
from common import (
2-
a, b , c # these should stick around
3-
)
1+
from common import a, b, c # these should stick around
42

53
# these imports should be removed
64

7-
CONST = 'foo'
8-
9-
def foo():
10-
print('this function should stick around')
11-
5+
CONST = "foo"
126

137

8+
def foo():
9+
print("this function should stick around")
1410

1511

1612
class Foo:
1713
def foobar(self):
18-
print('This method should stick around')
19-
14+
print("This method should stick around")
2015

2116
def another_method(self):
22-
print('This line should stick around')
23-
17+
print("This line should stick around")

tests/test_unasync.py

-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def test_rule_on_short_path():
3535

3636
@pytest.mark.parametrize("source_file", TEST_FILES)
3737
def test_unasync(tmpdir, source_file):
38-
3938
rule = unasync.Rule(fromdir=ASYNC_DIR, todir=str(tmpdir))
4039
rule._unasync_file(os.path.join(ASYNC_DIR, source_file))
4140

@@ -64,7 +63,6 @@ def test_unasync_files(tmpdir):
6463

6564

6665
def test_build_py_modules(tmpdir):
67-
6866
source_modules_dir = os.path.join(TEST_DIR, "example_mod")
6967
mod_dir = str(tmpdir) + "/" + "example_mod"
7068
shutil.copytree(source_modules_dir, mod_dir)
@@ -84,7 +82,6 @@ def test_build_py_modules(tmpdir):
8482

8583

8684
def test_build_py_packages(tmpdir):
87-
8885
source_pkg_dir = os.path.join(TEST_DIR, "example_pkg")
8986
pkg_dir = str(tmpdir) + "/" + "example_pkg"
9087
shutil.copytree(source_pkg_dir, pkg_dir)
@@ -101,7 +98,6 @@ def test_build_py_packages(tmpdir):
10198

10299

103100
def test_project_structure_after_build_py_packages(tmpdir):
104-
105101
source_pkg_dir = os.path.join(TEST_DIR, "example_pkg")
106102
pkg_dir = str(tmpdir) + "/" + "example_pkg"
107103
shutil.copytree(source_pkg_dir, pkg_dir)
@@ -121,7 +117,6 @@ def test_project_structure_after_build_py_packages(tmpdir):
121117

122118

123119
def test_project_structure_after_customized_build_py_packages(tmpdir):
124-
125120
source_pkg_dir = os.path.join(TEST_DIR, "example_custom_pkg")
126121
pkg_dir = str(tmpdir) + "/" + "example_custom_pkg"
127122
shutil.copytree(source_pkg_dir, pkg_dir)

0 commit comments

Comments
 (0)