mirror of https://github.com/zulip/zulip.git
f632692188
The `re.match` function in the Python stdlib is a trap for the unwary, with surprising and asymmetrical semantics; we should probably add a lint rule to ban it entirely. The docstring says: > Try to apply the pattern at the start of the string, [...] In other words, it effectively adds a `^` at the start (or `\A`, where the distinction matters.) It's bad enough that this differs from what grep, sed, perl, less, and every other tool I can think of do when looking for matches to a regex; on top of that, it treats the beginning of the string differently from the end, for no obvious reason. The function that does what the rest of the world understands by "match against this regex" is `re.search`. In this case, it's unlikely that anyone intended for comments with URLs, or `api_url` references, to miss out on their respective exceptions to the long-line rule if they happen to start after the first column. So fix those rules by just switching to `re.search` with the same pattern. I think Markdown URL references may have to start at the beginning of the line, so I've left a `^` there to preserve -- but now make explicit -- the `re.match` behavior. |
||
---|---|---|
.. | ||
__init__.py | ||
custom_check.py | ||
exclude.py | ||
pep8.py | ||
printer.py | ||
pyflakes.py |