Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite9d2a40

Browse files
committed
improve hooks/pre-commit, fix warnings found by flake8
1 parent6596a9f commite9d2a40

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

‎hooks/pre-commit

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
#!/bin/bash
22

3+
set -e
4+
35
# capture the changed files that have been staged
46
changed_files=$(git diff --staged --name-only)
57

68
forfilein${changed_files}
79
do
810
if [["${file##*.}"=="py" ]];then
9-
echo"Yapfing${file}"
10-
yapf${file} -i
11-
git add${file}
11+
ifcommand -v yapf> /dev/null;then
12+
echo"Run yapf on${file}"
13+
yapf${file} -i
14+
git add${file}
15+
fi
16+
17+
ifcommand -v flake8> /dev/null;then
18+
echo"Run flake8 on${file}"
19+
flake8${file}
20+
fi
1221
fi
1322
done
23+

‎tests/test_simple.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646

4747
defutil_exists(util):
4848
defgood_properties(f):
49-
return (os.path.exists(f)and
50-
os.path.isfile(f)and
49+
return (os.path.exists(f)and# noqa: W504
50+
os.path.isfile(f)and# noqa: W504
5151
os.access(f,os.X_OK))# yapf: disable
5252

5353
# try to resolve it
@@ -72,7 +72,7 @@ def removing(f):
7272
classTestgresTests(unittest.TestCase):
7373
deftest_node_repr(self):
7474
withget_new_node()asnode:
75-
pattern='PostgresNode\(name=\'.+\', port=.+, base_dir=\'.+\'\)'
75+
pattern=r"PostgresNode\(name='.+', port=.+, base_dir='.+'\)"
7676
self.assertIsNotNone(re.match(pattern,str(node)))
7777

7878
deftest_custom_init(self):
@@ -263,7 +263,7 @@ def test_psql(self):
263263
# check feeding input
264264
node.safe_psql('create table horns (w int)')
265265
node.safe_psql(
266-
'copy horns from stdin (format csv)',input=b"1\n2\n3\n\.\n")
266+
'copy horns from stdin (format csv)',input=b"1\n2\n3\n\\.\n")
267267
_sum=node.safe_psql('select sum(w) from horns')
268268
self.assertEqual(_sum,b'6\n')
269269

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp