Skip to content

Commit 1894e00

Browse files
committed
Use travis ci to moderate pylint styles.
1 parent cbe5780 commit 1894e00

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

.lint.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sys
2+
from os import listdir
3+
from os.path import join
4+
5+
from pylint.lint import Run
6+
7+
THRESHOLD = 9.75
8+
9+
cogs = [join('cogs', c) for c in listdir('cogs') if c.endswith('.py')]
10+
core = [join('core', c) for c in listdir('core') if c.endswith('.py')]
11+
12+
results = Run(['bot.py', *cogs, *core],
13+
do_exit=False)
14+
15+
score = results.linter.stats['global_note']
16+
if score <= THRESHOLD:
17+
sys.exit(1)

.pylintrc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ never-returning-functions=sys.exit
121121

122122
# Format style used to check logging format string. `old` means using %
123123
# formatting, while `new` is for `{}` formatting.
124-
logging-format-style=old
124+
logging-format-style=new
125125

126126
# Logging modules to check that the string format arguments are in logging
127127
# function parameter format.
@@ -152,8 +152,8 @@ spelling-store-unknown-words=no
152152

153153
# List of note tags to take in consideration, separated by a comma.
154154
notes=FIXME,
155-
XXX,
156-
TODO
155+
TODO,
156+
BUG
157157

158158

159159
[TYPECHECK]
@@ -351,11 +351,15 @@ good-names=i,
351351
j,
352352
k,
353353
ex,
354-
Run,
355-
_
354+
_,
355+
v,
356+
id,
357+
db,
358+
f,
359+
dt
356360

357361
# Include a hint for the correct naming format with invalid-name.
358-
include-naming-hint=no
362+
include-naming-hint=yes
359363

360364
# Naming style matching correct inline iteration names.
361365
inlinevar-naming-style=any

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
language: python
2+
3+
matrix:
4+
include:
5+
- python: '3.7'
6+
dist: xenial
7+
8+
install:
9+
- pip install -r requirements.txt
10+
- pip install pylint
11+
12+
script: python .lint.py

bot.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,13 @@ async def on_message_edit(self, before, after):
477477
after.content)
478478
break
479479

480-
async def on_command_error(self, ctx, error):
481-
if isinstance(error, (commands.MissingRequiredArgument,
482-
commands.UserInputError)):
483-
await ctx.invoke(self.get_command('help'),
484-
command=str(ctx.command))
480+
async def on_command_error(self, context, exception):
481+
if isinstance(exception, (commands.MissingRequiredArgument,
482+
commands.UserInputError)):
483+
await context.invoke(self.get_command('help'),
484+
command=str(context.command))
485485
else:
486-
raise error
486+
raise exception
487487

488488
@staticmethod
489489
def overwrites(ctx):
@@ -533,10 +533,10 @@ async def validate_api_token(self):
533533
async def validate_database_connection(self):
534534
try:
535535
await self.db.command('buildinfo')
536-
except Exception as e:
536+
except Exception as exc:
537537
print(Fore.RED, end='')
538538
print('Something went wrong while connecting to the database.')
539-
print(type(e).__name__, e, sep=': ')
539+
print(type(exc).__name__, exc, sep=': ')
540540
return await self.logout()
541541
else:
542542
print(Style.RESET_ALL + Fore.CYAN +

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ sanic==18.12.0
1313
dnspython==1.16.0
1414
aiohttp==3.4.4
1515
pymongo==3.7.2
16-
uvloop==0.12.0
17-
pylint==2.2.2
16+
uvloop==0.12.0

0 commit comments

Comments
 (0)