Skip to content

Commit c0b64e3

Browse files
committed
lint: Reformat using Black without skipping string normalization.
1 parent 0285c38 commit c0b64e3

File tree

178 files changed

+5239
-5239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+5239
-5239
lines changed

tools/custom_check.py

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,117 +8,117 @@
88

99
whitespace_rules = [
1010
# This linter should be first since bash_rules depends on it.
11-
{'pattern': r'\s+$', 'strip': '\n', 'description': 'Fix trailing whitespace'},
12-
{'pattern': '\t', 'strip': '\n', 'description': 'Fix tab-based whitespace'},
11+
{"pattern": r"\s+$", "strip": "\n", "description": "Fix trailing whitespace"},
12+
{"pattern": "\t", "strip": "\n", "description": "Fix tab-based whitespace"},
1313
] # type: List[Rule]
1414

1515
markdown_whitespace_rules = list(
16-
[rule for rule in whitespace_rules if rule['pattern'] != r'\s+$']
16+
[rule for rule in whitespace_rules if rule["pattern"] != r"\s+$"]
1717
) + [
1818
# Two spaces trailing a line with other content is okay--it's a markdown line break.
1919
# This rule finds one space trailing a non-space, three or more trailing spaces, and
2020
# spaces on an empty line.
2121
{
22-
'pattern': r'((?<!\s)\s$)|(\s\s\s+$)|(^\s+$)',
23-
'strip': '\n',
24-
'description': 'Fix trailing whitespace',
22+
"pattern": r"((?<!\s)\s$)|(\s\s\s+$)|(^\s+$)",
23+
"strip": "\n",
24+
"description": "Fix trailing whitespace",
2525
},
2626
{
27-
'pattern': r'^#+[A-Za-z0-9]',
28-
'strip': '\n',
29-
'description': 'Missing space after # in heading',
27+
"pattern": r"^#+[A-Za-z0-9]",
28+
"strip": "\n",
29+
"description": "Missing space after # in heading",
3030
},
3131
]
3232

3333
python_rules = RuleList(
34-
langs=['py'],
34+
langs=["py"],
3535
rules=[
36-
{'pattern': r'".*"%\([a-z_].*\)?$', 'description': 'Missing space around "%"'},
37-
{'pattern': r"'.*'%\([a-z_].*\)?$", 'description': 'Missing space around "%"'},
36+
{"pattern": r'".*"%\([a-z_].*\)?$', "description": 'Missing space around "%"'},
37+
{"pattern": r"'.*'%\([a-z_].*\)?$", "description": 'Missing space around "%"'},
3838
# This rule is constructed with + to avoid triggering on itself
39-
{'pattern': r" =" + r'[^ =>~"]', 'description': 'Missing whitespace after "="'},
40-
{'pattern': r'":\w[^"]*$', 'description': 'Missing whitespace after ":"'},
41-
{'pattern': r"':\w[^']*$", 'description': 'Missing whitespace after ":"'},
42-
{'pattern': r"^\s+[#]\w", 'strip': '\n', 'description': 'Missing whitespace after "#"'},
39+
{"pattern": r" =" + r'[^ =>~"]', "description": 'Missing whitespace after "="'},
40+
{"pattern": r'":\w[^"]*$', "description": 'Missing whitespace after ":"'},
41+
{"pattern": r"':\w[^']*$", "description": 'Missing whitespace after ":"'},
42+
{"pattern": r"^\s+[#]\w", "strip": "\n", "description": 'Missing whitespace after "#"'},
4343
{
44-
'pattern': r"assertEquals[(]",
45-
'description': 'Use assertEqual, not assertEquals (which is deprecated).',
44+
"pattern": r"assertEquals[(]",
45+
"description": "Use assertEqual, not assertEquals (which is deprecated).",
4646
},
4747
{
48-
'pattern': r'self: Any',
49-
'description': 'you can omit Any annotation for self',
50-
'good_lines': ['def foo (self):'],
51-
'bad_lines': ['def foo(self: Any):'],
48+
"pattern": r"self: Any",
49+
"description": "you can omit Any annotation for self",
50+
"good_lines": ["def foo (self):"],
51+
"bad_lines": ["def foo(self: Any):"],
5252
},
53-
{'pattern': r"== None", 'description': 'Use `is None` to check whether something is None'},
54-
{'pattern': r"type:[(]", 'description': 'Missing whitespace after ":" in type annotation'},
55-
{'pattern': r"# type [(]", 'description': 'Missing : after type in type annotation'},
56-
{'pattern': r"#type", 'description': 'Missing whitespace after "#" in type annotation'},
57-
{'pattern': r'if[(]', 'description': 'Missing space between if and ('},
58-
{'pattern': r", [)]", 'description': 'Unnecessary whitespace between "," and ")"'},
59-
{'pattern': r"% [(]", 'description': 'Unnecessary whitespace between "%" and "("'},
53+
{"pattern": r"== None", "description": "Use `is None` to check whether something is None"},
54+
{"pattern": r"type:[(]", "description": 'Missing whitespace after ":" in type annotation'},
55+
{"pattern": r"# type [(]", "description": "Missing : after type in type annotation"},
56+
{"pattern": r"#type", "description": 'Missing whitespace after "#" in type annotation'},
57+
{"pattern": r"if[(]", "description": "Missing space between if and ("},
58+
{"pattern": r", [)]", "description": 'Unnecessary whitespace between "," and ")"'},
59+
{"pattern": r"% [(]", "description": 'Unnecessary whitespace between "%" and "("'},
6060
# This next check could have false positives, but it seems pretty
6161
# rare; if we find any, they can be added to the exclude list for
6262
# this rule.
6363
{
64-
'pattern': r' % [a-zA-Z0-9_.]*\)?$',
65-
'description': 'Used % comprehension without a tuple',
64+
"pattern": r" % [a-zA-Z0-9_.]*\)?$",
65+
"description": "Used % comprehension without a tuple",
6666
},
6767
{
68-
'pattern': r'.*%s.* % \([a-zA-Z0-9_.]*\)$',
69-
'description': 'Used % comprehension without a tuple',
68+
"pattern": r".*%s.* % \([a-zA-Z0-9_.]*\)$",
69+
"description": "Used % comprehension without a tuple",
7070
},
7171
{
72-
'pattern': r'__future__',
73-
'include_only': {'zulip_bots/zulip_bots/bots/'},
74-
'description': 'Bots no longer need __future__ imports.',
72+
"pattern": r"__future__",
73+
"include_only": {"zulip_bots/zulip_bots/bots/"},
74+
"description": "Bots no longer need __future__ imports.",
7575
},
7676
{
77-
'pattern': r'#!/usr/bin/env python$',
78-
'include_only': {'zulip_bots/'},
79-
'description': 'Python shebangs must be python3',
77+
"pattern": r"#!/usr/bin/env python$",
78+
"include_only": {"zulip_bots/"},
79+
"description": "Python shebangs must be python3",
8080
},
8181
{
82-
'pattern': r'(^|\s)open\s*\(',
83-
'description': 'open() should not be used in Zulip\'s bots. Use functions'
84-
' provided by the bots framework to access the filesystem.',
85-
'include_only': {'zulip_bots/zulip_bots/bots/'},
82+
"pattern": r"(^|\s)open\s*\(",
83+
"description": "open() should not be used in Zulip's bots. Use functions"
84+
" provided by the bots framework to access the filesystem.",
85+
"include_only": {"zulip_bots/zulip_bots/bots/"},
8686
},
8787
{
88-
'pattern': r'pprint',
89-
'description': 'Used pprint, which is most likely a debugging leftover. For user output, use print().',
88+
"pattern": r"pprint",
89+
"description": "Used pprint, which is most likely a debugging leftover. For user output, use print().",
9090
},
9191
{
92-
'pattern': r'\(BotTestCase\)',
93-
'bad_lines': ['class TestSomeBot(BotTestCase):'],
94-
'description': 'Bot test cases should directly inherit from BotTestCase *and* DefaultTests.',
92+
"pattern": r"\(BotTestCase\)",
93+
"bad_lines": ["class TestSomeBot(BotTestCase):"],
94+
"description": "Bot test cases should directly inherit from BotTestCase *and* DefaultTests.",
9595
},
9696
{
97-
'pattern': r'\(DefaultTests, BotTestCase\)',
98-
'bad_lines': ['class TestSomeBot(DefaultTests, BotTestCase):'],
99-
'good_lines': ['class TestSomeBot(BotTestCase, DefaultTests):'],
100-
'description': 'Bot test cases should inherit from BotTestCase before DefaultTests.',
97+
"pattern": r"\(DefaultTests, BotTestCase\)",
98+
"bad_lines": ["class TestSomeBot(DefaultTests, BotTestCase):"],
99+
"good_lines": ["class TestSomeBot(BotTestCase, DefaultTests):"],
100+
"description": "Bot test cases should inherit from BotTestCase before DefaultTests.",
101101
},
102102
*whitespace_rules,
103103
],
104104
max_length=140,
105105
)
106106

107107
bash_rules = RuleList(
108-
langs=['sh'],
108+
langs=["sh"],
109109
rules=[
110110
{
111-
'pattern': r'#!.*sh [-xe]',
112-
'description': 'Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches'
113-
' to set -x|set -e',
111+
"pattern": r"#!.*sh [-xe]",
112+
"description": "Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches"
113+
" to set -x|set -e",
114114
},
115115
*whitespace_rules[0:1],
116116
],
117117
)
118118

119119

120120
json_rules = RuleList(
121-
langs=['json'],
121+
langs=["json"],
122122
# Here, we don't check tab-based whitespace, because the tab-based
123123
# whitespace rule flags a lot of third-party JSON fixtures
124124
# under zerver/webhooks that we want preserved verbatim. So
@@ -131,21 +131,21 @@
131131

132132
prose_style_rules = [
133133
{
134-
'pattern': r'[^\/\#\-"]([jJ]avascript)', # exclude usage in hrefs/divs
135-
'description': "javascript should be spelled JavaScript",
134+
"pattern": r'[^\/\#\-"]([jJ]avascript)', # exclude usage in hrefs/divs
135+
"description": "javascript should be spelled JavaScript",
136136
},
137137
{
138-
'pattern': r'''[^\/\-\."'\_\=\>]([gG]ithub)[^\.\-\_"\<]''', # exclude usage in hrefs/divs
139-
'description': "github should be spelled GitHub",
138+
"pattern": r"""[^\/\-\."'\_\=\>]([gG]ithub)[^\.\-\_"\<]""", # exclude usage in hrefs/divs
139+
"description": "github should be spelled GitHub",
140140
},
141141
{
142-
'pattern': r'[oO]rganisation', # exclude usage in hrefs/divs
143-
'description': "Organization is spelled with a z",
142+
"pattern": r"[oO]rganisation", # exclude usage in hrefs/divs
143+
"description": "Organization is spelled with a z",
144144
},
145-
{'pattern': r'!!! warning', 'description': "!!! warning is invalid; it's spelled '!!! warn'"},
145+
{"pattern": r"!!! warning", "description": "!!! warning is invalid; it's spelled '!!! warn'"},
146146
{
147-
'pattern': r'[^-_]botserver(?!rc)|bot server',
148-
'description': "Use Botserver instead of botserver or Botserver.",
147+
"pattern": r"[^-_]botserver(?!rc)|bot server",
148+
"description": "Use Botserver instead of botserver or Botserver.",
149149
},
150150
] # type: List[Rule]
151151

@@ -154,21 +154,21 @@
154154
}
155155

156156
markdown_rules = RuleList(
157-
langs=['md'],
157+
langs=["md"],
158158
rules=[
159159
*markdown_whitespace_rules,
160160
*prose_style_rules,
161161
{
162-
'pattern': r'\[(?P<url>[^\]]+)\]\((?P=url)\)',
163-
'description': 'Linkified markdown URLs should use cleaner <http://example.com> syntax.',
162+
"pattern": r"\[(?P<url>[^\]]+)\]\((?P=url)\)",
163+
"description": "Linkified markdown URLs should use cleaner <http://example.com> syntax.",
164164
},
165165
],
166166
max_length=120,
167167
length_exclude=markdown_docs_length_exclude,
168168
)
169169

170170
txt_rules = RuleList(
171-
langs=['txt'],
171+
langs=["txt"],
172172
rules=whitespace_rules,
173173
)
174174

0 commit comments

Comments
 (0)