Skip to content

Commit e9d2a40

Browse files
committed
improve hooks/pre-commit, fix warnings found by flake8
1 parent 6596a9f commit e9d2a40

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
for file in ${changed_files}
79
do
810
if [[ "${file##*.}" == "py" ]]; then
9-
echo "Yapfing ${file}"
10-
yapf ${file} -i
11-
git add ${file}
11+
if command -v yapf > /dev/null; then
12+
echo "Run yapf on ${file}"
13+
yapf ${file} -i
14+
git add ${file}
15+
fi
16+
17+
if command -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
def util_exists(util):
4848
def good_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
class TestgresTests(unittest.TestCase):
7373
def test_node_repr(self):
7474
with get_new_node() as node:
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
def test_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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy