launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28848
[Merge] ~cjwatson/launchpad:black-coop into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:black-coop into launchpad:master.
Commit message:
lp.coop: Apply black
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/427123
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:black-coop into launchpad:master.
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index b19c911..f667459 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -74,3 +74,5 @@ a6bed71f3d2fdbceae20c2d435c993e8bededdce
94d8e9842b7c92f3f9b7f514fb49ebdc9af7e413
# apply black to lp.codehosting
ed7d7b97b8fb4ebe92799f922b0fa9c4bd1714e8
+# apply black to lp.coop
+1e6ead9387a1d073eea9271fe8dc646bb22fa3d2
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 34046c5..a7d8233 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -51,6 +51,7 @@ repos:
|charms
|code
|codehosting
+ |coop
)/
- repo: https://github.com/PyCQA/isort
rev: 5.9.2
@@ -78,6 +79,7 @@ repos:
|charms
|code
|codehosting
+ |coop
)/
- id: isort
alias: isort-black
@@ -95,6 +97,7 @@ repos:
|charms
|code
|codehosting
+ |coop
)/
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
diff --git a/lib/lp/coop/answersbugs/browser.py b/lib/lp/coop/answersbugs/browser.py
index 87e7f2a..879a801 100644
--- a/lib/lp/coop/answersbugs/browser.py
+++ b/lib/lp/coop/answersbugs/browser.py
@@ -6,14 +6,8 @@
__all__ = []
from lp import _
-from lp.app.browser.launchpadform import (
- action,
- LaunchpadFormView,
- )
-from lp.bugs.interfaces.bug import (
- CreateBugParams,
- IBug,
- )
+from lp.app.browser.launchpadform import LaunchpadFormView, action
+from lp.bugs.interfaces.bug import CreateBugParams, IBug
from lp.services.webapp.publisher import canonical_url
from lp.services.webapp.snapshot import notify_modified
@@ -23,7 +17,7 @@ class QuestionMakeBugView(LaunchpadFormView):
schema = IBug
- field_names = ['title', 'description']
+ field_names = ["title", "description"]
def initialize(self):
"""Initialize the view when a Bug may be reported for the Question."""
@@ -31,39 +25,44 @@ class QuestionMakeBugView(LaunchpadFormView):
if question.bugs:
# we can't make a bug when we have linked bugs
self.request.response.addErrorNotification(
- _('You cannot create a bug report from a question'
- 'that already has bugs linked to it.'))
+ _(
+ "You cannot create a bug report from a question"
+ "that already has bugs linked to it."
+ )
+ )
self.request.response.redirect(canonical_url(question))
return
LaunchpadFormView.initialize(self)
@property
def page_title(self):
- return 'Create bug report based on question #%s' % self.context.id
+ return "Create bug report based on question #%s" % self.context.id
@property
def label(self):
- return 'Create a bug based on a question'
+ return "Create a bug based on a question"
@property
def initial_values(self):
"""Return the initial form values."""
question = self.context
- return {'title': '',
- 'description': question.description}
+ return {"title": "", "description": question.description}
- @action(_('Create Bug Report'), name='create')
+ @action(_("Create Bug Report"), name="create")
def create_action(self, action, data):
"""Create a Bug from a Question."""
question = self.context
- with notify_modified(question, ['bugs']):
+ with notify_modified(question, ["bugs"]):
params = CreateBugParams(
- owner=self.user, title=data['title'],
- comment=data['description'])
+ owner=self.user,
+ title=data["title"],
+ comment=data["description"],
+ )
bug = question.target.createBug(params)
question.linkBug(bug, user=self.user)
bug.subscribe(question.owner, self.user)
self.request.response.addNotification(
- _('Thank you! Bug #$bugid created.', mapping={'bugid': bug.id}))
+ _("Thank you! Bug #$bugid created.", mapping={"bugid": bug.id})
+ )
self.next_url = canonical_url(bug)
diff --git a/lib/lp/coop/answersbugs/subscribers.py b/lib/lp/coop/answersbugs/subscribers.py
index 70e075f..0c35a3f 100644
--- a/lib/lp/coop/answersbugs/subscribers.py
+++ b/lib/lp/coop/answersbugs/subscribers.py
@@ -22,7 +22,8 @@ def assign_question_bug_link_karma(question, event):
"""Assign karma to the user which added <questionbug>."""
if IBug.providedBy(event.other_object):
assignKarmaUsingQuestionContext(
- IPerson(event.user), event.object, 'questionlinkedtobug')
+ IPerson(event.user), event.object, "questionlinkedtobug"
+ )
def subscribe_owner_to_bug(question, event):
@@ -52,35 +53,44 @@ class QuestionLinkedBugStatusChangeNotification(QuestionNotification):
def initialize(self):
"""Create a notifcation for a linked bug status change."""
- assert IObjectModifiedEvent.providedBy(self.event), (
- "Should only be subscribed for IObjectModifiedEvent.")
- assert IBugTask.providedBy(self.event.object), (
- "Should only be subscribed for IBugTask modification.")
+ assert IObjectModifiedEvent.providedBy(
+ self.event
+ ), "Should only be subscribed for IObjectModifiedEvent."
+ assert IBugTask.providedBy(
+ self.event.object
+ ), "Should only be subscribed for IBugTask modification."
self.bugtask = self.event.object
self.old_bugtask = self.event.object_before_modification
def shouldNotify(self):
"""Only send notification when the status changed."""
- return (self.bugtask.status != self.old_bugtask.status
- and self.bugtask.bug.private == False)
+ return (
+ self.bugtask.status != self.old_bugtask.status
+ and self.bugtask.bug.private == False
+ )
def getSubject(self):
"""See QuestionNotification."""
return "[Question #%s]: Status of bug #%s changed to '%s' in %s" % (
- self.question.id, self.bugtask.bug.id, self.bugtask.status.title,
- self.bugtask.target.displayname)
+ self.question.id,
+ self.bugtask.bug.id,
+ self.bugtask.status.title,
+ self.bugtask.target.displayname,
+ )
def getBody(self):
"""See QuestionNotification."""
template = get_email_template(
- 'question-linked-bug-status-updated.txt', app='coop/answersbugs')
+ "question-linked-bug-status-updated.txt", app="coop/answersbugs"
+ )
return template % {
- 'bugtask_target_name': self.bugtask.target.displayname,
- 'question_id': self.question.id,
- 'question_title': self.question.title,
- 'question_url': canonical_url(self.question),
- 'bugtask_url': canonical_url(self.bugtask),
- 'bug_id': self.bugtask.bug.id,
- 'bugtask_title': self.bugtask.bug.title,
- 'old_status': self.old_bugtask.status.title,
- 'new_status': self.bugtask.status.title}
+ "bugtask_target_name": self.bugtask.target.displayname,
+ "question_id": self.question.id,
+ "question_title": self.question.title,
+ "question_url": canonical_url(self.question),
+ "bugtask_url": canonical_url(self.bugtask),
+ "bug_id": self.bugtask.bug.id,
+ "bugtask_title": self.bugtask.bug.title,
+ "old_status": self.old_bugtask.status.title,
+ "new_status": self.bugtask.status.title,
+ }
diff --git a/lib/lp/coop/answersbugs/tests/test_doc.py b/lib/lp/coop/answersbugs/tests/test_doc.py
index 16264c9..5ff20a2 100644
--- a/lib/lp/coop/answersbugs/tests/test_doc.py
+++ b/lib/lp/coop/answersbugs/tests/test_doc.py
@@ -15,27 +15,12 @@ from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.interfaces.person import IPersonSet
from lp.services.testing import build_test_suite
from lp.services.worlddata.interfaces.language import ILanguageSet
-from lp.soyuz.tests.test_doc import (
- uploaderSetUp,
- uploadQueueSetUp,
- )
-from lp.testing import (
- ANONYMOUS,
- login,
- person_logged_in,
- )
+from lp.soyuz.tests.test_doc import uploaderSetUp, uploadQueueSetUp
+from lp.testing import ANONYMOUS, login, person_logged_in
from lp.testing.dbuser import switch_dbuser
-from lp.testing.layers import (
- DatabaseFunctionalLayer,
- LaunchpadZopelessLayer,
- )
+from lp.testing.layers import DatabaseFunctionalLayer, LaunchpadZopelessLayer
from lp.testing.mail_helpers import pop_notifications
-from lp.testing.systemdocs import (
- LayeredDocFileSuite,
- setUp,
- tearDown,
- )
-
+from lp.testing.systemdocs import LayeredDocFileSuite, setUp, tearDown
here = os.path.dirname(os.path.realpath(__file__))
@@ -46,20 +31,24 @@ def _createUbuntuBugTaskLinkedToQuestion():
The Ubuntu team is set as the answer contact for Ubuntu, and no-priv
is used as the submitter..
"""
- login('test@xxxxxxxxxxxxx')
- sample_person = getUtility(IPersonSet).getByEmail('test@xxxxxxxxxxxxx')
- ubuntu_team = getUtility(IPersonSet).getByName('ubuntu-team')
+ login("test@xxxxxxxxxxxxx")
+ sample_person = getUtility(IPersonSet).getByEmail("test@xxxxxxxxxxxxx")
+ ubuntu_team = getUtility(IPersonSet).getByName("ubuntu-team")
with person_logged_in(ubuntu_team.teamowner):
- ubuntu_team.addLanguage(getUtility(ILanguageSet)['en'])
- ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
+ ubuntu_team.addLanguage(getUtility(ILanguageSet)["en"])
+ ubuntu = getUtility(IDistributionSet).getByName("ubuntu")
ubuntu.addAnswerContact(ubuntu_team, ubuntu_team.teamowner)
ubuntu_question = ubuntu.newQuestion(
- sample_person, "Can't install Ubuntu",
- "I insert the install CD in the CD-ROM drive, but it won't boot.")
- no_priv = getUtility(IPersonSet).getByEmail('no-priv@xxxxxxxxxxxxx')
+ sample_person,
+ "Can't install Ubuntu",
+ "I insert the install CD in the CD-ROM drive, but it won't boot.",
+ )
+ no_priv = getUtility(IPersonSet).getByEmail("no-priv@xxxxxxxxxxxxx")
params = CreateBugParams(
- owner=no_priv, title="Installer fails on a Mac PPC",
- comment=ubuntu_question.description)
+ owner=no_priv,
+ title="Installer fails on a Mac PPC",
+ comment=ubuntu_question.description,
+ )
bug = ubuntu.createBug(params)
ubuntu_question.linkBug(bug)
[ubuntu_bugtask] = bug.bugtasks
@@ -77,15 +66,16 @@ def bugLinkedToQuestionSetUp(test):
setUp(test)
bugtask_id = _createUbuntuBugTaskLinkedToQuestion()
- test.globs['get_bugtask_linked_to_question'] = (
- get_bugtask_linked_to_question)
+ test.globs[
+ "get_bugtask_linked_to_question"
+ ] = get_bugtask_linked_to_question
# Log in here, since we don't want to set up an non-anonymous
# interaction in the test.
- login('no-priv@xxxxxxxxxxxxx')
+ login("no-priv@xxxxxxxxxxxxx")
def uploaderBugLinkedToQuestionSetUp(test):
- switch_dbuser('launchpad')
+ switch_dbuser("launchpad")
bugLinkedToQuestionSetUp(test)
LaunchpadZopelessLayer.commit()
uploaderSetUp(test)
@@ -93,7 +83,7 @@ def uploaderBugLinkedToQuestionSetUp(test):
def uploadQueueBugLinkedToQuestionSetUp(test):
- switch_dbuser('launchpad')
+ switch_dbuser("launchpad")
bugLinkedToQuestionSetUp(test)
LaunchpadZopelessLayer.commit()
uploadQueueSetUp(test)
@@ -102,27 +92,33 @@ def uploadQueueBugLinkedToQuestionSetUp(test):
# Files that have special needs can construct their own suite
special = {
- 'notifications-linked-private-bug.rst': LayeredDocFileSuite(
- 'notifications-linked-private-bug.rst',
- setUp=bugLinkedToQuestionSetUp, tearDown=tearDown,
- layer=DatabaseFunctionalLayer),
- 'notifications-linked-bug.rst': LayeredDocFileSuite(
- 'notifications-linked-bug.rst',
- setUp=bugLinkedToQuestionSetUp, tearDown=tearDown,
- layer=DatabaseFunctionalLayer),
- 'notifications-linked-bug.rst-uploader': LayeredDocFileSuite(
- 'notifications-linked-bug.rst',
- id_extensions=['notifications-linked-bug.rst-uploader'],
+ "notifications-linked-private-bug.rst": LayeredDocFileSuite(
+ "notifications-linked-private-bug.rst",
+ setUp=bugLinkedToQuestionSetUp,
+ tearDown=tearDown,
+ layer=DatabaseFunctionalLayer,
+ ),
+ "notifications-linked-bug.rst": LayeredDocFileSuite(
+ "notifications-linked-bug.rst",
+ setUp=bugLinkedToQuestionSetUp,
+ tearDown=tearDown,
+ layer=DatabaseFunctionalLayer,
+ ),
+ "notifications-linked-bug.rst-uploader": LayeredDocFileSuite(
+ "notifications-linked-bug.rst",
+ id_extensions=["notifications-linked-bug.rst-uploader"],
setUp=uploaderBugLinkedToQuestionSetUp,
tearDown=tearDown,
- layer=LaunchpadZopelessLayer),
- 'notifications-linked-bug.rst-queued': LayeredDocFileSuite(
- 'notifications-linked-bug.rst',
- id_extensions=['notifications-linked-bug.rst-queued'],
+ layer=LaunchpadZopelessLayer,
+ ),
+ "notifications-linked-bug.rst-queued": LayeredDocFileSuite(
+ "notifications-linked-bug.rst",
+ id_extensions=["notifications-linked-bug.rst-queued"],
setUp=uploadQueueBugLinkedToQuestionSetUp,
tearDown=tearDown,
- layer=LaunchpadZopelessLayer),
- }
+ layer=LaunchpadZopelessLayer,
+ ),
+}
def test_suite():
diff --git a/lib/lp/coop/answersbugs/tests/test_questionbug.py b/lib/lp/coop/answersbugs/tests/test_questionbug.py
index 3aabd1f..a379dda 100644
--- a/lib/lp/coop/answersbugs/tests/test_questionbug.py
+++ b/lib/lp/coop/answersbugs/tests/test_questionbug.py
@@ -1,10 +1,7 @@
# Copyright 2015 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-from lp.testing import (
- login_person,
- TestCaseWithFactory,
- )
+from lp.testing import TestCaseWithFactory, login_person
from lp.testing.layers import DatabaseFunctionalLayer
diff --git a/lib/lp/coop/answersbugs/visibility.py b/lib/lp/coop/answersbugs/visibility.py
index cbb3815..795da3b 100644
--- a/lib/lp/coop/answersbugs/visibility.py
+++ b/lib/lp/coop/answersbugs/visibility.py
@@ -4,9 +4,9 @@
"""Provides mixins for visibility tests in messages."""
__all__ = [
- 'TestHideMessageControlMixin',
- 'TestMessageVisibilityMixin',
- ]
+ "TestHideMessageControlMixin",
+ "TestMessageVisibilityMixin",
+]
from lp.services.webapp.escaping import html_escape
from lp.testing.pages import find_tag_by_id
@@ -64,7 +64,7 @@ class TestMessageVisibilityMixin:
class TestHideMessageControlMixin:
- control_text = 'mark-spam-1'
+ control_text = "mark-spam-1"
def getContext(self, comment_owner=None):
"""To be overwridden by subclasses.