Upgrade requirements.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-25 13:09:26 -07:00
parent 2ecabb3260
commit 8eb3d4e1e2
5 changed files with 12 additions and 35 deletions

View file

@ -1,6 +1,6 @@
crayons crayons
twine twine
black==23.3.0 black~=23.10.1
isort isort
flake8 flake8
mock mock
@ -9,8 +9,8 @@ pytest-cov
-e ./zulip -e ./zulip
-e ./zulip_bots -e ./zulip_bots
-e ./zulip_botserver -e ./zulip_botserver
-e git+https://github.com/zulip/zulint@14e3974001bf8442a6a3486125865660f1f2eb68#egg=zulint==1.0.0 -e git+https://github.com/zulip/zulint@85de0cbadbba3f498deba32f861bb9a478faa3b4#egg=zulint==1.0.0
mypy==0.910 mypy==1.6.1
types-python-dateutil types-python-dateutil
types-pytz types-pytz
types-requests types-requests

View file

@ -4,24 +4,22 @@ from zulint.custom_rules import Rule, RuleList
whitespace_rules: List[Rule] = [ whitespace_rules: List[Rule] = [
# This linter should be first since bash_rules depends on it. # This linter should be first since bash_rules depends on it.
{"pattern": r"\s+$", "strip": "\n", "description": "Fix trailing whitespace"}, {"pattern": r"[\t ]+$", "description": "Fix trailing whitespace"},
{"pattern": "\t", "strip": "\n", "description": "Fix tab-based whitespace"}, {"pattern": r"\t", "description": "Fix tab-based whitespace"},
] ]
markdown_whitespace_rules = list( markdown_whitespace_rules = list(
rule for rule in whitespace_rules if rule["pattern"] != r"\s+$" rule for rule in whitespace_rules if rule["pattern"] != r"[\t ]+$"
) + [ ) + [
# Two spaces trailing a line with other content is okay--it's a markdown line break. # Two spaces trailing a line with other content is okay--it's a markdown line break.
# This rule finds one space trailing a non-space, three or more trailing spaces, and # This rule finds one space trailing a non-space, three or more trailing spaces, and
# spaces on an empty line. # spaces on an empty line.
{ {
"pattern": r"((?<!\s)\s$)|(\s\s\s+$)|(^\s+$)", "pattern": r"((?<![\t ])[\t ]$)|([\t ][\t ][\t ]+$)|(^[\t ]+$)",
"strip": "\n",
"description": "Fix trailing whitespace", "description": "Fix trailing whitespace",
}, },
{ {
"pattern": r"^#+[A-Za-z0-9]", "pattern": r"^#+[A-Za-z0-9]",
"strip": "\n",
"description": "Missing space after # in heading", "description": "Missing space after # in heading",
}, },
] ]
@ -29,13 +27,6 @@ markdown_whitespace_rules = list(
python_rules = RuleList( python_rules = RuleList(
langs=["py"], langs=["py"],
rules=[ rules=[
{"pattern": r'".*"%\([a-z_].*\)?$', "description": 'Missing space around "%"'},
{"pattern": r"'.*'%\([a-z_].*\)?$", "description": 'Missing space around "%"'},
# This rule is constructed with + to avoid triggering on itself
{"pattern": r" =" + r'[^ =>~"]', "description": 'Missing whitespace after "="'},
{"pattern": r'":\w[^"]*$', "description": 'Missing whitespace after ":"'},
{"pattern": r"':\w[^']*$", "description": 'Missing whitespace after ":"'},
{"pattern": r"^\s+[#]\w", "strip": "\n", "description": 'Missing whitespace after "#"'},
{ {
"pattern": r"assertEquals[(]", "pattern": r"assertEquals[(]",
"description": "Use assertEqual, not assertEquals (which is deprecated).", "description": "Use assertEqual, not assertEquals (which is deprecated).",
@ -46,13 +37,6 @@ python_rules = RuleList(
"good_lines": ["def foo (self):"], "good_lines": ["def foo (self):"],
"bad_lines": ["def foo(self: Any):"], "bad_lines": ["def foo(self: Any):"],
}, },
{"pattern": r"== None", "description": "Use `is None` to check whether something is None"},
{"pattern": r"type:[(]", "description": 'Missing whitespace after ":" in type annotation'},
{"pattern": r"# type [(]", "description": "Missing : after type in type annotation"},
{"pattern": r"#type", "description": 'Missing whitespace after "#" in type annotation'},
{"pattern": r"if[(]", "description": "Missing space between if and ("},
{"pattern": r", [)]", "description": 'Unnecessary whitespace between "," and ")"'},
{"pattern": r"% [(]", "description": 'Unnecessary whitespace between "%" and "("'},
# This next check could have false positives, but it seems pretty # This next check could have false positives, but it seems pretty
# rare; if we find any, they can be added to the exclude list for # rare; if we find any, they can be added to the exclude list for
# this rule. # this rule.
@ -97,7 +81,6 @@ python_rules = RuleList(
}, },
*whitespace_rules, *whitespace_rules,
], ],
max_length=140,
) )
bash_rules = RuleList( bash_rules = RuleList(
@ -145,10 +128,6 @@ prose_style_rules: List[Rule] = [
}, },
] ]
markdown_docs_length_exclude = {
"zulip_bots/zulip_bots/bots/converter/doc.md",
}
markdown_rules = RuleList( markdown_rules = RuleList(
langs=["md"], langs=["md"],
rules=[ rules=[
@ -159,8 +138,6 @@ markdown_rules = RuleList(
"description": "Linkified markdown URLs should use cleaner <http://example.com> syntax.", "description": "Linkified markdown URLs should use cleaner <http://example.com> syntax.",
}, },
], ],
max_length=120,
length_exclude=markdown_docs_length_exclude,
) )
txt_rules = RuleList( txt_rules = RuleList(

View file

@ -1,4 +1,3 @@
import pkgutil import pkgutil
from typing import List
__path__: List[str] = pkgutil.extend_path(__path__, __name__) __path__ = pkgutil.extend_path(__path__, __name__)

View file

@ -1,4 +1,3 @@
import pkgutil import pkgutil
from typing import List
__path__: List[str] = pkgutil.extend_path(__path__, __name__) __path__ = pkgutil.extend_path(__path__, __name__)

View file

@ -149,7 +149,9 @@ def load_bot_handlers(
api_key=bots_config[bot]["key"], api_key=bots_config[bot]["key"],
site=bots_config[bot]["site"], site=bots_config[bot]["site"],
) )
bot_dir = os.path.join(os.path.dirname(os.path.abspath(bot_lib_modules[bot].__file__))) bot_file = bot_lib_modules[bot].__file__
assert bot_file is not None
bot_dir = os.path.dirname(os.path.abspath(bot_file))
bot_handler = lib.ExternalBotHandler( bot_handler = lib.ExternalBotHandler(
client, bot_dir, bot_details={}, bot_config_parser=third_party_bot_conf client, bot_dir, bot_details={}, bot_config_parser=third_party_bot_conf
) )