Skip to content

Commit

Permalink
Enforce a pylint style of 10.0 with fine-grained exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
okurz committed Jan 30, 2024
1 parent 1cec709 commit 5d72455
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion openqabot/approver.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def osc_approve(inc: IncReq) -> bool:
)
except HTTPError as e:
return _handle_http_error(e, inc)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
return False

Expand Down
6 changes: 3 additions & 3 deletions openqabot/loader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def load_metadata(
for p in get_yml_list(path):
try:
data = loader.load(p)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
continue

Expand Down Expand Up @@ -79,7 +79,7 @@ def read_products(path: Path) -> List[Data]:
distri = data["settings"]["DISTRI"]
version = data["settings"]["VERSION"]
product = data["product"]
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
continue

Expand All @@ -94,7 +94,7 @@ def get_onearch(path: Path) -> Set[str]:

try:
data = loader.load(path)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
return set()

Expand Down
6 changes: 3 additions & 3 deletions openqabot/loader/qem.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def update_incidents(token: Dict[str, str], data, **kwargs) -> int:
retry -= 1
try:
ret = req.patch(QEM_DASHBOARD + "api/incidents", headers=token, json=data)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
return 1
if ret.status_code == 200:
Expand All @@ -255,7 +255,7 @@ def post_job(token: Dict[str, str], data) -> None:
if result.status_code != 200:
log.error(result.text)

except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)


Expand All @@ -267,5 +267,5 @@ def update_job(token: Dict[str, str], job_id: int, data) -> None:
if result.status_code != 200:
log.error(result.text)

except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
2 changes: 1 addition & 1 deletion openqabot/loader/smelt.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_incident(incident: int):
except ValidationError:
log.exception("Invalid data from SMELT for incident %s", incident)
return None
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.error("Unknown error for incident %s", incident)
log.exception(e)
return None
Expand Down
2 changes: 1 addition & 1 deletion openqabot/openqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_job_comments(self, job_id: int):
"GET", "jobs/%s/comments" % job_id, retries=self.retries
)
ret = list(map(lambda c: {"text": c.get("text", "")}, ret))
except Exception as e:
except Exception as e: # pylint: disable=broad-except
(_, _, status_code, *_) = e.args
if status_code == 404:
self.handle_job_not_found(job_id)
Expand Down
2 changes: 1 addition & 1 deletion openqabot/types/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __call__(
params={"product": self.product, "arch": arch},
headers=token,
).json()
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
old_jobs = None

Expand Down
4 changes: 2 additions & 2 deletions openqabot/types/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _is_scheduled_job(
f"{QEM_DASHBOARD}api/incident_settings/{inc.id}",
headers=token,
).json()
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)

if not jobs:
Expand All @@ -76,7 +76,7 @@ def _is_scheduled_job(

return False

def _handle_incident(
def _handle_incident( # pylint: disable=too-many-return-statements
self,
inc: Incident,
arch,
Expand Down
2 changes: 1 addition & 1 deletion pc_helper_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main():
apply_publiccloud_pint_image(settings)
if "PUBLIC_CLOUD_IMAGE_ID" not in settings:
log.error("Failed to get PUBLIC_CLOUD_IMAGE_ID from %s", data)
except Exception as e:
except Exception as e: # pylint: disable=broad-except
log.exception(e)
continue

Expand Down
3 changes: 2 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[MASTER]

disable=
missing-docstring,
bad-continuation,
C0103, # invalid-name
C0114, # missing-module-docstring
C0115, # missing-class-docstring
Expand Down Expand Up @@ -30,4 +32,3 @@ disable=
W4905, # deprecated-decorator

recursive = true
fail-under=9.9

0 comments on commit 5d72455

Please sign in to comment.