lint: Require python3 shebangs.

This commit was originally from @fredfishgames, but it
needed a big rebase due to use letting it sit too long.
Also, we decided not to have shebangs at the top of test
files.
This commit is contained in:
Steve Howell 2017-12-12 07:05:41 -06:00
parent 28687f18ca
commit fd069dff82
23 changed files with 10 additions and 36 deletions

View file

@ -166,7 +166,11 @@ def build_custom_checkers(by_lang):
# and comments which should be rewritten to avoid use of "python2", "python3", etc. # and comments which should be rewritten to avoid use of "python2", "python3", etc.
{'pattern': 'python[23]', {'pattern': 'python[23]',
'exclude': set(['tools/provision']), 'exclude': set(['tools/provision']),
'include_only': set(['zulip/', 'tools/', 'zulip_botserver/']),
'description': 'Explicit python invocations should not include a version'}, 'description': 'Explicit python invocations should not include a version'},
{'pattern': '#!/usr/bin/env python$',
'include_only': set(['zulip_bots/']),
'description': 'Python shebangs must be python3'},
{'pattern': '(^|\s)open\s*\(', {'pattern': '(^|\s)open\s*\(',
'description': 'open() should not be used in Zulip\'s bots. Use functions' 'description': 'open() should not be used in Zulip\'s bots. Use functions'
' provided by the bots framework to access the filesystem.', ' provided by the bots framework to access the filesystem.',

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
import argparse import argparse
import os import os

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function from __future__ import print_function

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
class TestChessBot(StubBotTestCase): class TestChessBot(StubBotTestCase):

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
class TestConverterBot(StubBotTestCase): class TestConverterBot(StubBotTestCase):

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
from unittest.mock import patch from unittest.mock import patch

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase, read_bot_fixture_data from zulip_bots.test_lib import StubBotTestCase, read_bot_fixture_data
from contextlib import contextmanager from contextlib import contextmanager

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
class TestEncryptBot(StubBotTestCase): class TestEncryptBot(StubBotTestCase):

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function from __future__ import print_function

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from unittest.mock import patch from unittest.mock import patch
from requests.exceptions import HTTPError, ConnectionError from requests.exceptions import HTTPError, ConnectionError

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import ( from zulip_bots.test_lib import (
StubBotHandler, StubBotHandler,
StubBotTestCase, StubBotTestCase,

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
from unittest.mock import patch from unittest.mock import patch

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
class TestHelpBot(StubBotTestCase): class TestHelpBot(StubBotTestCase):

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
from typing import Any from typing import Any

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
import mock import mock
from zulip_bots.test_lib import ( from zulip_bots.test_lib import (

View file

@ -1,4 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
class TestTictactoeBot(StubBotTestCase): class TestTictactoeBot(StubBotTestCase):

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase
from zulip_bots.request_test_lib import mock_request_exception from zulip_bots.request_test_lib import mock_request_exception

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
import mock import mock
from mock import MagicMock, patch from mock import MagicMock, patch
from zulip_bots.test_lib import StubBotTestCase from zulip_bots.test_lib import StubBotTestCase

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from __future__ import absolute_import from __future__ import absolute_import
from unittest.mock import patch from unittest.mock import patch

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
from __future__ import absolute_import from __future__ import absolute_import

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
from __future__ import print_function from __future__ import print_function
from __future__ import absolute_import from __future__ import absolute_import

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
import os import os
import sys import sys
import argparse import argparse

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
from __future__ import absolute_import from __future__ import absolute_import
import importlib import importlib