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.
{'pattern': 'python[23]',
'exclude': set(['tools/provision']),
'include_only': set(['zulip/', 'tools/', 'zulip_botserver/']),
'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*\(',
'description': 'open() should not be used in Zulip\'s bots. Use functions'
' 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 os

View file

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

View file

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

View file

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

View file

@ -1,5 +1,3 @@
#!/usr/bin/env python
from zulip_bots.test_lib import StubBotTestCase
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 contextlib import contextmanager

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
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 absolute_import

View file

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

View file

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