lint: Prevent self: Any annotations.

We should omit these for mypy.  For most class definitions,
mypy doesn't need `Any`, and it provides no real useful info.

For clever monkeypatches, you should provide a more specific
type than `Any`.
This commit is contained in:
Steve Howell
2017-12-08 08:03:58 -08:00
committed by Greg Price
parent ac48772907
commit 738c73f08e
3 changed files with 6 additions and 2 deletions

View File

@@ -264,6 +264,10 @@ def build_custom_checkers(by_lang):
'description': 'Missing space around "%"',
'good_lines': ["'%s' % ('foo')", "'%s' % (foo)"],
'bad_lines': ["'%s'%('foo')", "'%s'%(foo)"]},
{'pattern': 'self: Any',
'description': 'you can omit Any annotation for self',
'good_lines': ['def foo (self):'],
'bad_lines': ['def foo(self: Any):']},
# This rule is constructed with + to avoid triggering on itself
{'pattern': " =" + '[^ =>~"]',
'description': 'Missing whitespace after "="',

View File

@@ -23,7 +23,7 @@ class AttachmentsTests(ZulipTestCase):
attachments = user_attachments(user_profile)
self.assertEqual(result.json()['attachments'], attachments)
def test_remove_attachment_exception(self: Any) -> None:
def test_remove_attachment_exception(self) -> None:
user_profile = self.example_user('cordelia')
self.login(user_profile.email)
with mock.patch('zerver.lib.attachments.delete_message_image', side_effect=Exception()):

View File

@@ -2269,7 +2269,7 @@ class UserSignUpTest(ZulipTestCase):
self.assertEqual(result.status_code, 302)
self.assertEqual(get_session_dict_user(self.client.session), user_profile.id)
def test_registration_of_active_mirror_dummy_user(self: Any) -> None:
def test_registration_of_active_mirror_dummy_user(self) -> None:
"""
Trying to activate an already-active mirror dummy user should
raise an AssertionError.