mirror of https://github.com/zulip/zulip.git
lint: Fix incorrect line length calculations in Python 2.
Previously, we would incorrectly be counting bytes in Python 2, which meant lines with unicode characters in them appeared to the linter to be far longer than they actually were.
This commit is contained in:
parent
190d320afa
commit
b54f8b3b14
|
@ -157,7 +157,11 @@ def build_custom_checkers(by_lang):
|
|||
except Exception:
|
||||
print("Exception with %s at %s line %s" % (rule['pattern'], fn, i+1))
|
||||
traceback.print_exc()
|
||||
if (max_length is not None and len(line) > max_length and
|
||||
if isinstance(line, bytes):
|
||||
line_length = len(line.decode("utf-8"))
|
||||
else:
|
||||
line_length = len(line)
|
||||
if (max_length is not None and line_length > max_length and
|
||||
'# type' not in line and 'test' not in fn and 'example' not in fn and
|
||||
not re.match("\[[a-z0-9_-]*\]: http.*", line) and
|
||||
"#ignorelongline" not in line and 'migrations' not in fn):
|
||||
|
|
Loading…
Reference in New Issue