From 41bd88d5edc80d2f941f101114295bffc4793f1c Mon Sep 17 00:00:00 2001 From: Rafid Aslam Date: Tue, 29 Nov 2016 13:22:02 +0700 Subject: [PATCH] pep8: Fix E301 pep8 violations. Fix "E301: expected (1 or 2) blank line" pep8 violations. --- analytics/views.py | 1 + api/integrations/perforce/git_p4.py | 2 ++ api/zulip/__init__.py | 2 ++ bots/irc-mirror.py | 1 + bots/zephyr_mirror.py | 1 + tools/lib/template_parser.py | 1 + tools/lint-all | 3 +-- zerver/filters.py | 1 + zerver/lib/bugdown/__init__.py | 3 +++ zerver/lib/bugdown/fenced_code.py | 1 + zerver/lib/export.py | 2 ++ zerver/lib/narrow.py | 1 + zerver/lib/parallel.py | 1 + zerver/lib/queue.py | 2 ++ zerver/lib/str_utils.py | 1 + zerver/lib/test_helpers.py | 2 ++ zerver/lib/timeout.py | 1 + zerver/management/commands/enqueue_digest_emails.py | 1 + zerver/management/commands/process_queue.py | 1 + zerver/management/commands/purge_queue.py | 1 + zerver/middleware.py | 1 + zerver/models.py | 1 + zerver/tests/test_auth_backends.py | 1 + zerver/tests/test_decorators.py | 4 ++++ zerver/tests/test_external.py | 1 + zerver/tests/test_narrow.py | 1 + zerver/tests/test_push_notifications.py | 1 + zerver/tests/test_type_debug.py | 4 ++++ zerver/tests/tests.py | 1 + zerver/tests/webhooks/test_gitlab.py | 1 + zerver/tests/webhooks/test_new_relic.py | 1 + zerver/tornado/event_queue.py | 1 + zerver/tornado/ioloop_logging.py | 2 ++ zproject/backends.py | 8 ++++++++ zproject/jinja2/backends.py | 2 ++ 35 files changed, 57 insertions(+), 2 deletions(-) diff --git a/analytics/views.py b/analytics/views.py index 9e4945e8fc..22dea65084 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -655,6 +655,7 @@ def get_user_activity_summary(records): # `Union[Dict[str, Dict[str, int]], Dict[str, Dict[str, datetime]]]` #: but that would require this long `Union` to carry on throughout inner functions. summary = {} # type: Dict[str, Dict[str, Any]] + def update(action, record): # type: (str, QuerySet) -> None if action not in summary: diff --git a/api/integrations/perforce/git_p4.py b/api/integrations/perforce/git_p4.py index 69b1646a86..8730aafdd2 100755 --- a/api/integrations/perforce/git_p4.py +++ b/api/integrations/perforce/git_p4.py @@ -39,9 +39,11 @@ except ImportError: """This exception is raised when a process run by check_call() returns a non-zero exit status. The exit status will be stored in the returncode attribute.""" + def __init__(self, returncode, cmd): self.returncode = returncode self.cmd = cmd + def __str__(self): return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) diff --git a/api/zulip/__init__.py b/api/zulip/__init__.py index ff726b8234..bcbcccb1c4 100644 --- a/api/zulip/__init__.py +++ b/api/zulip/__init__.py @@ -398,6 +398,7 @@ class Client(object): if request is None: request = {} return request + def call(self, *args, **kwargs): request = make_request(*args, **kwargs) if computed_url is not None: @@ -411,6 +412,7 @@ class Client(object): def call_on_each_event(self, callback, event_types=None, narrow=None): if narrow is None: narrow = [] + def do_register(): while True: if event_types is None: diff --git a/bots/irc-mirror.py b/bots/irc-mirror.py index f9af690a58..5185b91016 100755 --- a/bots/irc-mirror.py +++ b/bots/irc-mirror.py @@ -35,6 +35,7 @@ class IRCBot(irc.bot.SingleServerIRCBot): def on_welcome(self, c, e): # type: (ServerConnection, Event) -> None c.join(self.channel) + def forward_to_irc(msg): # type: (Dict[str, Any]) -> None if msg["type"] == "stream": diff --git a/bots/zephyr_mirror.py b/bots/zephyr_mirror.py index 38275b5a0a..c1e52b82c4 100755 --- a/bots/zephyr_mirror.py +++ b/bots/zephyr_mirror.py @@ -62,6 +62,7 @@ if options.forward_class_messages and not options.noshard: from zerver.lib.parallel import run_parallel print("Starting parallel zephyr class mirroring bot") jobs = list("0123456789abcdef") + def run_job(shard): # type: (str) -> int subprocess.call(args + ["--shard=%s" % (shard,)]) diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index 5feeaf54a7..f9f47af2fa 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -157,6 +157,7 @@ def validate(fn=None, text=None, check_indent=True): start_col = start_token.col old_matcher = state.matcher + def f(end_token): # type: (Token) -> None diff --git a/tools/lint-all b/tools/lint-all index 151a033da8..0e09361fa8 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -83,10 +83,9 @@ def check_pep8(files): failed = False ignored_rules = [ 'E402', 'E501', 'W503', 'E711', 'E201', 'E203', 'E202', 'E128', 'E226', 'E124', 'E125', - 'E126', 'E127', 'E121', 'E122', 'E123', 'E266', 'E265', 'E261', 'E301', 'E221', 'E303', + 'E126', 'E127', 'E121', 'E122', 'E123', 'E266', 'E265', 'E261', 'E701', 'E221', 'E303', 'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E111', 'E222', 'E731', 'E302', 'E129', 'E741', 'E714', 'W391', 'E211', 'E713', 'E502', 'E131', 'E305', 'E251', 'E306', 'E231', - 'E701', ] pep8 = subprocess.Popen( ['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))], diff --git a/zerver/filters.py b/zerver/filters.py index 04e5a70649..b5d3168aba 100644 --- a/zerver/filters.py +++ b/zerver/filters.py @@ -16,6 +16,7 @@ class ZulipExceptionReporterFilter(SafeExceptionReporterFilter): if var in filtered_post: filtered_post[var] = '**********' return filtered_post + def get_request_repr(self, request): # type: (HttpRequest) -> str if request is None: diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 54b39fc5df..ea8992230f 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -659,6 +659,7 @@ class ModalLink(markdown.inlinepatterns.Pattern): """ A pattern that allows including in-app modal links in messages. """ + def handleMatch(self, match): # type: (Match[text_type]) -> Element relative_url = match.group('relative_url') @@ -824,6 +825,7 @@ class BugdownUListPreprocessor(markdown.preprocessors.Preprocessor): # Based on markdown.inlinepatterns.LinkPattern class LinkPattern(markdown.inlinepatterns.Pattern): """ Return a link element from the given match. """ + def handleMatch(self, m): # type: (Match[text_type]) -> Optional[Element] href = m.group(9) @@ -853,6 +855,7 @@ def prepare_realm_pattern(source): # using the provided format string to construct the URL. class RealmFilterPattern(markdown.inlinepatterns.Pattern): """ Applied a given realm filter to the input """ + def __init__(self, source_pattern, format_string, markdown_instance=None): # type: (text_type, text_type, Optional[markdown.Markdown]) -> None self.pattern = prepare_realm_pattern(source_pattern) diff --git a/zerver/lib/bugdown/fenced_code.py b/zerver/lib/bugdown/fenced_code.py index aee032bb6d..635bf1275e 100644 --- a/zerver/lib/bugdown/fenced_code.py +++ b/zerver/lib/bugdown/fenced_code.py @@ -128,6 +128,7 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor): def handle_line(self, line): # type: (text_type) -> None raise NotImplementedError() + def done(self): # type: () -> None raise NotImplementedError() diff --git a/zerver/lib/export.py b/zerver/lib/export.py index 078e68f7aa..3a1f3ade2a 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -199,6 +199,7 @@ class Config(object): append itself to the parent's list of children. ''' + def __init__(self, table=None, model=None, normal_parent=None, virtual_parent=None, filter_args=None, custom_fetch=None, custom_tables=None, @@ -1101,6 +1102,7 @@ def create_soft_link(source, in_progress=True): def launch_user_message_subprocesses(threads, output_dir): # type: (int, Path) -> None logging.info('Launching %d PARALLEL subprocesses to export UserMessage rows' % (threads,)) + def run_job(shard): # type: (str) -> int subprocess.call(["./manage.py", 'export_usermessage_batch', '--path', diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.py index 563820222b..039cfb59c2 100644 --- a/zerver/lib/narrow.py +++ b/zerver/lib/narrow.py @@ -17,6 +17,7 @@ def build_narrow_filter(narrow): """Changes to this function should come with corresponding changes to BuildNarrowFilterTest.""" check_supported_events_narrow_filter(narrow) + def narrow_filter(event): # type: (Mapping[str, Any]) -> bool message = event["message"] diff --git a/zerver/lib/parallel.py b/zerver/lib/parallel.py index 768943b285..0bcbd92461 100644 --- a/zerver/lib/parallel.py +++ b/zerver/lib/parallel.py @@ -58,6 +58,7 @@ if __name__ == "__main__": import time jobs = [10, 19, 18, 6, 14, 12, 8, 2, 1, 13, 3, 17, 9, 11, 5, 16, 7, 15, 4] expected_output = [6, 10, 12, 2, 1, 14, 8, 3, 18, 19, 5, 9, 13, 11, 4, 7, 17, 16, 15] + def wait_and_print(x): # type: (int) -> int time.sleep(x * 0.1) diff --git a/zerver/lib/queue.py b/zerver/lib/queue.py index 12f132bb5f..67e5dbf7f7 100644 --- a/zerver/lib/queue.py +++ b/zerver/lib/queue.py @@ -146,6 +146,7 @@ class SimpleQueueClient(object): # type: (str, bool) -> List[Dict[str, Any]] "Returns all messages in the desired queue" messages = [] + def opened(): # type: () -> None while True: @@ -233,6 +234,7 @@ class TornadoQueueClient(SimpleQueueClient): # Try to reconnect in two seconds retry_seconds = 2 + def on_timeout(): # type: () -> None try: diff --git a/zerver/lib/str_utils.py b/zerver/lib/str_utils.py index f4976d140b..b487f8c0dc 100644 --- a/zerver/lib/str_utils.py +++ b/zerver/lib/str_utils.py @@ -81,6 +81,7 @@ class ModelReprMixin(object): Define __unicode__ on your model which returns a six.text_type object. This mixin will automatically define __str__ and __repr__. """ + def __unicode__(self): # type: () -> Text # Originally raised an exception, but Django (e.g. the ./manage.py shell) diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index c2bae7b0ba..bfb07d18bc 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -80,6 +80,7 @@ def tornado_redirected_to_list(lst): def simulated_empty_cache(): # type: () -> Generator[List[Tuple[str, Union[text_type, List[text_type]], text_type]], None, None] cache_queries = [] # type: List[Tuple[str, Union[text_type, List[text_type]], text_type]] + def my_cache_get(key, cache_name=None): # type: (text_type, Optional[str]) -> Any cache_queries.append(('get', key, cache_name)) @@ -206,6 +207,7 @@ class POSTRequestMock(object): class HostRequestMock(object): """A mock request object where get_host() works. Useful for testing routes that use Zulip's subdomains feature""" + def __init__(self, host=settings.EXTERNAL_HOST): # type: (text_type) -> None self.host = host diff --git a/zerver/lib/timeout.py b/zerver/lib/timeout.py index 5122b8f7bb..8b5995340d 100644 --- a/zerver/lib/timeout.py +++ b/zerver/lib/timeout.py @@ -13,6 +13,7 @@ from six.moves import range class TimeoutExpired(Exception): '''Exception raised when a function times out.''' + def __str__(self): # type: () -> str return 'Function call timed out.' diff --git a/zerver/management/commands/enqueue_digest_emails.py b/zerver/management/commands/enqueue_digest_emails.py index 2919c7b074..dbc6c05000 100644 --- a/zerver/management/commands/enqueue_digest_emails.py +++ b/zerver/management/commands/enqueue_digest_emails.py @@ -88,6 +88,7 @@ class Command(BaseCommand): help = """Enqueue digest emails for users that haven't checked the app in a while. """ + def handle(self, *args, **options): # type: (*Any, **Any) -> None # To be really conservative while we don't have user timezones or diff --git a/zerver/management/commands/process_queue.py b/zerver/management/commands/process_queue.py index 48afef4126..0093d30896 100644 --- a/zerver/management/commands/process_queue.py +++ b/zerver/management/commands/process_queue.py @@ -25,6 +25,7 @@ class Command(BaseCommand): help="run all queues") help = "Runs a queue processing worker" + def handle(self, *args, **options): # type: (*Any, **Any) -> None logging.basicConfig() diff --git a/zerver/management/commands/purge_queue.py b/zerver/management/commands/purge_queue.py index 4c22a47246..9819d5b339 100644 --- a/zerver/management/commands/purge_queue.py +++ b/zerver/management/commands/purge_queue.py @@ -15,6 +15,7 @@ class Command(BaseCommand): help="queue to purge") help = "Discards all messages from the given queue" + def handle(self, *args, **options): # type: (*Any, **str) -> None queue_name = options['queue_name'] diff --git a/zerver/middleware.py b/zerver/middleware.py index d32871bb12..3bd7e889d3 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -299,6 +299,7 @@ class TagRequests(object): def process_view(self, request, view_func, args, kwargs): # type: (HttpRequest, Callable[..., HttpResponse], *str, **Any) -> None self.process_request(request) + def process_request(self, request): # type: (HttpRequest) -> None if request.path.startswith("/api/") or request.path.startswith("/json/"): diff --git a/zerver/models.py b/zerver/models.py index 8ecd8911e4..59da82fed8 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -852,6 +852,7 @@ def bulk_get_recipients(type, type_ids): def cache_key_function(type_id): # type: (int) -> Text return get_recipient_cache_key(type, type_id) + def query_function(type_ids): # type: (List[int]) -> Sequence[Recipient] # TODO: Change return type to QuerySet[Recipient] diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index efd24683d3..d04b24d044 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -1089,6 +1089,7 @@ class TestJWTLogin(ZulipTestCase): """ JWT uses ZulipDummyBackend. """ + def test_login_success(self): # type: () -> None payload = {'user': 'hamlet', 'realm': 'zulip.com'} diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index bf23238eda..28bc9e4fd3 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -264,6 +264,7 @@ class RateLimitTestCase(TestCase): def test_internal_local_clients_skip_rate_limiting(self): class Client(object): name = 'internal' + class Request(object): client = Client() META = {'REMOTE_ADDR': '127.0.0.1'} @@ -285,6 +286,7 @@ class RateLimitTestCase(TestCase): def test_debug_clients_skip_rate_limiting(self): class Client(object): name = 'internal' + class Request(object): client = Client() META = {'REMOTE_ADDR': '3.3.3.3'} @@ -307,6 +309,7 @@ class RateLimitTestCase(TestCase): def test_rate_limit_setting_of_false_bypasses_rate_limiting(self): class Client(object): name = 'external' + class Request(object): client = Client() META = {'REMOTE_ADDR': '3.3.3.3'} @@ -329,6 +332,7 @@ class RateLimitTestCase(TestCase): def test_rate_limiting_happens_in_normal_case(self): class Client(object): name = 'external' + class Request(object): client = Client() META = {'REMOTE_ADDR': '3.3.3.3'} diff --git a/zerver/tests/test_external.py b/zerver/tests/test_external.py index be19ce6b16..966da6eba1 100644 --- a/zerver/tests/test_external.py +++ b/zerver/tests/test_external.py @@ -50,6 +50,7 @@ class MITNameTest(TestCase): self.assertRaises(ValidationError, email_is_not_mit_mailing_list, "1234567890@mit.edu") with mock.patch('DNS.dnslookup', side_effect=DNS.Base.ServerError('DNS query status: NXDOMAIN', 3)): self.assertRaises(ValidationError, email_is_not_mit_mailing_list, "ec-discuss@mit.edu") + def test_notmailinglist(self): # type: () -> None with mock.patch('DNS.dnslookup', return_value=[['POP IMAP.EXCHANGE.MIT.EDU starnine']]): diff --git a/zerver/tests/test_narrow.py b/zerver/tests/test_narrow.py index 286a5155dc..37f148cc3b 100644 --- a/zerver/tests/test_narrow.py +++ b/zerver/tests/test_narrow.py @@ -377,6 +377,7 @@ class GetOldMessagesTest(ZulipTestCase): conversations with that user. """ me = 'hamlet@zulip.com' + def dr_emails(dr): return ','.join(sorted(set([r['email'] for r in dr] + [me]))) diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index a560fdfd67..6ed3f46363 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -187,6 +187,7 @@ class SendNotificationTest(PushNotificationTest): def test_do_push_to_apns_service(self, mock_push): # type: (mock.MagicMock) -> None msg = apn.APNsMessage(self.user_profile, self.tokens, alert="test") + def test_push(message): # type: (Message) -> None self.assertIs(message, msg.get_frame()) diff --git a/zerver/tests/test_type_debug.py b/zerver/tests/test_type_debug.py index cb4ad994dc..b442746ea8 100644 --- a/zerver/tests/test_type_debug.py +++ b/zerver/tests/test_type_debug.py @@ -24,6 +24,7 @@ class TypesPrintTest(TestCase): def _pre_setup(self): # type: () -> None pass + def _post_teardown(self): # type: () -> None pass @@ -91,6 +92,7 @@ class TypesPrintTest(TestCase): def test_class(self): # type: () -> None class A(object): pass + class B(str): pass self.check_signature("(A) -> str", 'A', (lambda x: x.__class__.__name__), A()) self.check_signature("(B) -> int", 5, (lambda x: len(x)), B("hello")) @@ -98,6 +100,7 @@ class TypesPrintTest(TestCase): def test_sequence(self): # type: () -> None class A(list): pass + class B(list): pass self.check_signature("add(A([]), B([str])) -> [str]", ['two'], add, A([]), B(['two'])) @@ -109,6 +112,7 @@ class TypesPrintTest(TestCase): def test_mapping(self): # type: () -> None class A(dict): pass + def to_A(l=[]): # type: (Iterable[Tuple[Any, Any]]) -> A return A(l) diff --git a/zerver/tests/tests.py b/zerver/tests/tests.py index 8ea7388a04..08c3a31b68 100644 --- a/zerver/tests/tests.py +++ b/zerver/tests/tests.py @@ -603,6 +603,7 @@ class WorkerTest(TestCase): def __init__(self): # type: () -> None super(TestWorker, self).__init__() + def consume(self, data): # type: (Mapping[str, Any]) -> None pass diff --git a/zerver/tests/webhooks/test_gitlab.py b/zerver/tests/webhooks/test_gitlab.py index f7d55c7caa..67d2cce113 100644 --- a/zerver/tests/webhooks/test_gitlab.py +++ b/zerver/tests/webhooks/test_gitlab.py @@ -173,6 +173,7 @@ class GitlabHookTests(WebhookTestCase): expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) + def test_merge_request_created_with_assignee_event_message(self): # type: () -> None expected_subject = u"my-awesome-project / MR #3 New Merge Request" diff --git a/zerver/tests/webhooks/test_new_relic.py b/zerver/tests/webhooks/test_new_relic.py index c353af9f27..b78d8d5c71 100644 --- a/zerver/tests/webhooks/test_new_relic.py +++ b/zerver/tests/webhooks/test_new_relic.py @@ -14,6 +14,7 @@ Apdex score fell below critical level of 0.90\n\ [View alert](https://rpm.newrelc.com/accounts/[account_id]/applications/[application_id]/incidents/[incident_id])' self.send_and_test_stream_message('alert', expected_subject, expected_message, content_type="application/x-www-form-urlencoded") + def test_deployment(self): # type: () -> None expected_subject = 'Test App deploy' diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 521b6532d9..77d30cc015 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -181,6 +181,7 @@ class ClientDescriptor(object): self.current_client_name = client_name set_descriptor_by_handler_id(handler_id, self) self.last_connection_time = time.time() + def timeout_callback(): # type: () -> None self._timeout_handle = None diff --git a/zerver/tornado/ioloop_logging.py b/zerver/tornado/ioloop_logging.py index c9923f1fa9..3be6dd69a4 100644 --- a/zerver/tornado/ioloop_logging.py +++ b/zerver/tornado/ioloop_logging.py @@ -11,6 +11,7 @@ from django.conf import settings try: # Tornado 2.4 orig_poll_impl = ioloop._poll # type: ignore # cross-version type variation is hard for mypy + def instrument_tornado_ioloop(): # type: () -> None ioloop._poll = InstrumentedPoll # type: ignore # cross-version type variation is hard for mypy @@ -21,6 +22,7 @@ except: # will be without actually constructing an IOLoop, so we just assume it will # be epoll. orig_poll_impl = select.epoll # type: ignore # There is no stub for select.epoll on python 3 + class InstrumentedPollIOLoop(PollIOLoop): def initialize(self, **kwargs): # type: ignore # TODO investigate likely buggy monkey patching here super(InstrumentedPollIOLoop, self).initialize(impl=InstrumentedPoll(), **kwargs) diff --git a/zproject/backends.py b/zproject/backends.py index 555d40a85b..c968292471 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -169,6 +169,7 @@ class ZulipDummyBackend(ZulipAuthMixin): """ Used when we want to log you in but we don't know which backend to use. """ + def authenticate(self, username=None, realm_subdomain=None, use_dummy_backend=False, return_data=None): # type: (Optional[text_type], Optional[text_type], bool, Optional[Dict[str, Any]]) -> Optional[UserProfile] @@ -189,6 +190,7 @@ class EmailAuthBackend(ZulipAuthMixin): Allows a user to sign in using an email/password pair rather than a username/password pair. """ + def authenticate(self, username=None, password=None, realm_subdomain=None, return_data=None): # type: (Optional[text_type], Optional[str], Optional[text_type], Optional[Dict[str, Any]]) -> Optional[UserProfile] """ Authenticate a user based on email address as the user name. """ @@ -227,6 +229,7 @@ class GoogleMobileOauth2Backend(ZulipAuthMixin): https://developers.google.com/accounts/docs/CrossClientAuth#offlineAccess """ + def authenticate(self, google_oauth2_token=None, realm_subdomain=None, return_data={}): # type: (Optional[str], Optional[text_type], Dict[str, Any]) -> Optional[UserProfile] try: @@ -257,6 +260,7 @@ class GoogleMobileOauth2Backend(ZulipAuthMixin): class ZulipRemoteUserBackend(RemoteUserBackend): create_unknown_user = False + def authenticate(self, remote_user, realm_subdomain=None): # type: (str, Optional[text_type]) -> Optional[UserProfile] if not remote_user: @@ -282,14 +286,17 @@ class ZulipLDAPAuthBackendBase(ZulipAuthMixin, LDAPBackend): # Using Any type is safe because we are not doing anything with # the arguments. return False + def has_module_perms(self, user, app_label): # type: (UserProfile, str) -> bool return False + def get_all_permissions(self, user, obj=None): # type: (UserProfile, Any) -> Set # Using Any type is safe because we are not doing anything with # the arguments. return set() + def get_group_permissions(self, user, obj=None): # type: (UserProfile, Any) -> Set # Using Any type is safe because we are not doing anything with @@ -303,6 +310,7 @@ class ZulipLDAPAuthBackendBase(ZulipAuthMixin, LDAPBackend): raise ZulipLDAPException("Username does not match LDAP domain.") return email_to_username(username) return username + def ldap_to_django_username(self, username): # type: (str) -> str if settings.LDAP_APPEND_DOMAIN: diff --git a/zproject/jinja2/backends.py b/zproject/jinja2/backends.py index bb385b052b..726a9717a9 100644 --- a/zproject/jinja2/backends.py +++ b/zproject/jinja2/backends.py @@ -22,6 +22,7 @@ class Jinja2(django_jinja2.Jinja2): and add the functionality to pass the context processors to the `Template` object. """ + def __init__(self, params, *args, **kwargs): # type: (Dict[str, Any], *Any, **Any) -> None # We need to remove `context_processors` from `OPTIONS` because @@ -51,6 +52,7 @@ class Template(django_jinja2.Template): processors to the context before passing it to the `render` function. """ + def __init__(self, template, context_processors, debug, *args, **kwargs): # type: (str, List[str], bool, *Any, **Any) -> None self.context_processors = context_processors