From 8eb3d4e1e2899ec8b95f94cded73f75491f43a4f Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 25 Oct 2023 13:09:26 -0700 Subject: [PATCH] Upgrade requirements. Signed-off-by: Anders Kaseorg --- requirements.txt | 6 ++--- tools/custom_check.py | 31 +++-------------------- zulip/tests/__init__.py | 3 +-- zulip_botserver/tests/__init__.py | 3 +-- zulip_botserver/zulip_botserver/server.py | 4 ++- 5 files changed, 12 insertions(+), 35 deletions(-) diff --git a/requirements.txt b/requirements.txt index 32c4523a9..9c2f8948f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ crayons twine -black==23.3.0 +black~=23.10.1 isort flake8 mock @@ -9,8 +9,8 @@ pytest-cov -e ./zulip -e ./zulip_bots -e ./zulip_botserver --e git+https://github.com/zulip/zulint@14e3974001bf8442a6a3486125865660f1f2eb68#egg=zulint==1.0.0 -mypy==0.910 +-e git+https://github.com/zulip/zulint@85de0cbadbba3f498deba32f861bb9a478faa3b4#egg=zulint==1.0.0 +mypy==1.6.1 types-python-dateutil types-pytz types-requests diff --git a/tools/custom_check.py b/tools/custom_check.py index f53bbc7ee..2e8efd169 100644 --- a/tools/custom_check.py +++ b/tools/custom_check.py @@ -4,24 +4,22 @@ whitespace_rules: List[Rule] = [ # This linter should be first since bash_rules depends on it. - {"pattern": r"\s+$", "strip": "\n", "description": "Fix trailing whitespace"}, - {"pattern": "\t", "strip": "\n", "description": "Fix tab-based whitespace"}, + {"pattern": r"[\t ]+$", "description": "Fix trailing whitespace"}, + {"pattern": r"\t", "description": "Fix tab-based whitespace"}, ] 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. # This rule finds one space trailing a non-space, three or more trailing spaces, and # spaces on an empty line. { - "pattern": 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[(]", "description": "Use assertEqual, not assertEquals (which is deprecated).", @@ -46,13 +37,6 @@ "good_lines": ["def foo (self):"], "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 # rare; if we find any, they can be added to the exclude list for # this rule. @@ -97,7 +81,6 @@ }, *whitespace_rules, ], - max_length=140, ) bash_rules = RuleList( @@ -145,10 +128,6 @@ }, ] -markdown_docs_length_exclude = { - "zulip_bots/zulip_bots/bots/converter/doc.md", -} - markdown_rules = RuleList( langs=["md"], rules=[ @@ -159,8 +138,6 @@ "description": "Linkified markdown URLs should use cleaner syntax.", }, ], - max_length=120, - length_exclude=markdown_docs_length_exclude, ) txt_rules = RuleList( diff --git a/zulip/tests/__init__.py b/zulip/tests/__init__.py index 832c764d2..f77af49c2 100644 --- a/zulip/tests/__init__.py +++ b/zulip/tests/__init__.py @@ -1,4 +1,3 @@ import pkgutil -from typing import List -__path__: List[str] = pkgutil.extend_path(__path__, __name__) +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/zulip_botserver/tests/__init__.py b/zulip_botserver/tests/__init__.py index 832c764d2..f77af49c2 100644 --- a/zulip_botserver/tests/__init__.py +++ b/zulip_botserver/tests/__init__.py @@ -1,4 +1,3 @@ import pkgutil -from typing import List -__path__: List[str] = pkgutil.extend_path(__path__, __name__) +__path__ = pkgutil.extend_path(__path__, __name__) diff --git a/zulip_botserver/zulip_botserver/server.py b/zulip_botserver/zulip_botserver/server.py index 85f49d0b6..08f1d233d 100644 --- a/zulip_botserver/zulip_botserver/server.py +++ b/zulip_botserver/zulip_botserver/server.py @@ -149,7 +149,9 @@ def load_bot_handlers( api_key=bots_config[bot]["key"], 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( client, bot_dir, bot_details={}, bot_config_parser=third_party_bot_conf )