mirror of https://github.com/zulip/zulip.git
python: Whitespace fixes from autopep8.
Generated by autopep8, with the setup.cfg configuration from #14532. I’m not sure why pycodestyle didn’t already flag these. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
18b577f600
commit
1cf63eb5bf
|
@ -21,6 +21,7 @@ class UserHandler:
|
|||
We also sometimes need to build mirror
|
||||
users on the fly.
|
||||
'''
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.id_to_user_map = dict() # type: Dict[int, Dict[str, Any]]
|
||||
self.name_to_mirror_user_map = dict() # type: Dict[str, Dict[str, Any]]
|
||||
|
|
|
@ -9,6 +9,7 @@ class UserHandler:
|
|||
The class helps us do things like map ids
|
||||
to names for mentions.
|
||||
'''
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.id_to_user_map = dict() # type: Dict[int, Dict[str, Any]]
|
||||
|
||||
|
|
|
@ -1530,6 +1530,7 @@ class UserMessageLite:
|
|||
is optimized for the simple use case of inserting a bunch of
|
||||
rows into zerver_usermessage.
|
||||
'''
|
||||
|
||||
def __init__(self, user_profile_id: int, message_id: int, flags: int) -> None:
|
||||
self.user_profile_id = user_profile_id
|
||||
self.message_id = message_id
|
||||
|
|
|
@ -502,6 +502,7 @@ class InlineHttpsProcessor(markdown.treeprocessors.Treeprocessor):
|
|||
|
||||
class BacktickPattern(markdown.inlinepatterns.Pattern):
|
||||
""" Return a `<code>` element containing the matching text. """
|
||||
|
||||
def __init__(self, pattern: str) -> None:
|
||||
markdown.inlinepatterns.Pattern.__init__(self, pattern)
|
||||
self.ESCAPED_BSLASH = '%s%s%s' % (markdown.util.STX, ord('\\'), markdown.util.ETX)
|
||||
|
@ -1276,6 +1277,7 @@ def unicode_emoji_to_codepoint(unicode_emoji: str) -> str:
|
|||
|
||||
class EmoticonTranslation(markdown.inlinepatterns.Pattern):
|
||||
""" Translates emoticons like `:)` into emoji like `:smile:`. """
|
||||
|
||||
def handleMatch(self, match: Match[str]) -> Optional[Element]:
|
||||
db_data = self.markdown.zulip_db_data
|
||||
if db_data is None or not db_data['translate_emoticons']:
|
||||
|
|
|
@ -26,6 +26,7 @@ class IncludeCustomPreprocessor(IncludePreprocessor):
|
|||
JsonableError exception. The rest of the functionality is identical
|
||||
to the original markdown_include extension.
|
||||
"""
|
||||
|
||||
def run(self, lines: List[str]) -> List[str]:
|
||||
done = False
|
||||
while not done:
|
||||
|
|
|
@ -16,6 +16,7 @@ class StreamRecipientMap:
|
|||
Note that this class uses raw SQL, because we want to highly
|
||||
optimize page loads.
|
||||
'''
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.recip_to_stream = dict() # type: Dict[int, int]
|
||||
self.stream_to_recip = dict() # type: Dict[int, int]
|
||||
|
|
|
@ -16,6 +16,7 @@ class StreamTopicTarget:
|
|||
places where we are are still using `topic_name` as
|
||||
a key into tables.
|
||||
'''
|
||||
|
||||
def __init__(self, stream_id: int, topic_name: str) -> None:
|
||||
self.stream_id = stream_id
|
||||
self.topic_name = topic_name
|
||||
|
|
|
@ -151,6 +151,7 @@ class TextTestResult(runner.TextTestResult):
|
|||
This class has unpythonic function names because base class follows
|
||||
this style.
|
||||
"""
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
self.failed_tests = [] # type: List[str]
|
||||
|
@ -192,6 +193,7 @@ class RemoteTestResult(django_runner.RemoteTestResult):
|
|||
The class follows the unpythonic style of function names of the
|
||||
base class.
|
||||
"""
|
||||
|
||||
def addInfo(self, test: TestCase, msg: str) -> None:
|
||||
self.events.append(('addInfo', self.test_index, msg))
|
||||
|
||||
|
@ -598,6 +600,7 @@ class SubSuiteList(List[Tuple[Type[TestSuite], List[str]]]):
|
|||
This class allows us to avoid changing the main logic of
|
||||
ParallelTestSuite and still make it serializable.
|
||||
"""
|
||||
|
||||
def __init__(self, suites: List[TestSuite]) -> None:
|
||||
serialized_suites = [serialize_suite(s) for s in suites]
|
||||
super().__init__(serialized_suites)
|
||||
|
|
|
@ -35,7 +35,6 @@ def get_topic_mutes(user_profile: UserProfile) -> List[List[Union[str, float]]]:
|
|||
|
||||
def set_topic_mutes(user_profile: UserProfile, muted_topics: List[List[str]],
|
||||
date_muted: Optional[datetime.datetime]=None) -> None:
|
||||
|
||||
'''
|
||||
This is only used in tests.
|
||||
'''
|
||||
|
|
|
@ -425,6 +425,7 @@ class SetRemoteAddrFromForwardedFor(MiddlewareMixin):
|
|||
is set in the request, then it has properly been set by NGINX.
|
||||
Therefore HTTP_X_FORWARDED_FOR's value is trusted.
|
||||
"""
|
||||
|
||||
def process_request(self, request: HttpRequest) -> None:
|
||||
try:
|
||||
real_ip = request.META['HTTP_X_FORWARDED_FOR']
|
||||
|
@ -465,6 +466,7 @@ class ZulipCommonMiddleware(CommonMiddleware):
|
|||
for non-API endpoints things like /login. But doing that
|
||||
transition will require more careful testing.
|
||||
"""
|
||||
|
||||
def should_redirect_with_slash(self, request: HttpRequest) -> bool:
|
||||
if settings.RUNNING_INSIDE_TORNADO:
|
||||
return False
|
||||
|
|
|
@ -17,6 +17,7 @@ from zerver.tornado.views import get_events, cleanup_event_queue
|
|||
class MissedMessageNotificationsTest(ZulipTestCase):
|
||||
"""Tests the logic for when missed-message notifications
|
||||
should be triggered, based on user settings"""
|
||||
|
||||
def check_will_notify(self, *args: Any, **kwargs: Any) -> Tuple[str, str]:
|
||||
email_notice = None
|
||||
mobile_notice = None
|
||||
|
|
|
@ -689,6 +689,7 @@ class ImportExportTest(ZulipTestCase):
|
|||
"""
|
||||
Tests for import_realm
|
||||
"""
|
||||
|
||||
def test_import_realm(self) -> None:
|
||||
|
||||
original_realm = Realm.objects.get(string_id='zulip')
|
||||
|
|
|
@ -4036,6 +4036,7 @@ class MessageAccessTests(ZulipTestCase):
|
|||
|
||||
class MessageHasKeywordsTest(ZulipTestCase):
|
||||
'''Test for keywords like has_link, has_image, has_attachment.'''
|
||||
|
||||
def setup_dummy_attachments(self, user_profile: UserProfile) -> List[str]:
|
||||
sample_size = 10
|
||||
realm_id = user_profile.realm_id
|
||||
|
|
|
@ -41,6 +41,7 @@ class OpenAPIToolsTest(ZulipTestCase):
|
|||
These tools are mostly dedicated to fetching parts of the -already parsed-
|
||||
specification, and comparing them to objects returned by our REST API.
|
||||
"""
|
||||
|
||||
def test_get_openapi_fixture(self) -> None:
|
||||
actual = get_openapi_fixture(TEST_ENDPOINT, TEST_METHOD,
|
||||
TEST_RESPONSE_BAD_REQ)
|
||||
|
|
|
@ -424,6 +424,7 @@ class ReactionEventTest(ZulipTestCase):
|
|||
class EmojiReactionBase(ZulipTestCase):
|
||||
"""Reusable testing functions for emoji reactions tests. Be careful when
|
||||
changing this: It's used in test_retention.py as well."""
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
self.reaction_type = 'realm_emoji'
|
||||
super().__init__(*args, **kwargs)
|
||||
|
|
|
@ -775,7 +775,6 @@ ClientInfo = TypedDict('ClientInfo', {
|
|||
|
||||
def get_client_info_for_message_event(event_template: Mapping[str, Any],
|
||||
users: Iterable[Mapping[str, Any]]) -> Dict[str, ClientInfo]:
|
||||
|
||||
'''
|
||||
Return client info for all the clients interested in a message.
|
||||
This basically includes clients for users who are recipients
|
||||
|
|
|
@ -235,6 +235,7 @@ class ZulipAuthMixin:
|
|||
from memcached before checking the database (avoiding a database
|
||||
query in most cases).
|
||||
"""
|
||||
|
||||
def get_user(self, user_profile_id: int) -> Optional[UserProfile]:
|
||||
"""Override the Django method for getting a UserProfile object from
|
||||
the user_profile_id,."""
|
||||
|
@ -380,6 +381,7 @@ class ZulipLDAPAuthBackendBase(ZulipAuthMixin, LDAPBackend):
|
|||
library. It's not a lot of code, and searching around in that
|
||||
file makes the flow for LDAP authentication clear.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
# Used to initialize a fake LDAP directly for both manual
|
||||
# and automated testing in a development environment where
|
||||
|
@ -720,6 +722,7 @@ class ZulipLDAPUser(_LDAPUser):
|
|||
UserProfile. The realm attribute serves to uniquely identify the UserProfile
|
||||
in case the ldap user is registered to multiple realms.
|
||||
"""
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
self.realm = kwargs['realm'] # type: Realm
|
||||
del kwargs['realm']
|
||||
|
@ -733,6 +736,7 @@ class ZulipLDAPUserPopulator(ZulipLDAPAuthBackendBase):
|
|||
registration for organizations that use a different SSO solution
|
||||
for managing login (often via RemoteUserBackend).
|
||||
"""
|
||||
|
||||
def authenticate(self, request: Optional[HttpRequest]=None, *,
|
||||
username: str, password: str, realm: Realm,
|
||||
return_data: Optional[Dict[str, Any]]=None) -> Optional[UserProfile]:
|
||||
|
@ -852,6 +856,7 @@ def query_ldap(email: str) -> List[str]:
|
|||
class DevAuthBackend(ZulipAuthMixin):
|
||||
"""Allow logging in as any user without a password. This is used for
|
||||
convenience when developing Zulip, and is disabled in production."""
|
||||
|
||||
def authenticate(self, request: Optional[HttpRequest]=None, *,
|
||||
dev_auth_username: str, realm: Realm,
|
||||
return_data: Optional[Dict[str, Any]]=None) -> Optional[UserProfile]:
|
||||
|
|
Loading…
Reference in New Issue