The /drivers GET endpoint is supposed to have {"drivers": null} when the
list of drivers has not (yes) been retrieved.
However, this behavior got broken by the following patch:
66c82b322 drivers: query again list of drivers if the source variant changes
.. which resets the drivers variable to an empty list when querying the
list of drivers (this happens automatically when the user submits on the
source screen).
Therefore, instead of getting {"drivers": null}, we would get
{"drivers": []} which has a different meaning.
The patch also incorrectly declared the drivers variable in the
initializer (not taking None into account). The variable was actually
already declared as a class variable with the right type.
Fixed by resetting the variable to None when re-querying the list of
drivers and dropped the class variable in favor of the instance variable
(with the right type this time).
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
The script can be invoked in different ways:
Run mypy in the current working directory and display the output:
$ scripts/run-mypy.py
Run mypy in a clean copy of the HEAD revision:
$ scripts/run-mypy.py --checkout-head
Run mypy in the current working directory and compare the result with
another revision (here main):
$ scripts/run-mypy.py --diff-against main
Run mypy in a clean copy of the HEAD revision and compare with another
revision (here main):
$ scripts/run-mypy.py --diff-against main --checkout-head
The produced result might be slightly different from what the CI does
because it also clones checks out curtin and probert (at the right
revision). This is something we might want to do in the CI as well.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
The pep8 binary package was a transitional package. It would install a
symlink /usr/bin/pep8 -> pycodestyle
pep8 does not exist anymore in mantic.
pycodestyle would be the right binary package going forward. That said,
we stopped using the pep8 command back in 2018 with this commit:
af9427561 Make tox and Makefile more similar.
Let's drop the dependency instead.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
curtin_install before this assembled a list of steps and then executed
them one by one. As far as I can tell/remember (I was at least partly
responsible for this) there is no reason to do it this way: it feels
more Pythonic to just execute the steps!
This required removing some indirection in how the config for each step
was constructed, which I think also makes things a bit clearer.
For a dictionary, the type hint should be dict[key_type, value_type] as
opposed to dict[key_type: value_type].
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
A new job now runs on PRs. It will automatically run mypy on the target
branch and on the source branch. It will generate a diff of the errors,
showing the new ones and showing the ones that have been fixed.
It will also show a summary with the number of errors before/after the
PR.
Because we have so many false positive, it makes no sense to mark this
job red. So we always make it green (unless mypy can't run).
As for now, it's up to developers to go check if any new error is
introduced.
If a line that used to produce a mypy error gets moved, it will be
reported as:
* a fixed error
* a newly introduced error
This is suboptimal and ideally we should have a way to detect moves.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
bind_mount_tree really wants to mount to places that don't exist yet,
and to unmount them later. Simply creating these files or directories
gets weird. Manage this process in the Mounter, so that any of these
temporary mountpoints get cleaned up on unmount.
Given disk layout like so
[p1 g1 p2 p3 g2]
The code attempting to create p4 used the largest_gap() method to
attempt to select g2. If the disk was small enough, below 28GiB with
current numbers, g1 would actually be larger, but the sizing math was
done with the offset that was correct for g2, so p4 would be created
a very incorrect size (-800MiB or so).
Just select gap by offset - we have the info needed.