Skip to content

Commit 5a97f43

Browse files
author
Bryan Sieber
committed
C0116 missing-function-docstring--pylint--enabled
1 parent dd80fb7 commit 5a97f43

File tree

14 files changed

+74
-16
lines changed

14 files changed

+74
-16
lines changed

infra/gunicorn_conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@
7373
}
7474

7575

76-
def child_exit(server, worker):
76+
def child_exit(server, worker): # pylint: disable=missing-function-docstring
7777
multiprocess.mark_process_dead(worker.pid)

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ testpaths = [
4545
[tool.pylint]
4646
[tool.pylint.'MESSAGES CONTROL']
4747
disable = [
48-
"C0116", #missing-function-docstring
4948
"C0301", #line-too-long
5049
"R0903", #too-few-public-methods
5150
"W0613", #unused-argument

src/app/api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def root(request: Request):
4040

4141
@app.middleware("http")
4242
async def request_summary(request: Request, call_next):
43+
"""
44+
Middleware to log request info
45+
:param request:
46+
:param call_next:
47+
:return: response
48+
"""
4349
summary_logger = logging.getLogger("request.summary")
4450
previous_time = time.time()
4551

@@ -66,6 +72,10 @@ async def request_summary(request: Request, call_next):
6672

6773
@app.on_event("startup")
6874
def startup_event():
75+
"""
76+
On app startup perform these setup operations
77+
:return:
78+
"""
6979
configure_logging()
7080

7181

src/app/environment.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class Settings(BaseSettings):
3333

3434
@lru_cache()
3535
def get_settings() -> Settings:
36+
"""
37+
Return the Settings object; use cache
38+
"""
3639
return Settings()
3740

3841

src/app/log.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212

1313
def configure_logging():
14+
"""
15+
Configure logging; mozlog format for Dockerflow
16+
"""
1417
logging_config = {
1518
"version": 1,
1619
"formatters": {

src/app/monitor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def get_heartbeat(
2828
request: Request,
2929
settings: environment.Settings = Depends(environment.get_settings),
3030
):
31+
"""
32+
Dockerflow API for heartbeat: GET
33+
"""
3134
return heartbeat(request, settings)
3235

3336

@@ -36,6 +39,9 @@ def head_heartbeat(
3639
request: Request,
3740
settings: environment.Settings = Depends(environment.get_settings),
3841
):
42+
"""
43+
Dockerflow API for heartbeat: HEAD
44+
"""
3945
return heartbeat(request, settings)
4046

4147

@@ -46,11 +52,17 @@ def lbheartbeat(request: Request):
4652

4753
@api_router.get("/__lbheartbeat__")
4854
def get_lbheartbeat(request: Request):
55+
"""
56+
Dockerflow API for lbheartbeat: GET
57+
"""
4958
return lbheartbeat(request)
5059

5160

5261
@api_router.head("/__lbheartbeat__")
5362
def head_lbheartbeat(request: Request):
63+
"""
64+
Dockerflow API for lbheartbeat: HEAD
65+
"""
5466
return lbheartbeat(request)
5567

5668

src/jbi/configuration.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class ProcessError(Exception):
3131
def get_yaml_configurations(
3232
jbi_config_file: str = f"config/config.{settings.env}.yaml",
3333
) -> Dict[str, Dict]:
34+
"""
35+
Convert and validate YAML configuration to python dict
36+
"""
3437

3538
with open(jbi_config_file, encoding="utf-8") as file:
3639
try:
@@ -46,6 +49,9 @@ def get_yaml_configurations(
4649

4750

4851
def process_actions(action_configuration) -> Dict[str, Dict]:
52+
"""
53+
Validate `actions` section of the YAML config
54+
"""
4955
requested_actions = {}
5056
for yaml_action_key, inner_action_dict in action_configuration.items():
5157
inner_action_dict.setdefault("action", "src.jbi.whiteboard_actions.default")
@@ -60,7 +66,7 @@ def process_actions(action_configuration) -> Dict[str, Dict]:
6066

6167

6268
def validate_action_yaml_jbi_naming(yaml_action_key, action_dict):
63-
# Validate yaml_action_key == parameters.whiteboard_tag
69+
"""Validate yaml_action_key == parameters.whiteboard_tag"""
6470
wb_tag = action_dict["parameters"].get("whiteboard_tag")
6571
if yaml_action_key != wb_tag:
6672
raise ConfigError(
@@ -70,7 +76,7 @@ def validate_action_yaml_jbi_naming(yaml_action_key, action_dict):
7076

7177

7278
def validate_action_yaml_module(action_dict: Dict[str, Any]):
73-
# Validate action: exists, has init function, and has expected params
79+
"""Validate action: exists, has init function, and has expected params"""
7480
try:
7581
action: str = action_dict.get("action") # type: ignore
7682
action_parameters: Optional[Dict[str, Any]] = action_dict.get("parameters")

src/jbi/router.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,29 @@
1919

2020

2121
def execute_request(request, settings):
22-
# Is request valid?
23-
# Is whiteboard known?
24-
# Execute desired action -- based on whiteboard config
25-
pass
22+
"""
23+
Is request valid?
24+
Is whiteboard known?
25+
Execute desired action -- based on whiteboard config
26+
"""
2627

2728

2829
@api_router.post("/bugzilla_webhook")
2930
def bugzilla_webhook(
3031
request: Request,
3132
settings: environment.Settings = Depends(environment.get_settings),
3233
):
34+
"""
35+
API endpoint that Bugzilla Webhook Events request
36+
"""
3337
return execute_request(request, settings)
3438

3539

3640
@api_router.get("/whiteboard_tags/")
3741
def get_whiteboard_tag(
3842
whiteboard_tag: Optional[str] = None,
3943
):
44+
"""API for viewing whiteboard_tags"""
4045
data = configuration.get_yaml_configurations()
4146
if whiteboard_tag:
4247
wb_val = data.get(whiteboard_tag)
@@ -47,6 +52,7 @@ def get_whiteboard_tag(
4752

4853
@api_router.get("/actions/")
4954
def get_actions_by_type(action_type: Optional[str] = None):
55+
"""API for viewing actions"""
5056
configured_actions = configuration.get_yaml_configurations()
5157
if action_type:
5258
data = [
@@ -61,6 +67,7 @@ def get_actions_by_type(action_type: Optional[str] = None):
6167

6268
@api_router.get("/powered_by_jbi", response_class=HTMLResponse)
6369
def powered_by_jbi(request: Request, enabled: Optional[bool] = None):
70+
"""API for `Powered By` endpoint"""
6471
data = configuration.get_yaml_configurations()
6572
context = {
6673
"request": request,

src/jbi/services.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
def get_jira():
16+
"""Get atlassian Jira Service"""
1617
return Jira(
1718
url=settings.jira_base_url,
1819
username=settings.jira_username,
@@ -21,18 +22,21 @@ def get_jira():
2122

2223

2324
def get_bugzilla():
25+
"""Get bugzilla service"""
2426
return rh_bugzilla.Bugzilla(
2527
settings.bugzilla_base_url, api_key=settings.bugzilla_api_key
2628
)
2729

2830

2931
def bugzilla_check_health():
32+
"""Check health for Bugzilla Service"""
3033
bugzilla = get_bugzilla()
3134
health = {"up": bugzilla.logged_in}
3235
return health
3336

3437

3538
def jira_check_health():
39+
"""Check health for Jira Service"""
3640
jira = get_jira()
3741
server_info = jira.get_server_info(True)
3842
services_logger.info(server_info)
@@ -41,6 +45,7 @@ def jira_check_health():
4145

4246

4347
def jbi_service_health_map():
48+
"""Returns dictionary of health check's for Bugzilla and Jira Services"""
4449
return {
4550
"bugzilla": bugzilla_check_health(),
4651
"jira": jira_check_health(),

src/jbi/whiteboard_actions/default.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99

1010
def init(whiteboard_tag, jira_project_key, **kwargs):
11+
"""
12+
Function that takes required and optional params and returns a callable object
13+
:param whiteboard_tag: Required param
14+
:param jira_project_key: Required param
15+
:param kwargs: Optional params
16+
:return: DefaultExecutor
17+
"""
1118
return DefaultExecutor(
1219
whiteboard_tag=whiteboard_tag, jira_project_key=jira_project_key, **kwargs
1320
)
@@ -19,12 +26,15 @@ class DefaultExecutor:
1926
"""
2027

2128
def __init__(self, **kwargs):
29+
"""Initialize DefaultExecutor Object"""
2230
self.parameters = kwargs
2331
self.whiteboard_tag = kwargs.get("whiteboard_tag")
2432
self.jira_project_key = kwargs.get("jira_project_key")
2533

2634
def __call__(self, payload):
27-
# Called from BZ webhook
28-
# Call Jira SDK with project key etc.
35+
"""
36+
Called from BZ webhook
37+
Call Jira SDK with project key etc.
38+
"""
2939
print(payload)
3040
print(self.parameters)

0 commit comments

Comments
 (0)