Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

WIP Clean up and fix various pylint issues #458

Open
wants to merge 36 commits into
base: gonzobot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0a1ae02
Clean up inconsistent continuation indents
linuxdaemon Feb 19, 2019
446c51f
Enable some of the pylint checks we don't need disabled
linuxdaemon Feb 19, 2019
1d4d4ac
Fix redefining outer names
linuxdaemon Feb 19, 2019
0eda0b8
Remove trailing whitespace
linuxdaemon Feb 19, 2019
ae626a5
Remove useless-object-inheritance
linuxdaemon Feb 19, 2019
93c5fe9
Remove superfluous parens
linuxdaemon Feb 19, 2019
b6f8130
Clean up duplicate format arguments
linuxdaemon Feb 19, 2019
38ca8a0
Fix implicit string concat in sequence literals
linuxdaemon Feb 19, 2019
c7440aa
Simplify if expressions
linuxdaemon Feb 19, 2019
67cf40a
Clean up if guards in duckhunt
linuxdaemon Feb 19, 2019
5d61323
Clean up if guards in brainfuck
linuxdaemon Feb 19, 2019
c2c6ce0
Clean up inconsistent return logic
linuxdaemon Feb 19, 2019
e19b79f
Add _cb suffix to sieves, remove unused parameters
linuxdaemon Feb 19, 2019
dec4eb1
Implement missing abstract methods
linuxdaemon Feb 19, 2019
87985ce
Clean up differing argument names in overloads
linuxdaemon Feb 19, 2019
f00ca49
Fix import orders
linuxdaemon Feb 20, 2019
d88319c
Remove broad excepts in quote.py
linuxdaemon Feb 20, 2019
4575f00
Clean up methods with no self use
linuxdaemon Feb 20, 2019
4181210
Clean up broad except statements
linuxdaemon Feb 20, 2019
59885e2
Remove locally-disabled check disable
linuxdaemon Feb 20, 2019
d67a445
Reorder pylint disabled checks
linuxdaemon Feb 20, 2019
4ab958f
Move subcmd logic in notes.py to separate functions
linuxdaemon Feb 21, 2019
3fe3a02
Split CTCP formatting to separate function in log.py
linuxdaemon Feb 21, 2019
20277cf
Collapse duplicate pluralize logic
linuxdaemon Feb 21, 2019
a47aaf1
Clean up subcmds in duckhunt
linuxdaemon Feb 21, 2019
39a6bc9
Enable too many return statements check
linuxdaemon Feb 21, 2019
443d4b0
Split up parsing and message handling in clients/irc.py
linuxdaemon Feb 21, 2019
fd50357
Fix elseif logic and structures
linuxdaemon Mar 9, 2019
8dbc201
Enable basic extended pylint checks
linuxdaemon Mar 9, 2019
8abb13b
Remove comparisons to empty string
linuxdaemon Mar 9, 2019
96d210f
Clean up overlapping exception types
linuxdaemon Mar 9, 2019
89b4238
Remove redefinitions of variables
linuxdaemon Mar 9, 2019
4f34691
Replace map() with list comprehensions
linuxdaemon Mar 9, 2019
86bfc05
Disable false-positive invalid-sequence-index
linuxdaemon Jun 29, 2019
cd8c8c7
Clean up long lines
linuxdaemon Jun 29, 2019
c278a63
Use compound assignment when needed
linuxdaemon Jun 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ignore-patterns=

# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=1
jobs=0

# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
Expand All @@ -28,7 +28,11 @@ limit-inference-results=100

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
load-plugins=pylint.extensions.check_elif,
pylint.extensions.bad_builtin,
pylint.extensions.redefined_variable_type,
pylint.extensions.overlapping_exceptions,
pylint.extensions.emptystring,

# Pickle collected data for later comparisons.
persistent=yes
Expand Down Expand Up @@ -62,33 +66,14 @@ confidence=
# --disable=W".
disable=invalid-name,
missing-docstring,
ungrouped-imports,
too-few-public-methods,
too-many-arguments,
too-many-locals,
too-few-public-methods,
too-many-return-statements,
inconsistent-return-statements,
redefined-outer-name,
too-many-branches,
unused-argument,
broad-except,
too-many-instance-attributes,
no-self-use,
ungrouped-imports,
too-many-statements,
wrong-import-position,
trailing-whitespace,
useless-object-inheritance,
no-name-in-module,
superfluous-parens,
function-redefined,
too-many-ancestors,
arguments-differ,
duplicate-string-formatting-argument,
simplifiable-if-expression,
implicit-str-concat-in-sequence,
abstract-method,
literal-comparison,
protected-access

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -472,7 +457,7 @@ max-parents=7
max-public-methods=20

# Maximum number of return / yield for function / method body.
max-returns=6
max-returns=8

# Maximum number of statements in function / method body.
max-statements=50
Expand Down
9 changes: 4 additions & 5 deletions cloudbot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import json
import logging
import logging.config
import os
import sys

# check python version
if sys.version_info < (3, 5, 0):
print("CloudBot requires Python 3.5 or newer.")
sys.exit(1)

import json
import logging.config
import logging
import os

__version__ = "1.0.9"

__all__ = ["clients", "util", "bot", "client", "config", "event", "hook", "permissions", "plugin", "reloader",
Expand Down
12 changes: 6 additions & 6 deletions cloudbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
sys.path.insert(0, str(install_dir))
os.chdir(str(install_dir))

# import bot
from cloudbot.bot import CloudBot
from cloudbot.util import async_util


def main():
# import bot
from cloudbot.bot import CloudBot
from cloudbot.util import async_util

# Logging optimizations, doing it here because we only want to change this if we're the main file
logging._srcfile = None
logging.logThreads = 0
Expand All @@ -42,7 +42,7 @@ def main():
# The handler is called with two arguments: the signal number and the current stack frame
# These parameters should NOT be removed
# noinspection PyUnusedLocal
def exit_gracefully(signum, frame):
def exit_gracefully_cb(signum, frame):
nonlocal stopped_while_restarting
if not _bot:
# we are currently in the process of restarting
Expand All @@ -55,7 +55,7 @@ def exit_gracefully(signum, frame):
# restore the original handler so if they do it again it triggers
signal.signal(signal.SIGINT, original_sigint)

signal.signal(signal.SIGINT, exit_gracefully)
signal.signal(signal.SIGINT, exit_gracefully_cb)

# start the bot master

Expand Down
3 changes: 2 additions & 1 deletion cloudbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ def run(self):
self.loop.close()
return restart

def get_client(self, name: str) -> Type[Client]:
@staticmethod
def get_client(name: str) -> Type[Client]:
return CLIENTS[name]

def create_connections(self):
Expand Down
2 changes: 1 addition & 1 deletion cloudbot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def try_connect(self):
while self.active and not self.connected:
try:
await self.connect(timeout)
except Exception:
except Exception: # pylint: disable=broad-except
logger.exception("[%s] Error occurred while connecting.", self.name)
else:
break
Expand Down
Loading