1 Star 0 Fork 6

MindFly/keystone

forked from openstack/keystone 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
HACKING.rst 1.39 KB
一键复制 编辑 原始数据 按行查看 历史

Keystone Style Commandments

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.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/midfly.com/keystone.git
git@gitee.com:midfly.com/keystone.git
midfly.com
keystone
keystone
master

搜索帮助