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
This commit is contained in:
Ian Wienand 2020-02-23 10:25:38 +11:00
parent 9d08848f25
commit 28ebd24844
10 changed files with 36 additions and 32 deletions

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@ SIZE_UNIT_SPECS = [
# Basic RE to check and split floats (without exponent) # Basic RE to check and split floats (without exponent)
# and a given unit specification (which must be non-numerical). # 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): def _split_size_unit_spec(size_unit_spec):

View File

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

View File

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

View File

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

View File

@ -173,7 +173,7 @@ class TestElementDeps(testtools.TestCase):
self._e('provides_new_virtual')], result) self._e('provides_new_virtual')], result)
def test_elements_provide_same(self): 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, self.assertRaisesRegex(element_dependencies.AlreadyProvidedException,
msg, msg,
element_dependencies.get_elements, element_dependencies.get_elements,

View File

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

View File

@ -59,7 +59,7 @@ basepython = python3
commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html commands = sphinx-build -a -W -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[flake8] [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 exclude = .venv,.git,.tox,dist,doc/build,doc/source,*lib/python*,*egg,build,conf.py
[testenv:lower-constraints] [testenv:lower-constraints]