question_utils.py each long line has been split to ensure that no line exceeds 100 characters (#10568)

This commit is contained in:
Adam Djellouli 2025-04-24 21:35:49 +02:00 committed by GitHub
parent d3fd48bd84
commit 5fde9ba3d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,7 +22,11 @@ def get_file_content() -> str:
def get_question_list(file_content: str) -> List[str]: def get_question_list(file_content: str) -> List[str]:
details = DETAILS_PATTERN.findall(file_content) details = DETAILS_PATTERN.findall(file_content)
return [SUMMARY_PATTERN.search(detail).group(1) for detail in details if SUMMARY_PATTERN.search(detail)] return [
SUMMARY_PATTERN.search(detail).group(1)
for detail in details
if SUMMARY_PATTERN.search(detail)
]
def get_answered_questions(file_content: str) -> List[str]: def get_answered_questions(file_content: str) -> List[str]:
@ -31,7 +35,12 @@ def get_answered_questions(file_content: str) -> List[str]:
for detail in details: for detail in details:
summary_match = SUMMARY_PATTERN.search(detail) summary_match = SUMMARY_PATTERN.search(detail)
b_match = B_PATTERN.search(detail) b_match = B_PATTERN.search(detail)
if summary_match and b_match and summary_match.group(1).strip() and b_match.group(1).strip(): if (
summary_match
and b_match
and summary_match.group(1).strip()
and b_match.group(1).strip()
):
answered.append(summary_match.group(1)) answered.append(summary_match.group(1))
return answered return answered
@ -58,9 +67,15 @@ you will end up doing the same thing twice.
eg: eg:
# my_dir/main.py # my_dir/main.py
from scripts import question_utils from scripts import question_utils
print(question_utils.get_answered_questions(question_utils.get_question_list(question_utils.get_file_content()))
print(
question_utils.get_answered_questions(
question_utils.get_question_list(
question_utils.get_file_content()
)
)
)
>> 123 >> 123
# noqa: E501
""" """
if __name__ == "__main__": if __name__ == "__main__":