mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 10:31:29 +08:00
Add more ruff rules (#8767)
* Add more ruff rules * Add more ruff rules * pre-commit: Update ruff v0.0.269 -> v0.0.270 * Apply suggestions from code review * Fix doctest * Fix doctest (ignore whitespace) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -26,7 +26,8 @@ def get_subreddit_data(
|
||||
"""
|
||||
wanted_data = wanted_data or []
|
||||
if invalid_search_terms := ", ".join(sorted(set(wanted_data) - valid_terms)):
|
||||
raise ValueError(f"Invalid search term: {invalid_search_terms}")
|
||||
msg = f"Invalid search term: {invalid_search_terms}"
|
||||
raise ValueError(msg)
|
||||
response = requests.get(
|
||||
f"https://reddit.com/r/{subreddit}/{age}.json?limit={limit}",
|
||||
headers={"User-agent": "A random string"},
|
||||
|
@ -22,7 +22,8 @@ def get_openlibrary_data(olid: str = "isbn/0140328726") -> dict:
|
||||
"""
|
||||
new_olid = olid.strip().strip("/") # Remove leading/trailing whitespace & slashes
|
||||
if new_olid.count("/") != 1:
|
||||
raise ValueError(f"{olid} is not a valid Open Library olid")
|
||||
msg = f"{olid} is not a valid Open Library olid"
|
||||
raise ValueError(msg)
|
||||
return requests.get(f"https://openlibrary.org/{new_olid}.json").json()
|
||||
|
||||
|
||||
|
@ -7,10 +7,11 @@ def send_slack_message(message_body: str, slack_url: str) -> None:
|
||||
headers = {"Content-Type": "application/json"}
|
||||
response = requests.post(slack_url, json={"text": message_body}, headers=headers)
|
||||
if response.status_code != 200:
|
||||
raise ValueError(
|
||||
f"Request to slack returned an error {response.status_code}, "
|
||||
f"the response is:\n{response.text}"
|
||||
msg = (
|
||||
"Request to slack returned an error "
|
||||
f"{response.status_code}, the response is:\n{response.text}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user