diff --git a/src/csbot/config.py b/src/csbot/config.py index 23fc81c..ee173b3 100644 --- a/src/csbot/config.py +++ b/src/csbot/config.py @@ -350,8 +350,8 @@ def _write(self, s, raw=False): """Write *s* to the current stream; if *raw* is True, don't apply comment filter.""" if not raw and self._commented: lines = s.split("\n") - modified = [f"# {l}" if l and not l.startswith("#") else l - for l in lines] + modified = [f"# {line}" if line and not line.startswith("#") else line + for line in lines] s = "\n".join(modified) self._stream.write(s) self._at_start = False diff --git a/src/csbot/util.py b/src/csbot/util.py index 83fd2e0..740a5a9 100644 --- a/src/csbot/util.py +++ b/src/csbot/util.py @@ -134,14 +134,14 @@ def pairwise(iterable): return zip(a, b) -def cap_string(s, l): +def cap_string(s, n): """If a string is longer than a particular length, it gets truncated and has '...' added to the end. """ - if len(s) <= l: + if len(s) <= n: return s - return s[0:l-3] + "..." + return s[0:n - 3] + "..." def ordinal(value): diff --git a/tests/conftest.py b/tests/conftest.py index 9da6e9d..9066f26 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -122,7 +122,7 @@ def receive(self, lines): """Shortcut to push a series of lines to the client.""" if isinstance(lines, str): lines = [lines] - return [self.client.line_received(l) for l in lines] + return [self.client.line_received(line) for line in lines] def assert_sent(self, lines): """Check that a list of (unicode) strings have been sent. @@ -132,7 +132,7 @@ def assert_sent(self, lines): """ if isinstance(lines, str): lines = [lines] - self.client.send_line.assert_has_calls([mock.call(l) for l in lines]) + self.client.send_line.assert_has_calls([mock.call(line) for line in lines]) self.client.send_line.reset_mock() diff --git a/tests/test_bot.py b/tests/test_bot.py index ce398af..147dc35 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -188,7 +188,7 @@ def command_b(self, *args, **kwargs): def command_cd(self, *args, **kwargs): self.handler_mock(inspect.currentframe().f_code.co_name) - CONFIG_A = f"""\ + CONFIG_A = """\ ["@bot"] command_prefix = "&" plugins = ["mockplugin1"] @@ -248,7 +248,7 @@ def __init__(self, *args, **kwargs): def command_a(self, *args, **kwargs): self.handler_mock(inspect.currentframe().f_code.co_name) - CONFIG_B = f"""\ + CONFIG_B = """\ ["@bot"] command_prefix = "&" plugins = ["mockplugin1", "mockplugin2"] diff --git a/tests/test_config.py b/tests/test_config.py index 949cd2a..b653b39 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -749,7 +749,7 @@ def _test_config_generator_list_wrap(): class Config(config.Config): a = config.option_list(str, default=["abcdefghijklmnopqrstuvwxyz" for _ in range(2)], help="") b = config.option_list(str, default=["abcdefghijklmnopqrstuvwxyz" for _ in range(5)], help="") - abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz = config.option_list(str, help="") + abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz = config.option_list(str, help="") # noqa: E501 return Config, [ # Shorter than threshold, don't split @@ -763,7 +763,7 @@ class Config(config.Config): ' "abcdefghijklmnopqrstuvwxyz",', ']', # Key longer than threshold, but no items, don't split - 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz = []', + 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz = []', # noqa: E501 ] diff --git a/tests/test_plugin_github.py b/tests/test_plugin_github.py index 3be1a8e..a166e48 100644 --- a/tests/test_plugin_github.py +++ b/tests/test_plugin_github.py @@ -67,8 +67,8 @@ class TestGitHubPlugin: ["github/alanbriolat/csbot-webhook-test"] notify = "#mychannel" - """ - URL = f'/webhook/github/foobar' + """ # noqa: E501 + URL = '/webhook/github/foobar' pytestmark = pytest.mark.bot(plugins=PLUGINS, config=CONFIG) TEST_CASES = [ diff --git a/tests/test_plugin_linkinfo.py b/tests/test_plugin_linkinfo.py index 14f105c..d7726fa 100644 --- a/tests/test_plugin_linkinfo.py +++ b/tests/test_plugin_linkinfo.py @@ -221,7 +221,7 @@ def __init__(self, *args, **kwargs): def privmsg(self, event): self.handler_mock(event['message']) - CONFIG = f"""\ + CONFIG = """\ ["@bot"] plugins = ["mockplugin", "linkinfo"] """ diff --git a/tox.ini b/tox.ini index 36c50f0..b349a89 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ skipsdist = True passenv = TRAVIS TRAVIS_* GITHUB_* deps = -r requirements.txt - flake8: flake8 + flake8: flake8==4.0.1 commands = python -m pytest {posargs} - flake8: flake8 --exit-zero --exclude=src/csbot/plugins_broken src/ tests/ + flake8: flake8 --exclude=src/csbot/plugins_broken src/ tests/