File: HACKING.rst

package info (click to toggle)
keystone 2%3A10.0.0-9%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,520 kB
  • sloc: python: 78,287; sh: 679; xml: 268; pascal: 213; makefile: 206
file content (58 lines) | stat: -rw-r--r-- 1,422 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Keystone Style Commandments
===========================

- Step 1: Read the OpenStack Style Commandments
  http://docs.openstack.org/developer/hacking/
- Step 2: Read on

Keystone Specific Commandments
------------------------------

- Avoid using "double quotes" where you can reasonably use 'single quotes'


TODO vs FIXME
-------------

- TODO(name): implies that something should be done (cleanup, refactoring,
  etc), but is expected to be functional.
- FIXME(name): implies that the method/function/etc shouldn't be used until
  that code is resolved and bug fixed.


Logging
-------

Use the common logging module, and ensure you ``getLogger``::

    from oslo_log import log

    LOG = log.getLogger(__name__)

    LOG.debug('Foobar')


AssertEqual argument order
--------------------------

assertEqual method's arguments should be in ('expected', 'actual') order.


Properly Calling Callables
--------------------------

Methods, functions and classes can specify optional parameters (with default
values) using Python's keyword arg syntax. When providing a value to such a
callable we prefer that the call also uses keyword arg syntax. For example::

    def f(required, optional=None):
        pass

    # GOOD
    f(0, optional=True)

    # BAD
    f(0, True)

This gives us the flexibility to re-order arguments and more importantly
to add new required arguments. It's also more explicit and easier to read.