概述
这些规范如果不遵守的话,可能程序也不会报错,不过 idea 会有提示
规范
类的块和块之间推荐要2个空行,不过类的方法之间推荐只有一个空行
例如下例中,BaseQueryBatchPersonMailSchema 类和 QueryBatchPersonMailSchema 类,中间空了两行。
class BaseQueryBatchPersonMailSchema(Schema):
"""
查询个人邮件
"""
logical_region_id = permission.Logical(required=True)
server_id = permission.Server(required=True)
mail_batch_id = fields.String()
class QueryBatchPersonMailSchema(BaseQueryBatchPersonMailSchema):
"""
查询批次个人邮件
"""
page_no = fields.Integer(required=True)
page_size = fields.Integer(required=True)
代码中,最后一个要有一个空行
例如下例中,代码最后有一个空行
class QueryBatchPersonMailSchema(BaseQueryBatchPersonMailSchema):
"""
查询批次个人邮件
"""
page_no = fields.Integer(required=True)
page_size = fields.Integer(required=True)
这里需要有个空行
参数缩进要对齐
例如下例中,mail_batch 参数和上一行的 logical_region_id 参数对齐了。
return self.service.query_person_mail_batch(logical_region_id, server_id, page_no, page_size,
mail_batch=mail_batch)要和上一行对齐
在代码末尾注释,注释和代码中间要有两个空格
例如下例中,params)
和 # wqy..
中间有两个空格
_, err = self.game_request(30411, logical_region_id, server_id, params) # wqytodo 需要确认接口号