Skip to content

Commit

Permalink
Upgrade requirements.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Oct 25, 2023
1 parent 2ecabb3 commit 8eb3d4e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 35 deletions.
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
crayons
twine
black==23.3.0
black~=23.10.1
isort
flake8
mock
Expand All @@ -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
Expand Down
31 changes: 4 additions & 27 deletions tools/custom_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,29 @@

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"((?<!\s)\s$)|(\s\s\s+$)|(^\s+$)",
"strip": "\n",
"pattern": r"((?<![\t ])[\t ]$)|([\t ][\t ][\t ]+$)|(^[\t ]+$)",
"description": "Fix trailing whitespace",
},
{
"pattern": r"^#+[A-Za-z0-9]",
"strip": "\n",
"description": "Missing space after # in heading",
},
]

python_rules = RuleList(
langs=["py"],
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[(]",
"description": "Use assertEqual, not assertEquals (which is deprecated).",
Expand All @@ -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.
Expand Down Expand Up @@ -97,7 +81,6 @@
},
*whitespace_rules,
],
max_length=140,
)

bash_rules = RuleList(
Expand Down Expand Up @@ -145,10 +128,6 @@
},
]

markdown_docs_length_exclude = {
"zulip_bots/zulip_bots/bots/converter/doc.md",
}

markdown_rules = RuleList(
langs=["md"],
rules=[
Expand All @@ -159,8 +138,6 @@
"description": "Linkified markdown URLs should use cleaner <http://example.com> syntax.",
},
],
max_length=120,
length_exclude=markdown_docs_length_exclude,
)

txt_rules = RuleList(
Expand Down
3 changes: 1 addition & 2 deletions zulip/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pkgutil
from typing import List

__path__: List[str] = pkgutil.extend_path(__path__, __name__)
__path__ = pkgutil.extend_path(__path__, __name__)
3 changes: 1 addition & 2 deletions zulip_botserver/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pkgutil
from typing import List

__path__: List[str] = pkgutil.extend_path(__path__, __name__)
__path__ = pkgutil.extend_path(__path__, __name__)
4 changes: 3 additions & 1 deletion zulip_botserver/zulip_botserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 8eb3d4e

Please sign in to comment.