Skip to content

Commit d24c221

Browse files
committed
Fix lint errors and make sure flake8 actually runs on CI
1 parent 6581e58 commit d24c221

File tree

8 files changed

+30
-24
lines changed

8 files changed

+30
-24
lines changed

.ci/package-version.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77

88
def main():
9-
version_file = os.path.join(os.path.dirname(os.path.dirname(__file__)),
10-
'asyncpg', '__init__.py')
9+
version_file = os.path.join(
10+
os.path.dirname(os.path.dirname(__file__)), 'asyncpg', '__init__.py')
1111

1212
with open(version_file, 'r') as f:
1313
for line in f:
@@ -16,7 +16,8 @@ def main():
1616
print(version.strip(" \n'\""))
1717
return 0
1818

19-
print('could not find package version in asyncpg/__init__.py', file=sys.stderr)
19+
print('could not find package version in asyncpg/__init__.py',
20+
file=sys.stderr)
2021
return 1
2122

2223

.ci/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cython>=0.24
2+
flake8>=3.4.1
23
uvloop>=0.5.0
34
tinys3
45
twine

.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[flake8]
22
ignore = E402,E731
3-
exclude = .git,__pycache__,build,dist,.eggs
3+
exclude = .git,__pycache__,build,dist,.eggs,.github

asyncpg/connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ async def _do_execute(self, query, executor, timeout, retry=True):
12381238
after = time.monotonic()
12391239
timeout -= after - before
12401240

1241-
except exceptions.InvalidCachedStatementError as e:
1241+
except exceptions.InvalidCachedStatementError:
12421242
# PostgreSQL will raise an exception when it detects
12431243
# that the result type of the query has changed from
12441244
# when the statement was prepared. This may happen,

docs/conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
version = version.strip(" \n'\"")
1717
break
1818
else:
19-
raise RuntimeError('unable to read the version from asyncpg/__init__.py')
19+
raise RuntimeError(
20+
'unable to read the version from asyncpg/__init__.py')
2021

2122
# -- General configuration ------------------------------------------------
2223

setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,16 @@ def _patch_cfile(self, cfile):
180180
readme = f.read()
181181

182182

183-
with open(os.path.join(os.path.dirname(__file__), 'asyncpg', '__init__.py')) as f:
183+
with open(os.path.join(
184+
os.path.dirname(__file__), 'asyncpg', '__init__.py')) as f:
184185
for line in f:
185186
if line.startswith('__version__ ='):
186187
_, _, version = line.partition('=')
187188
VERSION = version.strip(" \n'\"")
188189
break
189190
else:
190-
raise RuntimeError('unable to read the version from asyncpg/__init__.py')
191+
raise RuntimeError(
192+
'unable to read the version from asyncpg/__init__.py')
191193

192194

193195
setuptools.setup(

tests/test__sourcecode.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ def test_flake8(self):
2727
except ImportError:
2828
raise unittest.SkipTest('flake8 module is missing')
2929

30-
for subdir in ['asyncpg', 'tests']:
31-
try:
32-
subprocess.run(
33-
[sys.executable, '-m', 'flake8', '--config', config_path],
34-
check=True,
35-
stdout=subprocess.PIPE,
36-
stderr=subprocess.PIPE,
37-
cwd=os.path.join(root_path, subdir))
38-
except subprocess.CalledProcessError as ex:
39-
output = ex.output.decode()
40-
raise AssertionError(
41-
'flake8 validation failed:\n{}'.format(output)) from None
30+
try:
31+
subprocess.run(
32+
[sys.executable, '-m', 'flake8', '--config', config_path],
33+
check=True,
34+
stdout=subprocess.PIPE,
35+
stderr=subprocess.STDOUT,
36+
cwd=root_path)
37+
except subprocess.CalledProcessError as ex:
38+
output = ex.output.decode()
39+
raise AssertionError(
40+
'flake8 validation failed:\n{}'.format(output)) from None

tools/generate_type_map.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ async def runner(args):
2828
conn = await asyncpg.connect(host=args.pghost, port=args.pgport,
2929
user=args.pguser)
3030

31-
buf = '# GENERATED FROM pg_catalog.pg_type\n' + \
32-
'# DO NOT MODIFY, use tools/generate_type_map.py to update\n\n' + \
33-
'DEF INVALIDOID = {}\nDEF MAXBUILTINOID = {}\n'.format(
34-
_INVALIDOID, _MAXBUILTINOID)
31+
buf = (
32+
'# GENERATED FROM pg_catalog.pg_type\n' +
33+
'# DO NOT MODIFY, use tools/generate_type_map.py to update\n\n' +
34+
'DEF INVALIDOID = {}\n'.format(_INVALIDOID) +
35+
'DEF MAXBUILTINOID = {}\n'.format(_MAXBUILTINOID)
36+
)
3537

3638
pg_types = await conn.fetch('''
3739
SELECT

0 commit comments

Comments
 (0)