mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
tools: Upgrade Pycodestyle and fix new linter errors.
Here, we are upgrading pycodestyle version from 2.4.0 to 2.5.0. Fixes: #11396.
This commit is contained in:
committed by
Tim Abbott
parent
07bac66db7
commit
e1772b3b8f
@@ -26,7 +26,7 @@ httpretty==0.9.6
|
||||
isort==4.3.4
|
||||
|
||||
# for pep8 linter
|
||||
pycodestyle==2.4.0
|
||||
pycodestyle==2.5.0
|
||||
|
||||
# Needed to run pyflakes linter
|
||||
pyflakes==2.0.0
|
||||
|
||||
@@ -121,7 +121,7 @@ py3dns==3.2.0
|
||||
pyaml==18.11.0 # via moto
|
||||
pyasn1-modules==0.2.4
|
||||
pyasn1==0.4.5
|
||||
pycodestyle==2.4.0
|
||||
pycodestyle==2.5.0
|
||||
pycparser==2.19 # via cffi
|
||||
pycrypto==2.6.1
|
||||
pycryptodome==3.7.3 # via python-jose
|
||||
|
||||
@@ -11,4 +11,4 @@ LATEST_RELEASE_ANNOUNCEMENT = "https://blog.zulip.org/2018/11/07/zulip-1-9-relea
|
||||
# Typically, adding a dependency only requires a minor version bump, and
|
||||
# removing a dependency requires a major version bump.
|
||||
|
||||
PROVISION_VERSION = '27.4'
|
||||
PROVISION_VERSION = '27.5'
|
||||
|
||||
@@ -44,11 +44,11 @@ def rm_tree(path: str) -> None:
|
||||
|
||||
def slack_workspace_to_realm(domain_name: str, realm_id: int, user_list: List[ZerverFieldsT],
|
||||
realm_subdomain: str, slack_data_dir: str,
|
||||
custom_emoji_list: ZerverFieldsT)-> Tuple[ZerverFieldsT, AddedUsersT,
|
||||
AddedRecipientsT,
|
||||
AddedChannelsT,
|
||||
List[ZerverFieldsT],
|
||||
ZerverFieldsT]:
|
||||
custom_emoji_list: ZerverFieldsT) -> Tuple[ZerverFieldsT, AddedUsersT,
|
||||
AddedRecipientsT,
|
||||
AddedChannelsT,
|
||||
List[ZerverFieldsT],
|
||||
ZerverFieldsT]:
|
||||
"""
|
||||
Returns:
|
||||
1. realm, Converted Realm data
|
||||
|
||||
@@ -120,11 +120,11 @@ def get_user_mentions(token: str, users: List[ZerverFieldsT],
|
||||
for user in users:
|
||||
if (user['id'] == slack_id and user['name'] == short_name and short_name) or \
|
||||
(user['id'] == slack_id and short_name is None):
|
||||
full_name = get_user_full_name(user)
|
||||
user_id = added_users[slack_id]
|
||||
mention = "@**" + full_name + "**"
|
||||
token = re.sub(SLACK_USERMENTION_REGEX, mention, token, flags=re.VERBOSE)
|
||||
return token, user_id
|
||||
full_name = get_user_full_name(user)
|
||||
user_id = added_users[slack_id]
|
||||
mention = "@**" + full_name + "**"
|
||||
token = re.sub(SLACK_USERMENTION_REGEX, mention, token, flags=re.VERBOSE)
|
||||
return token, user_id
|
||||
return token, None
|
||||
|
||||
# Map italic, bold and strikethrough markdown
|
||||
|
||||
@@ -720,7 +720,7 @@ class WebhookTestCase(ZulipTestCase):
|
||||
|
||||
def send_and_test_private_message(self, fixture_name: str, expected_topic: str=None,
|
||||
expected_message: str=None, content_type: str="application/json",
|
||||
**kwargs: Any)-> Message:
|
||||
**kwargs: Any) -> Message:
|
||||
payload = self.get_body(fixture_name)
|
||||
if content_type is not None:
|
||||
kwargs['content_type'] = content_type
|
||||
|
||||
@@ -36,13 +36,13 @@ class StatsDWrapper:
|
||||
# as our statsd server supports them but supporting
|
||||
# pystatsd is not released yet
|
||||
def _our_gauge(self, stat: str, value: float, rate: float=1, delta: bool=False) -> None:
|
||||
"""Set a gauge value."""
|
||||
from django_statsd.clients import statsd
|
||||
if delta:
|
||||
value_str = '%+g|g' % (value,)
|
||||
else:
|
||||
value_str = '%g|g' % (value,)
|
||||
statsd._send(stat, value_str, rate)
|
||||
"""Set a gauge value."""
|
||||
from django_statsd.clients import statsd
|
||||
if delta:
|
||||
value_str = '%+g|g' % (value,)
|
||||
else:
|
||||
value_str = '%g|g' % (value,)
|
||||
statsd._send(stat, value_str, rate)
|
||||
|
||||
def __getattr__(self, name: str) -> Any:
|
||||
# Hand off to statsd if we have it enabled
|
||||
|
||||
@@ -1609,17 +1609,17 @@ class ReturnSuccessOnHeadRequestDecorator(ZulipTestCase):
|
||||
self.assertNotEqual(ujson.loads(response.content).get('msg'), u'from_test_function')
|
||||
|
||||
def test_returns_normal_response_if_request_method_is_not_head(self) -> None:
|
||||
class HeadRequest:
|
||||
method = 'POST'
|
||||
class HeadRequest:
|
||||
method = 'POST'
|
||||
|
||||
request = HeadRequest()
|
||||
request = HeadRequest()
|
||||
|
||||
@return_success_on_head_request
|
||||
def test_function(request: HttpRequest) -> HttpResponse:
|
||||
return json_response(msg=u'from_test_function')
|
||||
@return_success_on_head_request
|
||||
def test_function(request: HttpRequest) -> HttpResponse:
|
||||
return json_response(msg=u'from_test_function')
|
||||
|
||||
response = test_function(request)
|
||||
self.assertEqual(ujson.loads(response.content).get('msg'), u'from_test_function')
|
||||
response = test_function(request)
|
||||
self.assertEqual(ujson.loads(response.content).get('msg'), u'from_test_function')
|
||||
|
||||
class RestAPITest(ZulipTestCase):
|
||||
def test_method_not_allowed(self) -> None:
|
||||
|
||||
@@ -1820,7 +1820,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||
# to ANY stream, even one she is not unsubscribed to, and
|
||||
# she can do it for herself or on behalf of a mirrored user.
|
||||
|
||||
def test_with(sender_email: str, client: str, forged: bool) ->None:
|
||||
def test_with(sender_email: str, client: str, forged: bool) -> None:
|
||||
payload = dict(
|
||||
type="stream",
|
||||
to=stream_name,
|
||||
|
||||
@@ -344,8 +344,8 @@ class WorkerTest(ZulipTestCase):
|
||||
self.settings(MAILCHIMP_API_KEY='one-two',
|
||||
PRODUCTION=True,
|
||||
ZULIP_FRIENDS_LIST_ID='id'):
|
||||
worker.start()
|
||||
fake_response.raise_for_status.assert_called_once()
|
||||
worker.start()
|
||||
fake_response.raise_for_status.assert_called_once()
|
||||
|
||||
def test_invites_worker(self) -> None:
|
||||
fake_client = self.FakeClient()
|
||||
|
||||
@@ -2531,11 +2531,11 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
self.make_stream(stream_name)
|
||||
|
||||
with queries_captured() as queries:
|
||||
self.common_subscribe_to_streams(
|
||||
self.test_email,
|
||||
streams,
|
||||
dict(principals=ujson.dumps([self.test_email])),
|
||||
)
|
||||
self.common_subscribe_to_streams(
|
||||
self.test_email,
|
||||
streams,
|
||||
dict(principals=ujson.dumps([self.test_email])),
|
||||
)
|
||||
# Make sure we don't make O(streams) queries
|
||||
self.assert_length(queries, 21)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class WebhooksCommonTestCase(ZulipTestCase):
|
||||
self.assertEqual(msg.sender.email, notification_bot.email)
|
||||
self.assertEqual(msg.content, expected_message)
|
||||
|
||||
def test_notify_bot_owner_on_invalid_json(self)-> None:
|
||||
def test_notify_bot_owner_on_invalid_json(self) -> None:
|
||||
@api_key_only_webhook_view('ClientName', notify_bot_owner_on_invalid_json=False)
|
||||
def my_webhook_no_notify(request: HttpRequest, user_profile: UserProfile) -> None:
|
||||
raise InvalidJSONError("Malformed JSON")
|
||||
|
||||
@@ -75,12 +75,12 @@ class JiraHookTests(WebhookTestCase):
|
||||
self.send_and_test_stream_message('created_v1', expected_topic, expected_message)
|
||||
|
||||
def test_created_with_unicode(self) -> None:
|
||||
expected_topic = u"BUG-15: New bug with à hook"
|
||||
expected_message = u"""Leo Franchià **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**:
|
||||
expected_topic = u"BUG-15: New bug with à hook"
|
||||
expected_message = u"""Leo Franchià **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**:
|
||||
|
||||
> New bug with à hook"""
|
||||
self.send_and_test_stream_message('created_with_unicode_v1', expected_topic, expected_message)
|
||||
self.send_and_test_stream_message('created_with_unicode_v2', expected_topic, expected_message)
|
||||
self.send_and_test_stream_message('created_with_unicode_v1', expected_topic, expected_message)
|
||||
self.send_and_test_stream_message('created_with_unicode_v2', expected_topic, expected_message)
|
||||
|
||||
def test_created_assignee(self) -> None:
|
||||
expected_topic = "TEST-4: Test Created Assignee"
|
||||
@@ -108,12 +108,12 @@ Leaving a comment here! :)"""
|
||||
self.send_and_test_stream_message('comment_created', expected_topic, expected_message)
|
||||
|
||||
def test_comment_edited(self) -> None:
|
||||
expected_topic = "BUG-15: New bug with hook"
|
||||
expected_message = """Leo Franchi **edited comment on** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**):
|
||||
expected_topic = "BUG-15: New bug with hook"
|
||||
expected_message = """Leo Franchi **edited comment on** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**):
|
||||
|
||||
|
||||
Adding a comment. Oh, what a comment it is!"""
|
||||
self.send_and_test_stream_message('comment_edited_v2', expected_topic, expected_message)
|
||||
self.send_and_test_stream_message('comment_edited_v2', expected_topic, expected_message)
|
||||
|
||||
def test_comment_deleted(self) -> None:
|
||||
expected_topic = "TOM-1: New Issue"
|
||||
@@ -149,12 +149,12 @@ Adding a comment. Oh, what a comment it is!"""
|
||||
self.send_and_test_stream_message('updated_priority_v2', expected_topic, expected_message)
|
||||
|
||||
def test_status_changed(self) -> None:
|
||||
expected_topic = "TEST-1: Fix That"
|
||||
expected_message = """Leonardo Franchi [Administrator] **updated** [TEST-1](https://zulipp.atlassian.net/browse/TEST-1):
|
||||
expected_topic = "TEST-1: Fix That"
|
||||
expected_message = """Leonardo Franchi [Administrator] **updated** [TEST-1](https://zulipp.atlassian.net/browse/TEST-1):
|
||||
|
||||
* Changed status from **To Do** to **In Progress**"""
|
||||
self.send_and_test_stream_message('change_status_v1', expected_topic, expected_message)
|
||||
self.send_and_test_stream_message('change_status_v2', expected_topic, expected_message)
|
||||
self.send_and_test_stream_message('change_status_v1', expected_topic, expected_message)
|
||||
self.send_and_test_stream_message('change_status_v2', expected_topic, expected_message)
|
||||
|
||||
def get_body(self, fixture_name: str) -> str:
|
||||
return self.webhook_fixture_data('jira', fixture_name)
|
||||
|
||||
@@ -17,7 +17,7 @@ from zerver.models import Stream, UserProfile
|
||||
def api_newrelic_webhook(request: HttpRequest, user_profile: UserProfile,
|
||||
alert: Optional[Dict[str, Any]]=REQ(validator=check_dict([]), default=None),
|
||||
deployment: Optional[Dict[str, Any]]=REQ(validator=check_dict([]), default=None)
|
||||
)-> HttpResponse:
|
||||
) -> HttpResponse:
|
||||
if alert:
|
||||
# Use the message as the subject because it stays the same for
|
||||
# "opened", "acknowledged", and "closed" messages that should be
|
||||
|
||||
@@ -565,7 +565,7 @@ class EmbeddedBotWorker(QueueProcessingWorker):
|
||||
continue
|
||||
try:
|
||||
if hasattr(bot_handler, 'initialize'):
|
||||
bot_handler.initialize(self.get_bot_api_client(user_profile))
|
||||
bot_handler.initialize(self.get_bot_api_client(user_profile))
|
||||
if event['trigger'] == 'mention':
|
||||
message['content'] = extract_query_without_mention(
|
||||
message=message,
|
||||
|
||||
@@ -29,7 +29,7 @@ def set_forward_address(forward_address: str) -> None:
|
||||
config.set("DEV_EMAIL", "forward_address", forward_address)
|
||||
|
||||
with open(settings.FORWARD_ADDRESS_CONFIG_FILE, "w") as cfgfile:
|
||||
config.write(cfgfile)
|
||||
config.write(cfgfile)
|
||||
|
||||
class EmailLogBackEnd(BaseEmailBackend):
|
||||
def send_email_smtp(self, email: EmailMultiAlternatives) -> None:
|
||||
|
||||
Reference in New Issue
Block a user