Skip to content

Commit 14b1e32

Browse files
committed
apply black formatting
1 parent 01b2c8a commit 14b1e32

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
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

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# isort: skip_file
2+
# fmt: off
13
from common import (
24
a, b , c # these should stick around
35
)
@@ -34,3 +36,4 @@ async def another_method(self):
3436
print('This line should stick around')
3537
await self.something("the content in this line should be removed") # unasync: remove
3638

39+
# fmt: on

tests/data/sync/removals.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# isort: skip_file
2+
# fmt: off
13
from common import (
24
a, b , c # these should stick around
35
)
@@ -21,3 +23,4 @@ def foobar(self):
2123
def another_method(self):
2224
print('This line should stick around')
2325

26+
# fmt: on

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)