From 75d1fe2b41cf3efef6bc7908a8aafe2b74eac64f Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 18 Apr 2020 15:47:39 -0700 Subject: [PATCH] lint: Upgrade zulint. Signed-off-by: Anders Kaseorg --- requirements.txt | 2 +- tools/custom_check.py | 16 ++++++++++------ tools/run-mypy | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3ffabbf..312501f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,5 +7,5 @@ pytest -e ./zulip -e ./zulip_bots -e ./zulip_botserver --e git+https://github.com/zulip/zulint@aaed679f1ad38b230090eadd3870b7682500f60c#egg=zulint==1.0.0 +-e git+https://github.com/zulip/zulint@8cb430b64eec1e98ef637bafd06272ebe715aa87#egg=zulint==1.0.0 mypy==0.770 diff --git a/tools/custom_check.py b/tools/custom_check.py index 092ba63..ff60e91 100644 --- a/tools/custom_check.py +++ b/tools/custom_check.py @@ -13,7 +13,7 @@ whitespace_rules = [ {'pattern': '\t', 'strip': '\n', 'description': 'Fix tab-based whitespace'}, -] # type: Rule +] # type: List[Rule] markdown_whitespace_rules = list([rule for rule in whitespace_rules if rule['pattern'] != r'\s+$']) + [ # Two spaces trailing a line with other content is okay--it's a markdown line break. @@ -25,7 +25,7 @@ markdown_whitespace_rules = list([rule for rule in whitespace_rules if rule['pat {'pattern': r'^#+[A-Za-z0-9]', 'strip': '\n', 'description': 'Missing space after # in heading'}, -] # type: Rule +] python_rules = RuleList( langs=['py'], @@ -90,7 +90,8 @@ python_rules = RuleList( 'bad_lines': ['class TestSomeBot(DefaultTests, BotTestCase):'], 'good_lines': ['class TestSomeBot(BotTestCase, DefaultTests):'], 'description': 'Bot test cases should inherit from BotTestCase before DefaultTests.'}, - ] + whitespace_rules, + *whitespace_rules, + ], max_length=140, ) @@ -100,7 +101,8 @@ bash_rules = RuleList( {'pattern': r'#!.*sh [-xe]', 'description': 'Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches' ' to set -x|set -e'}, - ] + whitespace_rules[0:1], + *whitespace_rules[0:1], + ], ) @@ -127,7 +129,7 @@ prose_style_rules = [ 'description': "!!! warning is invalid; it's spelled '!!! warn'"}, {'pattern': r'[^-_]botserver(?!rc)|bot server', 'description': "Use Botserver instead of botserver or Botserver."}, -] # type: Rule +] # type: List[Rule] markdown_docs_length_exclude = { "zulip_bots/zulip_bots/bots/converter/doc.md", @@ -135,7 +137,9 @@ markdown_docs_length_exclude = { markdown_rules = RuleList( langs=['md'], - rules=markdown_whitespace_rules + prose_style_rules + [ + rules=[ + *markdown_whitespace_rules, + *prose_style_rules, {'pattern': r'\[(?P[^\]]+)\]\((?P=url)\)', 'description': 'Linkified markdown URLs should use cleaner syntax.'} ], diff --git a/tools/run-mypy b/tools/run-mypy index c118b3e..357c599 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -98,6 +98,7 @@ force_include = [ "zulip_bots/zulip_bots/bots/susi/test_susi.py", "zulip_bots/zulip_bots/bots/front/front.py", "zulip_bots/zulip_bots/bots/front/test_front.py", + "tools/custom_check.py", "tools/deploy" ]