deb-glance/HACKING.rst
ChangBo Guo(gcb) 9d4225289b Leverage dict comprehension in PEP-0274
PEP-0274 introduced dict comprehensions to replace dict constructor
with a sequence of key-pairs[1], these are two benefits:
- First, it makes the code look neater.
- Second, it gains a micro-optimization.

Glance dropped python 2.6 support in Kilo, we can leverage this now.
Note: This commit doesn't handle dict constructor with kwargs.
This commit also adds a hacking rule.

[1]http://legacy.python.org/dev/peps/pep-0274/

Co-Authored-By: ChangBo Guo(gcb) <eric.guo@easystack.cn>
Co-Authored-By: Kamil Rykowski <kamil.rykowski@intel.com>
Change-Id: I0ba408f9c616dcdb09618f6256db76b9facc0c1d
2015-05-28 01:46:02 +00:00

1.1 KiB

glance Style Commandments =======================

glance Specific Commandments --------------------------

  • [G316] Change assertTrue(isinstance(A, B)) by optimal assert like assertIsInstance(A, B)
  • [G317] Change assertEqual(type(A), B) by optimal assert like assertIsInstance(A, B)
  • [G318] Change assertEqual(A, None) or assertEqual(None, A) by optimal assert like assertIsNone(A)
  • [G319] Validate that debug level logs are not translated
  • [G320] For python 3 compatibility, use six.text_type() instead of unicode()
  • [G321] Validate that LOG messages, except debug ones, have translations
  • [G322] Validate that LOG.info messages use _LI.
  • [G323] Validate that LOG.exception messages use _LE.
  • [G324] Validate that LOG.error messages use _LE.
  • [G325] Validate that LOG.critical messages use _LC.
  • [G326] Validate that LOG.warning messages use _LW.
  • [G327] Prevent use of deprecated contextlib.nested
  • [G328] Must use a dict comprehension instead of a dict constructor with a sequence of key-value pairs