2017-06-23 02:16:10 +02:00
# -*- coding: utf-8 -*-
2017-06-05 16:29:04 +02:00
from __future__ import print_function
from __future__ import absolute_import
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
from typing import List , TYPE_CHECKING
2019-05-30 17:41:23 +02:00
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
from zulint . custom_rules import RuleList
if TYPE_CHECKING :
from zulint . custom_rules import Rule
2019-05-30 17:41:23 +02:00
# Rule help:
# By default, a rule applies to all files within the extension for which it is specified (e.g. all .py files)
# There are three operators we can use to manually include or exclude files from linting for a rule:
# 'exclude': 'set([<path>, ...])' - if <path> is a filename, excludes that file.
# if <path> is a directory, excludes all files directly below the directory <path>.
# 'exclude_line': 'set([(<path>, <line>), ...])' - excludes all lines matching <line> in the file <path> from linting.
# 'include_only': 'set([<path>, ...])' - includes only those files where <path> is a substring of the filepath.
2017-08-04 02:23:09 +02:00
2019-05-30 17:41:23 +02:00
PYDELIMS = r ''' " ' () \ [ \ ] {} # \ \ '''
PYREG = r " [^ {} ] " . format ( PYDELIMS )
PYSQ = r ' " (?:[^ " \\ ]| \\ .)* " '
PYDQ = r " ' (?:[^ ' \\ ]| \\ .)* ' "
PYLEFT = r " [( \ [ { ] "
PYRIGHT = r " [) \ ]}] "
PYCODE = PYREG
for depth in range ( 5 ) :
PYGROUP = r """ (?: {} | {} | {} {} * {} ) """ . format ( PYSQ , PYDQ , PYLEFT , PYCODE , PYRIGHT )
PYCODE = r """ (?: {} | {} ) """ . format ( PYREG , PYGROUP )
2018-11-08 16:33:36 +01:00
FILES_WITH_LEGACY_SUBJECT = {
# This basically requires a big DB migration:
' zerver/lib/topic.py ' ,
2018-11-10 17:52:28 +01:00
# This is for backward compatibility.
' zerver/tests/test_legacy_subject.py ' ,
# Other migration-related changes require extreme care.
2018-11-08 16:33:36 +01:00
' zerver/lib/fix_unreads.py ' ,
2018-11-10 17:52:28 +01:00
' zerver/tests/test_migrations.py ' ,
2018-11-08 16:33:36 +01:00
# These use subject in the email sense, and will
# probably always be exempt:
' zerver/lib/email_mirror.py ' ,
' zerver/lib/feedback.py ' ,
2018-11-10 17:52:28 +01:00
' zerver/tests/test_new_users.py ' ,
2019-01-04 08:34:59 +01:00
' zerver/tests/test_email_mirror.py ' ,
2018-11-08 16:33:36 +01:00
# These are tied more to our API than our DB model.
2019-08-04 18:14:48 +02:00
' zerver/openapi/python_examples.py ' ,
2019-07-15 22:33:16 +02:00
' zerver/tests/test_openapi.py ' ,
2018-11-08 16:33:36 +01:00
2018-11-10 18:28:56 +01:00
# This has lots of query data embedded, so it's hard
# to fix everything until we migrate the DB to "topic".
2018-11-10 17:52:28 +01:00
' zerver/tests/test_narrow.py ' ,
2018-11-08 16:33:36 +01:00
}
2019-06-12 18:37:03 +02:00
shebang_rules = [
{ ' pattern ' : ' ^#! ' ,
' description ' : " zerver library code shouldn ' t have a shebang line. " ,
' include_only ' : set ( [ ' zerver/ ' ] ) } ,
# /bin/sh and /usr/bin/env are the only two binaries
# that NixOS provides at a fixed path (outside a
# buildFHSUserEnv sandbox).
{ ' pattern ' : ' ^#!(?! *(?:/usr/bin/env|/bin/sh)(?: |$)) ' ,
' description ' : " Use `#!/usr/bin/env foo` instead of `#!/path/foo` "
" for interpreters other than sh. " } ,
{ ' pattern ' : ' ^#!/usr/bin/env python$ ' ,
' description ' : " Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`. " }
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] # type: List[Rule]
2019-06-12 18:37:03 +02:00
2019-05-30 17:41:23 +02:00
trailing_whitespace_rule = {
' pattern ' : r ' \ s+$ ' ,
' strip ' : ' \n ' ,
' description ' : ' Fix trailing whitespace '
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
} # type: Rule
2019-05-30 17:41:23 +02:00
whitespace_rules = [
# This linter should be first since bash_rules depends on it.
trailing_whitespace_rule ,
{ ' pattern ' : ' http://zulip.readthedocs.io ' ,
' description ' : ' Use HTTPS when linking to ReadTheDocs ' ,
} ,
{ ' pattern ' : ' \t ' ,
' strip ' : ' \n ' ,
' exclude ' : set ( [ ' tools/ci/success-http-headers.txt ' ] ) ,
' description ' : ' Fix tab-based whitespace ' } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] # type: List[Rule]
2019-05-30 17:41:23 +02:00
comma_whitespace_rule = [
{ ' pattern ' : ' , { 2,}[^#/ ] ' ,
' exclude ' : set ( [ ' zerver/tests ' , ' frontend_tests/node_tests ' , ' corporate/tests ' ] ) ,
' description ' : " Remove multiple whitespaces after ' , ' " ,
' good_lines ' : [ ' foo(1, 2, 3) ' , ' foo = bar # some inline comment ' ] ,
' bad_lines ' : [ ' foo(1, 2, 3) ' , ' foo(1, 2, 3) ' ] } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] # type: List[Rule]
2019-05-30 17:41:23 +02:00
markdown_whitespace_rules = list ( [ rule for rule in whitespace_rules if rule [ ' pattern ' ] != r ' \ s+$ ' ] ) + [
# 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 ' ,
' description ' : ' Fix trailing whitespace ' } ,
{ ' pattern ' : ' ^#+[A-Za-z0-9] ' ,
' strip ' : ' \n ' ,
' description ' : ' Missing space after # in heading ' ,
' good_lines ' : [ ' ### some heading ' , ' # another heading ' ] ,
' bad_lines ' : [ ' ###some heading ' , ' #another heading ' ] } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
]
2019-05-30 17:41:23 +02:00
js_rules = RuleList (
langs = [ ' js ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2018-12-23 17:58:31 +01:00
{ ' pattern ' : ' subject|SUBJECT ' ,
' exclude ' : set ( [ ' static/js/util.js ' ,
' frontend_tests/ ' ] ) ,
' exclude_pattern ' : ' emails ' ,
' description ' : ' avoid subject in JS code ' ,
' good_lines ' : [ ' topic_name ' ] ,
' bad_lines ' : [ ' subject= " foo " ' , ' MAX_SUBJECT_LEN ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' [^_]function \ ( ' ,
2017-06-05 16:29:04 +02:00
' description ' : ' The keyword " function " should be followed by a space ' } ,
2019-08-28 17:46:10 +02:00
{ ' pattern ' : ' msgid|MSGID ' ,
' description ' : ' Avoid using " msgid " as a variable name; use " message_id " instead. ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' .*blueslip.warning \ (.* ' ,
2017-06-05 16:29:04 +02:00
' description ' : ' The module blueslip has no function warning, try using blueslip.warn ' } ,
{ ' pattern ' : ' [)] { $ ' ,
' description ' : ' Missing space between ) and { ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' i18n \ .t \ ([^)]+[^, \ { \ )]$ ' ,
2017-09-05 08:37:25 +02:00
' description ' : ' i18n string should not be a multiline string ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ''' i18n \ .t \ ([ ' " ].+?[ ' " ] \ s* \ + ''' ,
2017-09-08 09:35:11 +02:00
' description ' : ' Do not concatenate arguments within i18n.t() ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' i18n \ .t \ (.+ \ ).* \ + ' ,
2017-09-05 08:37:25 +02:00
' description ' : ' Do not concatenate i18n strings ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' \ +.*i18n \ .t \ (.+ \ ) ' ,
2017-09-05 08:37:25 +02:00
' description ' : ' Do not concatenate i18n strings ' } ,
2018-06-03 22:00:04 +02:00
{ ' pattern ' : ' [.]includes[(] ' ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
' exclude ' : { ' frontend_tests/ ' } ,
2018-06-03 22:00:04 +02:00
' description ' : ' .includes() is incompatible with Internet Explorer. Use .indexOf() !== -1 instead. ' } ,
2018-03-22 22:04:24 +01:00
{ ' pattern ' : ' [.]html[(] ' ,
2019-07-09 21:24:00 +02:00
' exclude_pattern ' : r ''' [.]html[(]( " | ' |render_|html|message.content|sub.rendered_description|i18n.t|rendered_|$|[)]|error_text|widget_elem|[$]error|[$][(] " <p> " [)]) ''' ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
' exclude ' : { ' static/js/portico ' , ' static/js/lightbox.js ' , ' static/js/ui_report.js ' ,
2018-09-12 17:43:38 +02:00
' static/js/confirm_dialog.js ' ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
' frontend_tests/ ' } ,
2018-03-22 22:04:24 +01:00
' description ' : ' Setting HTML content with jQuery .html() can lead to XSS security bugs. Consider .text() or using rendered_foo as a variable name if content comes from handlebars and thus is already sanitized. ' } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' [ " \' ]json/ ' ,
' description ' : ' Relative URL for JSON route not supported by i18n ' } ,
# This rule is constructed with + to avoid triggering on itself
{ ' pattern ' : " = " + ' [^ =>~ " ] ' ,
' description ' : ' Missing whitespace after " = " ' } ,
{ ' pattern ' : ' ^[ ]*//[A-Za-z0-9] ' ,
' description ' : ' Missing space after // in comment ' } ,
{ ' pattern ' : ' if[(] ' ,
' description ' : ' Missing space between if and ( ' } ,
{ ' pattern ' : ' else { $ ' ,
' description ' : ' Missing space between else and { ' } ,
{ ' pattern ' : ' ^else { $ ' ,
' description ' : ' Write JS else statements on same line as } ' } ,
{ ' pattern ' : ' ^else if ' ,
' description ' : ' Write JS else statements on same line as } ' } ,
{ ' pattern ' : ' console[.][a-z] ' ,
' exclude ' : set ( [ ' static/js/blueslip.js ' ,
' frontend_tests/zjsunit ' ,
' frontend_tests/casper_lib/common.js ' ,
' frontend_tests/node_tests ' ,
2019-07-18 06:47:06 +02:00
' static/js/debug.js ' ] ) ,
2017-06-05 16:29:04 +02:00
' description ' : ' console.log and similar should not be used in webapp ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ''' [.]text \ ([ " ' ][a-zA-Z] ''' ,
2018-07-20 20:23:02 +02:00
' description ' : ' Strings passed to $().text should be wrapped in i18n.t() for internationalization ' ,
' exclude ' : set ( [ ' frontend_tests/node_tests/ ' ] ) } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ''' compose_error \ ([ " ' ] ''' ,
2017-06-05 16:29:04 +02:00
' description ' : ' Argument to compose_error should be a literal string enclosed '
' by i18n.t() ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' ui.report_success \ ( ' ,
2017-06-05 16:29:04 +02:00
' description ' : ' Deprecated function, use ui_report.success. ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ''' report.success \ ([ " ' ] ''' ,
2017-06-05 16:29:04 +02:00
' description ' : ' Argument to report_success should be a literal string enclosed '
' by i18n.t() ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' ui.report_error \ ( ' ,
2017-06-05 16:29:04 +02:00
' description ' : ' Deprecated function, use ui_report.error. ' } ,
2018-12-18 21:32:54 +01:00
{ ' pattern ' : r ''' report.error \ ([ " ' ][^ ' " ] ''' ,
' description ' : ' Argument to ui_report.error should be a literal string enclosed '
' by i18n.t() ' ,
' good_lines ' : [ ' ui_report.error( " " ) ' , ' ui_report.error(_( " text " )) ' ] ,
' bad_lines ' : [ ' ui_report.error( " test " ) ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' \ $ \ (document \ ) \ .ready \ ( ' ,
2017-10-05 16:03:58 +02:00
' description ' : " `Use $(f) rather than `$(document).ready(f)` " ,
' good_lines ' : [ ' $(function () { foo();} ' ] ,
' bad_lines ' : [ ' $(document).ready(function () { foo();} ' ] } ,
2018-02-14 01:47:09 +01:00
{ ' pattern ' : ' [$][.](get|post|patch|delete|ajax)[(] ' ,
' description ' : " Use channel module for AJAX calls " ,
' exclude ' : set ( [
# Internal modules can do direct network calls
' static/js/blueslip.js ' ,
' static/js/channel.js ' ,
# External modules that don't include channel.js
' static/js/stats/ ' ,
' static/js/portico/ ' ,
2018-09-06 15:14:54 +02:00
' static/js/billing/ ' ,
2018-02-14 01:47:09 +01:00
] ) ,
' good_lines ' : [ ' channel.get(...) ' ] ,
' bad_lines ' : [ ' $.get() ' , ' $.post() ' , ' $.ajax() ' ] } ,
2017-10-06 10:12:47 +02:00
{ ' pattern ' : ' style ?= ' ,
' description ' : " Avoid using the `style=` attribute; we prefer styling in CSS files " ,
' exclude ' : set ( [
2017-11-23 21:17:08 +01:00
' frontend_tests/node_tests/copy_and_paste.js ' ,
2017-11-25 22:22:36 +01:00
' frontend_tests/node_tests/upload.js ' ,
2017-10-06 10:12:47 +02:00
' frontend_tests/node_tests/templates.js ' ,
2017-11-23 15:00:05 +01:00
' static/js/upload.js ' ,
2017-10-06 10:12:47 +02:00
' static/js/stream_color.js ' ,
] ) ,
' good_lines ' : [ ' #my-style { color: blue;} ' ] ,
' bad_lines ' : [ ' <p style= " color: blue; " >Foo</p> ' , ' style = " color: blue; " ' ] } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* whitespace_rules ,
* comma_whitespace_rule ,
] ,
2019-05-30 17:41:23 +02:00
)
python_rules = RuleList (
langs = [ ' py ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2018-11-01 21:21:01 +01:00
{ ' pattern ' : ' subject|SUBJECT ' ,
2018-11-27 20:05:25 +01:00
' exclude_pattern ' : ' subject to the|email|outbox ' ,
2018-11-01 21:21:01 +01:00
' description ' : ' avoid subject as a var ' ,
' good_lines ' : [ ' topic_name ' ] ,
' bad_lines ' : [ ' subject= " foo " ' , ' MAX_SUBJECT_LEN ' ] ,
2018-11-08 16:33:36 +01:00
' exclude ' : FILES_WITH_LEGACY_SUBJECT ,
2018-11-01 21:48:49 +01:00
' include_only ' : set ( [
2018-11-10 17:10:45 +01:00
' zerver/data_import/ ' ,
2018-11-09 20:23:55 +01:00
' zerver/lib/ ' ,
2018-11-10 17:52:28 +01:00
' zerver/tests/ ' ,
2018-11-09 20:23:55 +01:00
' zerver/views/ ' ] ) } ,
2019-08-15 08:05:44 +02:00
{ ' pattern ' : ' msgid|MSGID ' ,
' exclude ' : set ( [ ' tools/check-capitalization ' ,
' tools/i18n/tagmessages ' ] ) ,
' description ' : ' Avoid using " msgid " as a variable name; use " message_id " instead. ' } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' ^(?!#)@login_required ' ,
2017-09-26 15:54:14 +02:00
' description ' : ' @login_required is unsupported; use @zulip_login_required ' ,
' good_lines ' : [ ' @zulip_login_required ' , ' # foo @login_required ' ] ,
' bad_lines ' : [ ' @login_required ' , ' @login_required ' ] } ,
2017-11-20 19:52:10 +01:00
{ ' pattern ' : ' ^user_profile[.]save[(][)] ' ,
' description ' : ' Always pass update_fields when saving user_profile objects ' ,
' exclude_line ' : set ( [
( ' zerver/lib/actions.py ' , " user_profile.save() # Can ' t use update_fields because of how the foreign key works. " ) ,
] ) ,
' exclude ' : set ( [ ' zerver/tests ' , ' zerver/lib/create_user.py ' ] ) ,
' good_lines ' : [ ' user_profile.save(update_fields=[ " pointer " ]) ' ] ,
' bad_lines ' : [ ' user_profile.save() ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' ^[^ " ]* " [^ " ]* " % \ ( ' ,
2017-09-26 15:54:14 +02:00
' description ' : ' Missing space around " % " ' ,
' good_lines ' : [ ' " %s " % ( " foo " ) ' , ' " %s " % (foo) ' ] ,
' bad_lines ' : [ ' " %s " % ( " foo " ) ' , ' " %s " % (foo) ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r " ^[^ ' ]* ' [^ ' ]* ' % \ ( " ,
2017-09-26 15:54:14 +02:00
' description ' : ' Missing space around " % " ' ,
' good_lines ' : [ " ' %s ' % ( ' foo ' ) " , " ' %s ' % (foo) " ] ,
' bad_lines ' : [ " ' %s ' % ( ' foo ' ) " , " ' %s ' % (foo) " ] } ,
2017-12-08 17:03:58 +01:00
{ ' pattern ' : ' self: Any ' ,
' description ' : ' you can omit Any annotation for self ' ,
' good_lines ' : [ ' def foo (self): ' ] ,
' bad_lines ' : [ ' def foo(self: Any): ' ] } ,
2017-06-05 16:29:04 +02:00
# This rule is constructed with + to avoid triggering on itself
{ ' pattern ' : " = " + ' [^ =>~ " ] ' ,
2017-09-26 15:54:14 +02:00
' description ' : ' Missing whitespace after " = " ' ,
' good_lines ' : [ ' a = b ' , ' 5 == 6 ' ] ,
' bad_lines ' : [ ' a =b ' , ' asdf =42 ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' " : \ w[^ " ]*$ ' ,
2017-09-26 15:54:14 +02:00
' description ' : ' Missing whitespace after " : " ' ,
2019-10-03 02:01:36 +02:00
' exclude ' : set ( [ ' zerver/tests/test_push_notifications.py ' ] ) ,
2017-09-26 15:54:14 +02:00
' good_lines ' : [ ' " foo " : bar ' , ' " some:string:with:colons " ' ] ,
' bad_lines ' : [ ' " foo " :bar ' , ' " foo " :1 ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r " ' : \ w[^ ' ]*$ " ,
2017-09-26 15:54:14 +02:00
' description ' : ' Missing whitespace after " : " ' ,
' good_lines ' : [ " ' foo ' : bar " , " ' some:string:with:colons ' " ] ,
' bad_lines ' : [ " ' foo ' :bar " , " ' foo ' :1 " ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r " ^ \ s+# \ w " ,
2017-06-05 16:29:04 +02:00
' strip ' : ' \n ' ,
2017-10-29 02:02:58 +01:00
' exclude ' : set ( [ ' tools/droplets/create.py ' ] ) ,
2017-09-26 15:54:14 +02:00
' description ' : ' Missing whitespace after " # " ' ,
' good_lines ' : [ ' a = b # some operation ' , ' 1+2 # 3 is the result ' ] ,
' bad_lines ' : [ ' #some operation ' , ' #not valid!!! ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " assertEquals[(] " ,
2017-09-26 15:54:14 +02:00
' description ' : ' Use assertEqual, not assertEquals (which is deprecated). ' ,
' good_lines ' : [ ' assertEqual(1, 2) ' ] ,
' bad_lines ' : [ ' assertEquals(1, 2) ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " == None " ,
2017-09-26 15:54:14 +02:00
' description ' : ' Use `is None` to check whether something is None ' ,
' good_lines ' : [ ' if foo is None ' ] ,
' bad_lines ' : [ ' foo == None ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " type:[(] " ,
2017-09-26 15:54:14 +02:00
' description ' : ' Missing whitespace after " : " in type annotation ' ,
' good_lines ' : [ ' # type: (Any, Any) ' , ' colon:separated:string:containing:type:as:keyword ' ] ,
' bad_lines ' : [ ' # type:(Any, Any) ' ] } ,
2017-07-28 00:59:36 +02:00
{ ' pattern ' : " type: ignore$ " ,
' exclude ' : set ( [ ' tools/tests ' ,
' zerver/lib/test_runner.py ' ,
' zerver/tests ' ] ) ,
2017-11-08 19:35:35 +01:00
' description ' : ' " type: ignore " should always end with " # type: ignore # explanation for why " ' ,
' good_lines ' : [ ' foo = bar # type: ignore # explanation ' ] ,
' bad_lines ' : [ ' foo = bar # type: ignore ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " # type [(] " ,
2017-11-08 19:35:35 +01:00
' description ' : ' Missing : after type in type annotation ' ,
' good_lines ' : [ ' foo = 42 # type: int ' , ' # type: (str, int) -> None ' ] ,
' bad_lines ' : [ ' # type (str, int) -> None ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " #type " ,
2017-11-08 19:35:35 +01:00
' description ' : ' Missing whitespace after " # " in type annotation ' ,
' good_lines ' : [ ' foo = 42 # type: int ' ] ,
' bad_lines ' : [ ' foo = 42 #type: int ' ] } ,
2017-10-05 15:09:46 +02:00
{ ' pattern ' : r ' \ b(if|else|while)[(] ' ,
' description ' : ' Put a space between statements like if, else, etc. and (. ' ,
' good_lines ' : [ ' if (1 == 2): ' , ' while (foo == bar): ' ] ,
' bad_lines ' : [ ' if(1 == 2): ' , ' while(foo == bar): ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " , [)] " ,
2017-11-08 19:35:35 +01:00
' description ' : ' Unnecessary whitespace between " , " and " ) " ' ,
' good_lines ' : [ ' foo = (1, 2, 3,) ' , ' foo(bar, 42) ' ] ,
' bad_lines ' : [ ' foo = (1, 2, 3, ) ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " % [(] " ,
2017-11-08 19:35:35 +01:00
' description ' : ' Unnecessary whitespace between " % " and " ( " ' ,
' good_lines ' : [ ' " foo %s bar " % ( " baz " ,) ' ] ,
' bad_lines ' : [ ' " foo %s bar " % ( " baz " ,) ' ] } ,
2017-06-05 16:29:04 +02:00
# 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.
2019-04-20 03:05:14 +02:00
{ ' pattern ' : r """ ^(?:[^ ' " # \ \ ]| {} | {} )*(?: {} | {} ) \ s* % \ s*(?![ \ s( {{ \ \ ]|dict \ (|tuple \ ()(?:[^, {} ]| {} )+(?:$|[,# \ \ ]| {} ) """ . format (
PYSQ , PYDQ , PYSQ , PYDQ , PYDELIMS , PYGROUP , PYRIGHT ) ,
' description ' : ' Used % f ormatting without a tuple ' ,
2017-11-08 19:35:35 +01:00
' good_lines ' : [ ' " foo %s bar " % ( " baz " ,) ' ] ,
' bad_lines ' : [ ' " foo %s bar " % " baz " ' ] } ,
2019-04-20 03:05:14 +02:00
{ ' pattern ' : r """ ^(?:[^ ' " # \ \ ]| {} | {} )*(?: {} | {} ) \ s* % \ s* \ ((?:[^, {} ]| {} )* \ ) """ . format (
PYSQ , PYDQ , PYSQ , PYDQ , PYDELIMS , PYGROUP ) ,
' description ' : ' Used % f ormatting with parentheses that do not form a tuple ' ,
2017-11-08 19:35:35 +01:00
' good_lines ' : [ ' " foo %s bar " % ( " baz " ,) " ' ] ,
' bad_lines ' : [ ' " foo %s bar " % ( " baz " ) ' ] } ,
2018-03-02 01:27:08 +01:00
{ ' pattern ' : ' sudo ' ,
' include_only ' : set ( [ ' scripts/ ' ] ) ,
' exclude ' : set ( [ ' scripts/lib/setup_venv.py ' ] ) ,
' exclude_line ' : set ( [
2019-02-26 20:20:46 +01:00
( ' scripts/lib/zulip_tools.py ' , ' sudo_args = kwargs.pop( \' sudo_args \' , []) ' ) ,
( ' scripts/lib/zulip_tools.py ' , ' args = [ \' sudo \' ] + sudo_args + [ \' -- \' ] + args ' ) ,
2018-03-02 01:27:08 +01:00
] ) ,
' description ' : ' Most scripts are intended to run on systems without sudo. ' ,
' good_lines ' : [ ' subprocess.check_call([ " ls " ]) ' ] ,
' bad_lines ' : [ ' subprocess.check_call([ " sudo " , " ls " ]) ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' django.utils.translation ' ,
2019-05-15 22:40:33 +02:00
' include_only ' : set ( [ ' test/ ' , ' zerver/views/development/ ' ] ) ,
2017-11-08 19:35:35 +01:00
' description ' : ' Test strings should not be tagged for translation ' ,
' good_lines ' : [ ' ' ] ,
' bad_lines ' : [ ' django.utils.translation ' ] } ,
2017-10-07 17:55:36 +02:00
{ ' pattern ' : ' userid ' ,
2017-11-08 19:35:35 +01:00
' description ' : ' We prefer user_id over userid. ' ,
' good_lines ' : [ ' id = alice.user_id ' ] ,
' bad_lines ' : [ ' id = alice.userid ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' json_success \ ( {} \ ) ' ,
2017-11-08 19:35:35 +01:00
' description ' : ' Use json_success() to return nothing ' ,
' good_lines ' : [ ' return json_success() ' ] ,
' bad_lines ' : [ ' return json_success( {} ) ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' \ Wjson_error \ (_ \ (? \ w+ \ ) ' ,
2019-05-15 22:40:33 +02:00
' exclude ' : set ( [ ' zerver/tests ' , ' zerver/views/development/ ' ] ) ,
2017-11-08 19:35:35 +01:00
' description ' : ' Argument to json_error should be a literal string enclosed by _() ' ,
' good_lines ' : [ ' return json_error(_( " string " )) ' ] ,
' bad_lines ' : [ ' return json_error(_variable) ' , ' return json_error(_(variable)) ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ''' \ Wjson_error \ ([ ' " ].+[),]$ ''' ,
2017-06-05 16:29:04 +02:00
' exclude ' : set ( [ ' zerver/tests ' ] ) ,
' description ' : ' Argument to json_error should a literal string enclosed by _() ' } ,
# To avoid JsonableError(_variable) and JsonableError(_(variable))
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' \ WJsonableError \ (_ \ (? \ w.+ \ ) ' ,
2019-05-15 22:40:33 +02:00
' exclude ' : set ( [ ' zerver/tests ' , ' zerver/views/development/ ' ] ) ,
2017-06-05 16:29:04 +02:00
' description ' : ' Argument to JsonableError should be a literal string enclosed by _() ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ''' \ WJsonableError \ ([ " ' ].+ \ ) ''' ,
2019-05-15 22:40:33 +02:00
' exclude ' : set ( [ ' zerver/tests ' , ' zerver/views/development/ ' ] ) ,
2017-06-05 16:29:04 +02:00
' description ' : ' Argument to JsonableError should be a literal string enclosed by _() ' } ,
2019-04-20 03:49:14 +02:00
{ ' pattern ' : r """ \ b_ \ ((?: \ s| {} | {} )*[^ \ s ' " )] """ . format ( PYSQ , PYDQ ) ,
' description ' : ' Called _() on a computed string ' ,
' exclude_line ' : set ( [
( ' zerver/lib/i18n.py ' , ' result = _(string) ' ) ,
] ) ,
' good_lines ' : [ " return json_error(_( ' No presence data for %s ' ) % (target.email,)) " ] ,
' bad_lines ' : [ " return json_error(_( ' No presence data for %s ' % (target.email,))) " ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ''' ([a-zA-Z0-9_]+)=REQ \ ([ ' " ] \ 1[ ' " ] ''' ,
2017-06-05 16:29:04 +02:00
' description ' : ' REQ \' s first argument already defaults to parameter name ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' self \ .client \ .(get|post|patch|put|delete) ' ,
2017-06-05 16:29:04 +02:00
' description ' : \
''' Do not call self.client directly for put/patch/post/get.
See WRAPPER_COMMENT in test_helpers . py for details .
''' },
# Directly fetching Message objects in e.g. views code is often a security bug.
2017-09-27 09:47:46 +02:00
{ ' pattern ' : ' [^r]Message.objects.get ' ,
2017-08-02 06:02:06 +02:00
' exclude ' : set ( [ " zerver/tests " ,
" zerver/lib/onboarding.py " ,
2017-08-06 09:56:29 +02:00
" zilencer/management/commands/add_mock_conversation.py " ,
2019-05-10 14:28:38 +02:00
" zerver/worker/queue_processors.py " ,
" zerver/management/commands/export.py " ,
" zerver/lib/export.py " ] ) ,
2017-06-05 16:29:04 +02:00
' description ' : ' Please use access_message() to fetch Message objects ' ,
} ,
2017-09-27 09:47:46 +02:00
{ ' pattern ' : ' Stream.objects.get ' ,
2017-06-05 16:29:04 +02:00
' include_only ' : set ( [ " zerver/views/ " ] ) ,
' description ' : ' Please use access_stream_by_*() to fetch Stream objects ' ,
} ,
{ ' pattern ' : ' get_stream[(] ' ,
' include_only ' : set ( [ " zerver/views/ " , " zerver/lib/actions.py " ] ) ,
' exclude_line ' : set ( [
# This one in check_message is kinda terrible, since it's
# how most instances are written, but better to exclude something than nothing
( ' zerver/lib/actions.py ' , ' stream = get_stream(stream_name, realm) ' ) ,
2017-10-04 02:01:22 +02:00
( ' zerver/lib/actions.py ' , ' get_stream(admin_realm_signup_notifications_stream, admin_realm) ' ) ,
2017-06-05 16:29:04 +02:00
] ) ,
' description ' : ' Please use access_stream_by_*() to fetch Stream objects ' ,
} ,
2017-09-27 09:47:46 +02:00
{ ' pattern ' : ' Stream.objects.filter ' ,
2017-06-05 16:29:04 +02:00
' include_only ' : set ( [ " zerver/views/ " ] ) ,
' description ' : ' Please use access_stream_by_*() to fetch Stream objects ' ,
} ,
{ ' pattern ' : ' ^from (zerver|analytics|confirmation) ' ,
' include_only ' : set ( [ " /migrations/ " ] ) ,
2017-09-01 14:22:18 +02:00
' exclude ' : set ( [
' zerver/migrations/0032_verify_all_medium_avatar_images.py ' ,
' zerver/migrations/0060_move_avatars_to_be_uid_based.py ' ,
' zerver/migrations/0104_fix_unreads.py ' ,
2019-01-11 13:48:22 +01:00
' zerver/migrations/0206_stream_rendered_description.py ' ,
2019-11-18 07:57:36 +01:00
' zerver/migrations/0209_user_profile_no_empty_password.py ' ,
2018-05-31 02:34:15 +02:00
' pgroonga/migrations/0002_html_escape_subject.py ' ,
2017-09-01 14:22:18 +02:00
] ) ,
2017-11-08 17:55:36 +01:00
' description ' : " Don ' t import models or other code in migrations; see docs/subsystems/schema-migrations.md " ,
2017-06-05 16:29:04 +02:00
} ,
{ ' pattern ' : ' datetime[.](now|utcnow) ' ,
' include_only ' : set ( [ " zerver/ " , " analytics/ " ] ) ,
' description ' : " Don ' t use datetime in backend code. \n "
2017-11-08 17:55:36 +01:00
" See https://zulip.readthedocs.io/en/latest/contributing/code-style.html#naive-datetime-objects " ,
2017-06-05 16:29:04 +02:00
} ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' render_to_response \ ( ' ,
2017-06-05 16:29:04 +02:00
' description ' : " Use render() instead of render_to_response(). " ,
} ,
2017-09-22 08:15:01 +02:00
{ ' pattern ' : ' from os.path ' ,
' description ' : " Don ' t use from when importing from the standard library " ,
} ,
2017-09-22 18:30:18 +02:00
{ ' pattern ' : ' import os.path ' ,
' description ' : " Use import os instead of import os.path " ,
} ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' (logging|logger) \ .warn \ W ' ,
2017-10-02 11:12:52 +02:00
' description ' : " Logger.warn is a deprecated alias for Logger.warning; Use ' warning ' instead of ' warn ' . " ,
' good_lines ' : [ " logging.warning( ' I am a warning. ' ) " , " logger.warning( ' warning ' ) " ] ,
' bad_lines ' : [ " logging.warn( ' I am a warning. ' ) " , " logger.warn( ' warning ' ) " ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' \ .pk ' ,
2017-10-06 13:17:23 +02:00
' exclude_pattern ' : ' [.]_meta[.]pk ' ,
' description ' : " Use `id` instead of `pk`. " ,
' good_lines ' : [ ' if my_django_model.id == 42 ' , ' self.user_profile._meta.pk ' ] ,
2017-10-18 11:12:55 +02:00
' bad_lines ' : [ ' if my_django_model.pk == 42 ' ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' ^[ ]*# type: \ ( ' ,
2018-03-12 00:09:33 +01:00
' exclude ' : set ( [
# These directories, especially scripts/ and puppet/,
# have tools that need to run before a Zulip environment
# is provisioned; in some of those, the `typing` module
# might not be available yet, so care is required.
' scripts/ ' ,
' tools/ ' ,
' puppet/ ' ,
# Zerver files that we should just clean.
' zerver/tests ' ,
2019-08-04 18:14:48 +02:00
' zerver/openapi/python_examples.py ' ,
2018-03-12 00:09:33 +01:00
' zerver/lib/request.py ' ,
' zerver/views/streams.py ' ,
# thumbor is (currently) python2 only
' zthumbor/ ' ,
] ) ,
' description ' : ' Comment-style function type annotation. Use Python3 style annotations instead. ' ,
} ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' = models[.].*null=True.* \ ) # type: (?!Optional) ' ,
2018-03-25 03:32:04 +02:00
' include_only ' : { " zerver/models.py " } ,
' description ' : ' Model variable with null=true not annotated as Optional. ' ,
' good_lines ' : [ ' desc = models.TextField(null=True) # type: Optional[Text] ' ,
' stream = models.ForeignKey(Stream, null=True, on_delete=CASCADE) # type: Optional[Stream] ' ,
' desc = models.TextField() # type: Text ' ,
' stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Stream ' ] ,
' bad_lines ' : [ ' desc = models.CharField(null=True) # type: Text ' ,
' stream = models.ForeignKey(Stream, null=True, on_delete=CASCADE) # type: Stream ' ] ,
} ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' = models[.](?!NullBoolean).* \ ) # type: Optional ' , # Optional tag, except NullBoolean(Field)
2018-03-26 00:00:44 +02:00
' exclude_pattern ' : ' null=True ' ,
' include_only ' : { " zerver/models.py " } ,
' description ' : ' Model variable annotated with Optional but variable does not have null=true. ' ,
' good_lines ' : [ ' desc = models.TextField(null=True) # type: Optional[Text] ' ,
' stream = models.ForeignKey(Stream, null=True, on_delete=CASCADE) # type: Optional[Stream] ' ,
' desc = models.TextField() # type: Text ' ,
' stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Stream ' ] ,
' bad_lines ' : [ ' desc = models.TextField() # type: Optional[Text] ' ,
' stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Optional[Stream] ' ] ,
} ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' [ \ s([]Text([^ \ s \ w]|$) ' ,
2018-05-14 01:46:08 +02:00
' exclude ' : set ( [
# We are likely to want to keep these dirs Python 2+3 compatible,
# since the plan includes extracting them to a separate project eventually.
' tools/lib ' ,
# TODO: Update our migrations from Text->str.
' zerver/migrations/ ' ,
# thumbor is (currently) python2 only
' zthumbor/ ' ,
] ) ,
' description ' : " Now that we ' re a Python 3 only codebase, we don ' t need to use typing.Text. Please use str instead. " ,
} ,
2019-05-16 14:20:36 +02:00
{ ' pattern ' : ' exit[(]1[)] ' ,
' include_only ' : set ( [ " /management/commands/ " ] ) ,
' description ' : ' Raise CommandError to exit with failure in management commands ' ,
} ,
2019-12-08 20:08:25 +01:00
{ ' pattern ' : ' .is_realm_admin = ' ,
' description ' : ' Use do_change_is_admin function rather than setting UserProfile \' s is_realm_admin attribute directly. ' ,
' exclude ' : set ( [
' zerver/migrations/0248_userprofile_role_start.py ' ,
' zerver/tests/test_users.py ' ,
] ) ,
} ,
{ ' pattern ' : ' .is_guest = ' ,
' description ' : ' Use do_change_is_guest function rather than setting UserProfile \' s is_guest attribute directly. ' ,
' exclude ' : set ( [
' zerver/migrations/0248_userprofile_role_start.py ' ,
' zerver/tests/test_users.py ' ,
] ) ,
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* whitespace_rules ,
* comma_whitespace_rule ,
] ,
2019-05-30 17:41:23 +02:00
max_length = 110 ,
2019-06-12 18:37:03 +02:00
shebang_rules = shebang_rules ,
2019-05-30 17:41:23 +02:00
)
bash_rules = RuleList (
langs = [ ' bash ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' #!.*sh [-xe] ' ,
' description ' : ' Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches '
' to set -x|set -e ' } ,
2018-03-02 01:27:08 +01:00
{ ' pattern ' : ' sudo ' ,
' description ' : ' Most scripts are intended to work on systems without sudo ' ,
' include_only ' : set ( [ ' scripts/ ' ] ) ,
' exclude ' : set ( [
' scripts/lib/install ' ,
' scripts/setup/configure-rabbitmq '
] ) , } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* whitespace_rules [ 0 : 1 ] ,
] ,
2019-06-12 18:37:03 +02:00
shebang_rules = shebang_rules ,
2019-05-30 17:41:23 +02:00
)
css_rules = RuleList (
langs = [ ' css ' , ' scss ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' calc \ ([^+]+ \ +[^+]+ \ ) ' ,
2018-02-25 19:49:13 +01:00
' description ' : " Avoid using calc with ' + ' operator. See #8403 : in CSS. " ,
' good_lines ' : [ " width: calc(20 % - -14px); " ] ,
' bad_lines ' : [ " width: calc(20 % + 14px); " ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' ^[^:]*: \ S[^:]*;$ ' ,
2017-12-01 17:11:55 +01:00
' description ' : " Missing whitespace after : in CSS " ,
' good_lines ' : [ " background-color: white; " , " text-size: 16px; " ] ,
' bad_lines ' : [ " background-color:white; " , " text-size:16px; " ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' [a-z] { ' ,
2017-12-01 17:11:55 +01:00
' description ' : " Missing whitespace before ' { ' in CSS. " ,
' good_lines ' : [ " input { " , " body { " ] ,
' bad_lines ' : [ " input { " , " body { " ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' https:// ' ,
2017-12-01 17:11:55 +01:00
' description ' : " Zulip CSS should have no dependencies on external resources " ,
' good_lines ' : [ ' background: url(/static/images/landing-page/pycon.jpg); ' ] ,
' bad_lines ' : [ ' background: url(https://example.com/image.png); ' ] } ,
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' ^[ ][ ][a-zA-Z0-9] ' ,
' description ' : " Incorrect 2-space indentation in CSS " ,
2017-12-01 17:11:55 +01:00
' strip ' : ' \n ' ,
' good_lines ' : [ " color: white; " , " color: white; " ] ,
' bad_lines ' : [ " color: white; " ] } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' { \ w ' ,
2017-12-01 17:11:55 +01:00
' description ' : " Missing whitespace after ' { ' in CSS (should be newline). " ,
' good_lines ' : [ " { \n " ] ,
' bad_lines ' : [ " { color: LightGoldenRodYellow; " ] } ,
{ ' pattern ' : ' thin[ ;] ' ,
' description ' : " thin CSS attribute is under-specified, please use 1px. " ,
' good_lines ' : [ " border-width: 1px; " ] ,
' bad_lines ' : [ " border-width: thin; " , " border-width: thin solid black; " ] } ,
{ ' pattern ' : ' medium[ ;] ' ,
' description ' : " medium CSS attribute is under-specified, please use pixels. " ,
' good_lines ' : [ " border-width: 3px; " ] ,
' bad_lines ' : [ " border-width: medium; " , " border: medium solid black; " ] } ,
{ ' pattern ' : ' thick[ ;] ' ,
' description ' : " thick CSS attribute is under-specified, please use pixels. " ,
' good_lines ' : [ " border-width: 5px; " ] ,
' bad_lines ' : [ " border-width: thick; " , " border: thick solid black; " ] } ,
2019-06-19 17:30:13 +02:00
{ ' pattern ' : r ' rgba? \ ( ' ,
' description ' : ' Use of rgb(a) format is banned, Please use hsl(a) instead ' ,
' good_lines ' : [ ' hsl(0, 0 % , 0 % ) ' , ' hsla(0, 0 % , 100 % , 0.1) ' ] ,
' bad_lines ' : [ ' rgb(0, 0, 0) ' , ' rgba(255, 255, 255, 0.1) ' ] } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* whitespace_rules ,
* comma_whitespace_rule ,
] ,
2019-05-30 17:41:23 +02:00
)
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
prose_style_rules = [
2019-05-30 17:41:23 +02:00
{ ' pattern ' : r ' [^ \ / \ # \ - " ]([jJ]avascript) ' , # exclude usage in hrefs/divs
2019-07-20 02:45:21 +02:00
' exclude ' : set ( [ " docs/documentation/api.md " ] ) ,
2019-05-30 17:41:23 +02:00
' description ' : " javascript should be spelled JavaScript " } ,
{ ' pattern ' : r ''' [^ \ / \ - \ . " ' \ _ \ = \ >]([gG]ithub)[^ \ . \ - \ _ " \ <] ''' , # exclude usage in hrefs/divs
' description ' : " github should be spelled GitHub " } ,
{ ' pattern ' : ' [oO]rganisation ' , # exclude usage in hrefs/divs
' description ' : " Organization is spelled with a z " ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
' exclude_line ' : { ( ' docs/translating/french.md ' , ' * organization - **organisation** ' ) } } ,
2019-05-30 17:41:23 +02:00
{ ' pattern ' : ' !!! warning ' ,
' description ' : " !!! warning is invalid; it ' s spelled ' !!! warn ' " } ,
{ ' pattern ' : ' Terms of service ' ,
' description ' : " The S in Terms of Service is capitalized " } ,
2019-08-29 01:17:31 +02:00
{ ' pattern ' : ' [^-_p]botserver(?!rc)|bot server ' ,
2019-05-30 17:41:23 +02:00
' description ' : " Use Botserver instead of botserver or bot server. " } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
* comma_whitespace_rule ,
] # type: List[Rule]
html_rules = whitespace_rules + prose_style_rules + [
2019-05-30 17:41:23 +02:00
{ ' pattern ' : ' subject|SUBJECT ' ,
' exclude ' : set ( [ ' templates/zerver/email.html ' ] ) ,
' exclude_pattern ' : ' email subject ' ,
' description ' : ' avoid subject in templates ' ,
' good_lines ' : [ ' topic_name ' ] ,
' bad_lines ' : [ ' subject= " foo " ' , ' MAX_SUBJECT_LEN ' ] } ,
{ ' pattern ' : r ' placeholder= " [^ { #](?:(?! \ .com).)+$ ' ,
' description ' : " `placeholder` value should be translatable. " ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
' exclude_line ' : { ( ' templates/zerver/register.html ' , ' placeholder= " acme " ' ) ,
( ' templates/zerver/register.html ' , ' placeholder= " Acme or Aκμή " ' ) } ,
2019-05-30 17:41:23 +02:00
' exclude ' : set ( [ " templates/analytics/support.html " ] ) ,
' good_lines ' : [ ' <input class= " stream-list-filter " type= " text " placeholder= " {{ _( \' Search streams \' ) }} " /> ' ] ,
' bad_lines ' : [ ' <input placeholder= " foo " > ' ] } ,
{ ' pattern ' : " placeholder= ' [^ { ] " ,
' description ' : " `placeholder` value should be translatable. " ,
' good_lines ' : [ ' <input class= " stream-list-filter " type= " text " placeholder= " {{ _( \' Search streams \' ) }} " /> ' ] ,
' bad_lines ' : [ " <input placeholder= ' foo ' > " ] } ,
{ ' pattern ' : " aria-label= ' [^ { ] " ,
' description ' : " `aria-label` value should be translatable. " ,
' good_lines ' : [ ' <button type= " button " class= " close close-alert-word-status " aria-label= " {{ t \' Close \' }} " > ' ] ,
' bad_lines ' : [ " <button aria-label= ' foo ' ></button> " ] } ,
{ ' pattern ' : ' aria-label= " [^ { ] ' ,
' description ' : " `aria-label` value should be translatable. " ,
' good_lines ' : [ ' <button type= " button " class= " close close-alert-word-status " aria-label= " {{ t \' Close \' }} " > ' ] ,
' bad_lines ' : [ ' <button aria-label= " foo " ></button> ' ] } ,
{ ' pattern ' : ' script src= " http ' ,
2019-10-23 18:23:25 +02:00
' description ' : " Don ' t directly load dependencies from CDNs. See docs/subsystems/html-css.md " ,
2019-05-30 17:41:23 +02:00
' exclude ' : set ( [ " templates/corporate/billing.html " , " templates/zerver/hello.html " ,
" templates/corporate/upgrade.html " ] ) ,
2019-10-22 02:14:28 +02:00
' good_lines ' : [ " {{ render_entrypoint( ' landing-page ' ) }} " ] ,
2019-05-30 17:41:23 +02:00
' bad_lines ' : [ ' <script src= " https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js " ></script> ' ] } ,
{ ' pattern ' : " title= ' [^ { ] " ,
' description ' : " `title` value should be translatable. " ,
' good_lines ' : [ ' <link rel= " author " title= " {{ _( \' About these documents \' ) }} " /> ' ] ,
' bad_lines ' : [ " <p title= ' foo ' ></p> " ] } ,
{ ' pattern ' : r ' title= " [^ { \ :] ' ,
' exclude_line ' : set ( [
( ' templates/zerver/app/markdown_help.html ' ,
' <td class= " rendered_markdown " ><img alt= " :heart: " class= " emoji " src= " /static/generated/emoji/images/emoji/heart.png " title= " :heart: " /></td> ' )
] ) ,
2019-09-18 15:04:36 +02:00
' exclude ' : set ( [ " templates/zerver/emails " , " templates/analytics/realm_details.html " , " templates/analytics/support.html " ] ) ,
2019-05-30 17:41:23 +02:00
' description ' : " `title` value should be translatable. " } ,
{ ' pattern ' : r ''' \ Walt=[ " ' ][^ { " ' ] ''' ,
' description ' : " alt argument should be enclosed by _() or it should be an empty string. " ,
2019-07-12 00:52:56 +02:00
' exclude ' : set ( [ ' static/templates/settings/display_settings.hbs ' ,
2019-05-30 17:41:23 +02:00
' templates/zerver/app/keyboard_shortcuts.html ' ,
' templates/zerver/app/markdown_help.html ' ] ) ,
' good_lines ' : [ ' <img src= " {{ source_url}} " alt= " {{ _(name) }} " /> ' , ' <img alg= " " /> ' ] ,
' bad_lines ' : [ ' <img alt= " Foo Image " /> ' ] } ,
{ ' pattern ' : r ''' \ Walt=[ " ' ] {{ ?[ " ' ] ''' ,
' description ' : " alt argument should be enclosed by _(). " ,
' good_lines ' : [ ' <img src= " {{ source_url}} " alt= " {{ _(name) }} " /> ' ] ,
' bad_lines ' : [ ' <img alt= " {{ " /> ' ] } ,
{ ' pattern ' : r ' \ bon \ w+ ?= ' ,
' description ' : " Don ' t use inline event handlers (onclick=, etc. attributes) in HTML. Instead, "
" attach a jQuery event handler ($( ' #foo ' ).on( ' click ' , function () { ...})) when "
" the DOM is ready (inside a $(function () { ...}) block). " ,
' exclude ' : set ( [ ' templates/zerver/dev_login.html ' , ' templates/corporate/upgrade.html ' ] ) ,
' good_lines ' : [ " ($( ' #foo ' ).on( ' click ' , function () {} " ] ,
' bad_lines ' : [ " <button id= ' foo ' onclick= ' myFunction() ' >Foo</button> " , " <input onchange= ' myFunction() ' > " ] } ,
{ ' pattern ' : ' style ?= ' ,
' description ' : " Avoid using the `style=` attribute; we prefer styling in CSS files " ,
' exclude_pattern ' : r ' .*style ?=[ " ' + " ' " + ' ](display: ?none|background: {{ |color: {{ |background-color: {{ ).* ' ,
' exclude ' : set ( [
# KaTeX output uses style attribute
' templates/zerver/app/markdown_help.html ' ,
# 5xx page doesn't have external CSS
' static/html/5xx.html ' ,
# Group PMs color is dynamically calculated
2019-07-12 00:52:56 +02:00
' static/templates/group_pms.hbs ' ,
2019-05-30 17:41:23 +02:00
# exclude_pattern above handles color, but have other issues:
2019-07-12 00:52:56 +02:00
' static/templates/draft.hbs ' ,
' static/templates/subscription.hbs ' ,
' static/templates/single_message.hbs ' ,
2019-05-30 17:41:23 +02:00
# Old-style email templates need to use inline style
# attributes; it should be possible to clean these up
# when we convert these templates to use premailer.
' templates/zerver/emails/email_base_messages.html ' ,
# Email log templates; should clean up.
' templates/zerver/email.html ' ,
' templates/zerver/email_log.html ' ,
2019-10-22 18:11:28 +02:00
# Social backend logos are dynamically loaded
' templates/zerver/accounts_home.html ' ,
' templates/zerver/login.html ' ,
2019-05-30 17:41:23 +02:00
# Probably just needs to be changed to display: none so the exclude works
' templates/zerver/app/navbar.html ' ,
# Needs the width cleaned up; display: none is fine
2019-07-12 00:52:56 +02:00
' static/templates/settings/account_settings.hbs ' ,
2019-05-30 17:41:23 +02:00
# background image property is dynamically generated
2019-07-12 00:52:56 +02:00
' static/templates/user_profile_modal.hbs ' ,
' static/templates/sidebar_private_message_list.hbs ' ,
2019-05-30 17:41:23 +02:00
# Inline styling for an svg; could be moved to CSS files?
' templates/zerver/landing_nav.html ' ,
' templates/zerver/billing_nav.html ' ,
' templates/zerver/app/home.html ' ,
' templates/zerver/features.html ' ,
' templates/zerver/portico-header.html ' ,
' templates/corporate/billing.html ' ,
' templates/corporate/upgrade.html ' ,
# Miscellaneous violations to be cleaned up
2019-07-12 00:52:56 +02:00
' static/templates/user_info_popover_title.hbs ' ,
' static/templates/subscription_invites_warning_modal.hbs ' ,
2019-05-30 17:41:23 +02:00
' templates/zerver/reset_confirm.html ' ,
' templates/zerver/config_error.html ' ,
' templates/zerver/dev_env_email_access_details.html ' ,
' templates/zerver/confirm_continue_registration.html ' ,
' templates/zerver/register.html ' ,
' templates/zerver/accounts_send_confirm.html ' ,
' templates/zerver/integrations/index.html ' ,
' templates/zerver/documentation_main.html ' ,
' templates/analytics/realm_summary_table.html ' ,
' templates/corporate/zephyr.html ' ,
' templates/corporate/zephyr-mirror.html ' ,
] ) ,
' good_lines ' : [ ' #my-style { color: blue;} ' , ' style= " display: none " ' , " style= ' display: none " ] ,
' bad_lines ' : [ ' <p style= " color: blue; " >Foo</p> ' , ' style = " color: blue; " ' ] } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] # type: List[Rule]
2019-05-30 17:41:23 +02:00
handlebars_rules = RuleList (
2019-07-12 00:52:56 +02:00
langs = [ ' hbs ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = html_rules + [
2017-06-05 16:29:04 +02:00
{ ' pattern ' : " [<]script " ,
' description ' : " Do not use inline <script> tags here; put JavaScript in static/js instead. " } ,
2017-06-10 12:32:06 +02:00
{ ' pattern ' : ' {{ t ( " | \' ) ' ,
' description ' : ' There should be no spaces before the " t " in a translation tag. ' } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r " {{ t ' .* ' }}[ \ . \ ?!] " ,
2017-06-05 16:29:04 +02:00
' description ' : " Period should be part of the translatable string. " } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' {{ t " .* " }}[ \ . \ ?!] ' ,
2017-06-05 16:29:04 +02:00
' description ' : " Period should be part of the translatable string. " } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r " {{ /tr}}[ \ . \ ?!] " ,
2017-06-05 16:29:04 +02:00
' description ' : " Period should be part of the translatable string. " } ,
2017-06-10 11:56:36 +02:00
{ ' pattern ' : ' {{ t ( " | \' ) ' ,
' description ' : ' Translatable strings should not have leading spaces. ' } ,
2017-06-10 12:11:33 +02:00
{ ' pattern ' : " {{ t ' [^ ' ]+ ' }} " ,
' description ' : ' Translatable strings should not have trailing spaces. ' } ,
{ ' pattern ' : ' {{ t " [^ " ]+ " }} ' ,
' description ' : ' Translatable strings should not have trailing spaces. ' } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
jinja2_rules = RuleList (
langs = [ ' html ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = html_rules + [
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r " { % e ndtrans % }[ \ . \ ?!] " ,
2017-06-05 16:29:04 +02:00
' description ' : " Period should be part of the translatable string. " } ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r " {{ _(.+) }}[ \ . \ ?!] " ,
2017-06-05 16:29:04 +02:00
' description ' : " Period should be part of the translatable string. " } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
)
json_rules = RuleList (
langs = [ ' json ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = [
2017-11-23 20:56:05 +01:00
# Here, we don't use `whitespace_rules`, because the tab-based
# whitespace rule flags a lot of third-party JSON fixtures
# under zerver/webhooks that we want preserved verbatim. So
# we just include the trailing whitespace rule and a modified
# version of the tab-based whitespace rule (we can't just use
# exclude in whitespace_rules, since we only want to ignore
# JSON files with tab-based whitespace, not webhook code).
2017-08-15 17:54:29 +02:00
trailing_whitespace_rule ,
2017-11-23 19:39:58 +01:00
{ ' pattern ' : ' \t ' ,
' strip ' : ' \n ' ,
2017-11-23 20:56:05 +01:00
' exclude ' : set ( [ ' zerver/webhooks/ ' ] ) ,
2017-11-23 19:39:58 +01:00
' description ' : ' Fix tab-based whitespace ' } ,
2018-07-23 21:02:07 +02:00
{ ' pattern ' : r ' " :[ " \ [ \ { ] ' ,
2018-04-19 20:17:24 +02:00
' exclude ' : set ( [ ' zerver/webhooks/ ' , ' zerver/tests/fixtures/ ' ] ) ,
2018-03-02 22:06:21 +01:00
' description ' : ' Require space after : in JSON ' } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
]
2019-05-30 17:41:23 +02:00
)
markdown_docs_length_exclude = {
# Has some example Vagrant output that's very long
" docs/development/setup-vagrant.md " ,
# Have wide output in code blocks
" docs/subsystems/logging.md " ,
2019-11-07 18:29:05 +01:00
" docs/subsystems/schema-migrations.md " ,
2019-05-30 17:41:23 +02:00
# Have curl commands with JSON that would be messy to wrap
" zerver/webhooks/helloworld/doc.md " ,
" zerver/webhooks/trello/doc.md " ,
# Has a very long configuration line
" templates/zerver/integrations/perforce.md " ,
# Has some example code that could perhaps be wrapped
" templates/zerver/api/incoming-webhooks-walkthrough.md " ,
# This macro has a long indented URL
" templates/zerver/help/include/git-webhook-url-with-branches-indented.md " ,
2019-10-18 09:00:43 +02:00
" templates/zerver/api/update-notification-settings.md " ,
2019-05-30 17:41:23 +02:00
# These two are the same file and have some too-long lines for GitHub badges
" README.md " ,
" docs/overview/readme.md " ,
}
markdown_rules = RuleList (
langs = [ ' md ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = markdown_whitespace_rules + prose_style_rules + [
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' \ [(?P<url>[^ \ ]]+) \ ] \ ((?P=url) \ ) ' ,
2017-11-16 21:44:16 +01:00
' description ' : ' Linkified markdown URLs should use cleaner <http://example.com> syntax. ' } ,
{ ' pattern ' : ' https://zulip.readthedocs.io/en/latest/[a-zA-Z0-9] ' ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
' exclude ' : { ' docs/overview/contributing.md ' , ' docs/overview/readme.md ' , ' docs/README.md ' } ,
2017-11-16 22:59:21 +01:00
' include_only ' : set ( [ ' docs/ ' ] ) ,
2018-04-24 02:28:14 +02:00
' description ' : " Use relative links (../foo/bar.html) to other documents in docs/ " ,
2017-11-16 21:44:16 +01:00
} ,
2018-11-30 21:08:25 +01:00
{ ' pattern ' : " su zulip -c [^ ' ] " ,
' include_only ' : set ( [ ' docs/ ' ] ) ,
' description ' : " Always quote arguments using `su zulip -c ' ` to avoid confusion about how su works. " ,
} ,
2018-07-02 00:05:24 +02:00
{ ' pattern ' : r ' \ ][(][^#h] ' ,
2017-11-16 21:44:16 +01:00
' include_only ' : set ( [ ' README.md ' , ' CONTRIBUTING.md ' ] ) ,
' description ' : " Use absolute links from docs served by GitHub " ,
} ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
max_length = 120 ,
length_exclude = markdown_docs_length_exclude ,
exclude_files_in = ' templates/zerver/help/ '
)
help_markdown_rules = RuleList (
langs = [ ' md ' ] ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
rules = markdown_rules . rules + [
2017-06-05 16:29:04 +02:00
{ ' pattern ' : ' [a-z][.][A-Z] ' ,
2019-05-30 17:41:23 +02:00
' description ' : " Likely missing space after end of sentence " ,
' include_only ' : set ( [ ' templates/zerver/help/ ' ] ) ,
} ,
2018-05-25 21:00:58 +02:00
{ ' pattern ' : r ' \ b[rR]ealm[s]? \ b ' ,
2019-05-30 17:41:23 +02:00
' include_only ' : set ( [ ' templates/zerver/help/ ' ] ) ,
2018-05-25 21:00:58 +02:00
' good_lines ' : [ ' Organization ' , ' deactivate_realm ' , ' realm_filter ' ] ,
' bad_lines ' : [ ' Users are in a realm ' , ' Realm is the best model ' ] ,
2017-06-05 16:29:04 +02:00
' description ' : " Realms are referred to as Organizations in user-facing docs. " } ,
linter_lib: Fix mypy errors.
tools/linter_lib/pyflakes.py:35: error: Argument 3 to "run_pyflakes" has incompatible type "List[Tuple[bytes, bytes]]"; expected "List[Tuple[str, str]]"
tools/linter_lib/custom_check.py:110: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:214: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:502: error: Argument "shebang_rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:519: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:706: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:728: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:738: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
tools/linter_lib/custom_check.py:779: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:803: error: Argument "length_exclude" to "RuleList" has incompatible type "Set[str]"; expected "List[str]"
tools/linter_lib/custom_check.py:805: error: Unsupported operand types for + ("List[Rule]" and "List[Dict[str, Any]]")
tools/linter_lib/custom_check.py:819: error: Argument "rules" to "RuleList" has incompatible type "List[Dict[str, Any]]"; expected "List[Rule]"
These were missed the `zulint` package was missing PEP 561 type
annotation markers, and if it’d had them, mypy daemon mode would’ve
required us to set `follow_imports = skip` for it.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-08-07 03:29:33 +02:00
] ,
2019-05-30 17:41:23 +02:00
length_exclude = markdown_docs_length_exclude ,
)
txt_rules = RuleList (
langs = [ ' txt ' , ' text ' , ' yaml ' , ' rst ' ] ,
rules = whitespace_rules ,
)
non_py_rules = [
handlebars_rules ,
jinja2_rules ,
css_rules ,
js_rules ,
json_rules ,
markdown_rules ,
help_markdown_rules ,
bash_rules ,
txt_rules ,
]