mirror of https://github.com/zulip/zulip.git
Add lint rule to disallow python calls with versions (e.g: python2, python3)
Fixes #2435
This commit is contained in:
parent
f826c87a73
commit
c0326d1938
|
@ -334,7 +334,14 @@ def build_custom_checkers(by_lang):
|
||||||
'''Do not call self.client directly for put/patch/post/get.
|
'''Do not call self.client directly for put/patch/post/get.
|
||||||
See WRAPPER_COMMENT in test_helpers.py for details.
|
See WRAPPER_COMMENT in test_helpers.py for details.
|
||||||
'''},
|
'''},
|
||||||
|
# This rule might give false positives in virtualenv setup files which should be excluded,
|
||||||
|
# and comments which should be rewritten to avoid use of "python2", "python3", etc.
|
||||||
|
{'pattern': 'python[23]',
|
||||||
|
'exclude': set(['tools/provision.py',
|
||||||
|
'tools/setup/setup_venvs.py',
|
||||||
|
'scripts/lib/setup_venv.py',
|
||||||
|
'tools/lint-all']),
|
||||||
|
'description': 'Explicit python invocations should not include a version'}
|
||||||
]) + whitespace_rules
|
]) + whitespace_rules
|
||||||
bash_rules = [
|
bash_rules = [
|
||||||
{'pattern': '#!.*sh [-xe]',
|
{'pattern': '#!.*sh [-xe]',
|
||||||
|
|
|
@ -19,7 +19,7 @@ except ImportError:
|
||||||
class ParserTestHappyPath(unittest.TestCase):
|
class ParserTestHappyPath(unittest.TestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
# This method should be remove when we quit from python2
|
# This method should be removed when we migrate to version 3 of Python
|
||||||
import six
|
import six
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
self.assertRaisesRegex = self.assertRaisesRegexp # type: ignore
|
self.assertRaisesRegex = self.assertRaisesRegexp # type: ignore
|
||||||
|
@ -136,7 +136,7 @@ class ParserTestSadPath(unittest.TestCase):
|
||||||
'''
|
'''
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
# This method should be remove when we quit from python2
|
# This method should be removed when we migrate to version 3 of Python
|
||||||
import six
|
import six
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
self.assertRaisesRegex = self.assertRaisesRegexp # type: ignore
|
self.assertRaisesRegex = self.assertRaisesRegexp # type: ignore
|
||||||
|
|
|
@ -20,7 +20,7 @@ except ImportError:
|
||||||
class ParserTest(unittest.TestCase):
|
class ParserTest(unittest.TestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
# This method should be remove when we quit from python2
|
# This method should be removed when we migrate to version 3 of Python
|
||||||
import six
|
import six
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
self.assertRaisesRegex = self.assertRaisesRegexp # type: ignore
|
self.assertRaisesRegex = self.assertRaisesRegexp # type: ignore
|
||||||
|
|
|
@ -312,7 +312,7 @@ def user_profile_by_id_cache_key(user_profile_id):
|
||||||
return u"user_profile_by_id:%s" % (user_profile_id,)
|
return u"user_profile_by_id:%s" % (user_profile_id,)
|
||||||
|
|
||||||
# TODO: Refactor these cache helpers into another file that can import
|
# TODO: Refactor these cache helpers into another file that can import
|
||||||
# models.py so that python3-style type annotations can also work.
|
# models.py so that python v3 style type annotations can also work.
|
||||||
|
|
||||||
def cache_save_user_profile(user_profile):
|
def cache_save_user_profile(user_profile):
|
||||||
# type: (UserProfile) -> None
|
# type: (UserProfile) -> None
|
||||||
|
|
|
@ -80,7 +80,7 @@ class ZulipTestCase(TestCase):
|
||||||
'''
|
'''
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
# This method should be remove when we quit from python2
|
# This method should be removed when we migrate to version 3 of Python
|
||||||
import six
|
import six
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
self.assertRaisesRegex = self.assertRaisesRegexp
|
self.assertRaisesRegex = self.assertRaisesRegexp
|
||||||
|
|
|
@ -40,7 +40,7 @@ import ujson
|
||||||
class DecoratorTestCase(TestCase):
|
class DecoratorTestCase(TestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
# This method should be remove when we quit from python2
|
# This method should be removed when we migrate to version 3 of Python
|
||||||
import six
|
import six
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
self.assertRaisesRegex = self.assertRaisesRegexp
|
self.assertRaisesRegex = self.assertRaisesRegexp
|
||||||
|
|
Loading…
Reference in New Issue