launchpad:db-devel

Last commit made on 2022-08-08
Get this branch:
git clone -b db-devel https://git.launchpad.net/launchpad
Members of Canonical Launchpad Engineering can upload to this branch. Log in for directions.

Branch merges

Branch information

Name:
db-devel
Repository:
lp:launchpad

Recent commits

fb7328e... by Patch Queue Manager <email address hidden>

Automatic merge from stable up to 286db7fd90c4

286db7f... by Colin Watson

Fix some test failures caused by type-checking changes

Merged from https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/428030

3e6b74b... by Colin Watson

Fix logic in POTemplateEditView._return_url

To satisfy `mypy`, commit 65e983ad01a81e2ec3d6ceb0bb08bf7868b67e7f
changed the definition of a couple of properties in `LaunchpadFormView`
from:

    next_url = _return_url
    cancel_url = _return_url

... to:

    @property
    def next_url(self):
        return self._return_url

    @property
    def cancel_url(self):
        return self._return_url

This looks fairly innocuous, but it has an interesting side-effect: it
means that redefining `_return_url` in subclasses is now effective, when
previously it wasn't because the `next_url` and `cancel_url` names were
bound to the definition in the superclass. As a result, I don't think
the property in the subclass (`POTemplateEditView`) was being called in
practice. Arranging for it to be called caused failures in
`lib/lp/translations/stories/standalone/xx-potemplate-admin.rst` and
`lib/lp/translations/stories/standalone/xx-potemplate-edit.rst`. I
considered simply removing the property in the subclass, but based on
the comment at the top there does seem to be a point to it, so I made
the effort to repair it.

The problem was that `POTemplateEditView._return_url` failed to check
whether it needs to construct a new URL in the case where the default
return URL is provided by a hidden input in the form; but that's
normally the case when an edit form is being submitted. Moving the
check for whether the default return URL contains "/+pots/" out one
level, so that it's called regardless of the source of the default
return URL, fixes the problem.

I also removed `POTemplateEditView._return_attribute_name`, since it was
only used by `LaunchpadFormView._return_url` which is now overridden
here, so it had become effectively dead code.

6403e7a... by Colin Watson

Fix handling of MaloneView.error_message

Commit 65e983ad01a81e2ec3d6ceb0bb08bf7868b67e7f changed
`MaloneView.error_message` from being initialized to None to being a
property that returns None, due to needing to convince `mypy` that its
type was compatible with that of `LaunchpadView.error_message`.
However, this caused test failures in
`lp.bugs.browser.tests.test_bugs.TestMaloneView.test_redirect_unknown_bug_fail`
and
`lp.bugs.browser.tests.test_bugs.TestMaloneView.test_redirect_list_of_bug_fail`,
because `MaloneView._redirectToBug` expected to be able to assign to
`error_message`.

I think it's best to rearrange `MaloneView` to conform to the
expectations of the base class for `error_message`: that is, assignments
to it must be either None or an `IStructuredString`. The `structured`
helper makes it easier to write pages in a way that avoids XSS attacks
by separating fixed text from interpolated variables such that
interpolations are HTML-escaped. As it happens I satisfied myself that
this page was already XSS-safe, but this approach makes it a bit clearer
in a way that's more usual for Launchpad, and makes it easier to keep
the type-checker happy.

ce60dfd... by Colin Watson

Fix LaunchpadScript.{usage,description}

The default value was changed from None to "" in commit
551507a0b01442f3c6ca7b827195298fadad64a0, but they should actually stay
as None and be explicitly annotated as optional strings.
`LaunchpadScript.__init__` behaves differently if they're None vs.
empty.

This caused test failures in
`lib/lp/bugs/doc/checkwatches-cli-switches.rst` and
`lib/lp/translations/doc/distroseries-translations-copy.rst`.

7bc3d1d... by Colin Watson

Publish Python sdists to the correct paths

Merged from https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/427901

7808acf... by Colin Watson

Publish Python sdists to the correct paths

When creating a `SourcePackageRelease` from a `CIBuild`, we have to take
the release's source package name from the namespace of the build's Git
repository, since that means everything is grouped together properly
under the same source package name, and it also allows us to handle
source package types whose true package name can't be used as a source
package name (notably Go modules); teams building these also generally
try to use the same source package name as used in Ubuntu, to make it
easier to associate fixes in different distributions.

However, this meant that we published Python sdists to the wrong paths
if their true package name didn't correspond to the repository
namespace. To fix this, pass through the true package name via
`SourcePackageRelease.user_defined_fields` and use that in the
publishing machinery.

LP: #1983401

09ccbf9... by Colin Watson

Ensure that getUserDefinedField works consistently

`SourcePackageRelease.user_defined_fields` returns an empty list if the
corresponding database column is NULL, but
`BinaryPackageRelease.user_defined_fields` didn't match that, causing
`BinaryPackageRelease.getUserDefinedField` to raise an exception in that
case. This made it difficult to write code that works with both types.

a91420d... by Jürgen Gmach

Run mypy via tox

Merged from https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/427961

75bb0d2... by Jürgen Gmach

Run mypy via tox

You can run now the mypy checker via

```
tox -e mypy
```

Currently, this command runs the mypy checks on `lp.answers`. In future
we can add more subpackages to the list once they pass.

If you want to lint another subpackage, e.g. `lp.bugs`, you have to run

```
tox -e mypy -- lib/lp/bugs
```

Please note that you cannot run tox from within the LXC container on
Xenial as the available mypy version has issues with finding Python
files (recursion does not work properly).

Additionally, this commit fixes issues reported by mypy in lp.answers.