Uncap hacking

This causes problems for other projects incorporating dib; we don't
have a specific need for a cap.

Fix a few issues, mostly spacing or regex matches.  No functional
changes.

W503 and W504 relate to leaving artithmetic operators at the start or
end of lines, and are mutually exclusive and, due to "ignore"
overriding the defaults both get enabled.  It seems everyone gets this
wrong (https://gitlab.com/pycqa/flake8/issues/466).  Don't take a
position on this and ignore both.

Use double # around comments including YAML snippets using "# type: "
which now gets detected as PEP484/mypy type hints.

Change-Id: I8b7ce6dee02dcce31c82427a2441c931d136ef57
changes/32/709332/2
Ian Wienand 3 years ago
parent 9d08848f25
commit 28ebd24844
  1. 1
      diskimage_builder/block_device/cmd.py
  2. 52
      diskimage_builder/block_device/config.py
  3. 4
      diskimage_builder/block_device/tests/test_lvm.py
  4. 2
      diskimage_builder/block_device/utils.py
  5. 1
      diskimage_builder/element_dependencies.py
  6. 1
      diskimage_builder/elements/package-installs/bin/package-installs-squash
  7. 1
      diskimage_builder/elements/pkg-map/bin/pkg-map
  8. 2
      diskimage_builder/tests/test_elementdeps.py
  9. 2
      requirements.txt
  10. 2
      tox.ini

@ -119,5 +119,6 @@ def main():
bdc = BlockDeviceCmd()
return bdc.main()
if __name__ == "__main__":
sys.exit(main())

@ -52,9 +52,9 @@ def recurse_config(config, parent_base=None):
# We should only have one key, with multiple values, being the
# config entries. e.g. (this was checked by config_tree_to_graph)
# mkfs:
# type: ext4
# label: 1234
# # mkfs:
# # type: ext4
# # label: 1234
assert len(config.items()) == 1
for k, v in config.items():
key = k
@ -248,31 +248,31 @@ def create_graph(config, default_config, state):
#
# To be concrete --
#
# partitioning:
# base: loop0
# name: mbr
# partitions:
# - name: partition1
# foo: bar
# mkfs:
# type: xfs
# mount:
# mount_point: /
# # partitioning:
# # base: loop0
# # name: mbr
# # partitions:
# # - name: partition1
# # foo: bar
# # mkfs:
# # type: xfs
# # mount:
# # mount_point: /
#
# gets turned into the following graph:
#
# partitioning:
# partitions:
# - name: partition1
# base: image0
# foo: bar
# # partitioning:
# # partitions:
# # - name: partition1
# # base: image0
# # foo: bar
#
# mkfs:
# base: partition1
# name: mkfs_partition1
# type: xfs
# # mkfs:
# # base: partition1
# # name: mkfs_partition1
# # type: xfs
#
# mount:
# base: mkfs_partition1
# name: mount_mkfs_partition1
# mount_point: /
# # mount:
# # base: mkfs_partition1
# # name: mount_mkfs_partition1
# # mount_point: /

@ -55,8 +55,8 @@ class TestLVM(tc.TestGraphGeneration):
bad_config = copy.deepcopy(lvm_config)
bad_config['lvs'][0]['base'] = ['invalid_vg']
self.assertRaisesRegex(BlockDeviceSetupException,
"base:\['invalid_vg'\] in lvs does not match "
"a valid vg",
r"base:\['invalid_vg'\] in lvs does not match "
r"a valid vg",
LVMPlugin, bad_config, {}, {})
bad_config = copy.deepcopy(lvm_config)

@ -42,7 +42,7 @@ SIZE_UNIT_SPECS = [
# Basic RE to check and split floats (without exponent)
# and a given unit specification (which must be non-numerical).
size_unit_spec_re = re.compile("^([\d\.]*) ?([a-zA-Z0-9_]*)$")
size_unit_spec_re = re.compile(r"^([\d\.]*) ?([a-zA-Z0-9_]*)$")
def _split_size_unit_spec(size_unit_spec):

@ -350,5 +350,6 @@ def main():
return 0
if __name__ == "__main__":
main()

@ -191,5 +191,6 @@ def main():
final_dict, outfile,
indent=True, separators=(',', ': '), sort_keys=False)
if __name__ == '__main__':
main()

@ -190,6 +190,7 @@ def main():
sys.exit(0)
if __name__ == '__main__':
main()

@ -173,7 +173,7 @@ class TestElementDeps(testtools.TestCase):
self._e('provides_new_virtual')], result)
def test_elements_provide_same(self):
msg = "virtual: already provided by \['provides_virtual'\]"
msg = r"virtual: already provided by \['provides_virtual'\]"
self.assertRaisesRegex(element_dependencies.AlreadyProvidedException,
msg,
element_dependencies.get_elements,

@ -10,4 +10,4 @@ PyYAML>=3.12 # MIT
six>=1.10.0 # MIT
stevedore>=1.20.0 # Apache-2.0
# NOTE(ianw) in here because dib-lint uses flake8
hacking<1.2.0,>=1.1.0
hacking>=1.1.0

@ -59,7 +59,7 @@ basepython = python3
commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[flake8]
ignore = E125,E126,E127,H202,H803
ignore = E125,E126,E127,H202,H803,W503,W504
exclude = .venv,.git,.tox,dist,doc/build,doc/source,*lib/python*,*egg,build,conf.py
[testenv:lower-constraints]

Loading…
Cancel
Save