From 5ce9011efb2d4d38b61326c369d0a56282f3607a Mon Sep 17 00:00:00 2001 From: kyuridenamida Date: Sat, 8 Jun 2024 00:36:59 +0900 Subject: [PATCH] Fix format --- atcodertools/atcoder_tools.py | 3 ++- atcodertools/common/language.py | 3 ++- atcodertools/constprediction/constants_prediction.py | 9 ++++++--- atcodertools/tools/codegen.py | 3 ++- atcodertools/tools/envgen.py | 3 ++- tests/test_language.py | 4 +++- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/atcodertools/atcoder_tools.py b/atcodertools/atcoder_tools.py index a115dda5..7b391f58 100644 --- a/atcodertools/atcoder_tools.py +++ b/atcodertools/atcoder_tools.py @@ -43,7 +43,8 @@ def main(): if len(sys.argv) < 2 or sys.argv[1] not in ("gen", "test", "submit", "codegen", "compile", "set", "version"): print("Usage:") print("{} gen -- to generate workspace".format(sys.argv[0])) - print("{} codegen -- to generate code for one problem".format(sys.argv[0])) + print( + "{} codegen -- to generate code for one problem".format(sys.argv[0])) print( "{} compile -- to compile codes in your workspace".format(sys.argv[0])) print("{} test -- to test codes in your workspace".format(sys.argv[0])) diff --git a/atcodertools/common/language.py b/atcodertools/common/language.py index 6e787651..331c5729 100644 --- a/atcodertools/common/language.py +++ b/atcodertools/common/language.py @@ -123,7 +123,8 @@ def from_name(cls, name: str): name="python", display_name="Python", extension="py", - submission_lang_pattern=re.compile(".*Python \\(3.*|.*Python \\(CPython 3.*"), + submission_lang_pattern=re.compile( + ".*Python \\(3.*|.*Python \\(CPython 3.*"), default_code_generator=python.main, default_template_path=get_default_template_path('py'), compile_command="python3 -mpy_compile {filename}.py", diff --git a/atcodertools/constprediction/constants_prediction.py b/atcodertools/constprediction/constants_prediction.py index a7ac15c0..4d1adf4e 100644 --- a/atcodertools/constprediction/constants_prediction.py +++ b/atcodertools/constprediction/constants_prediction.py @@ -222,7 +222,8 @@ def predict_is_format_analysis_allowed_by_rule(html: str) -> bool: is_target_contest_of_no_llm_rule = "/contests/abc" in url_meta_tag["content"] # If there is no virtual standings link, assume it's ongoing. - is_ongoing_contest = len([tag for tag in soup.find_all("a") if "/standings/virtual" in tag.get("href", "")]) == 0 + is_ongoing_contest = len([tag for tag in soup.find_all( + "a") if "/standings/virtual" in tag.get("href", "")]) == 0 if is_target_contest_of_no_llm_rule and is_ongoing_contest: return False @@ -258,9 +259,11 @@ def predict_constants(html: str) -> ProblemConstantSet: timeout = None try: - is_format_analysis_allowed_by_rule = predict_is_format_analysis_allowed_by_rule(html) + is_format_analysis_allowed_by_rule = predict_is_format_analysis_allowed_by_rule( + html) except FailingToKnowFormatAnalysisAllowedByRuleError as e: - logger.warning("Failed to know whether format analysis is allowed by the contest rules -- ", e.reason) + logger.warning( + "Failed to know whether format analysis is allowed by the contest rules -- ", e.reason) is_format_analysis_allowed_by_rule = None return ProblemConstantSet( diff --git a/atcodertools/tools/codegen.py b/atcodertools/tools/codegen.py index 71df263d..b08acba2 100755 --- a/atcodertools/tools/codegen.py +++ b/atcodertools/tools/codegen.py @@ -92,7 +92,8 @@ def emit_info(text): constants = predict_constants(content.original_html) try: - prediction_result = predict_format(content, constants.is_format_analysis_allowed_by_rule or False) + prediction_result = predict_format( + content, constants.is_format_analysis_allowed_by_rule or False) emit_info( with_color("Format prediction succeeded", Fore.LIGHTGREEN_EX)) except (NoPredictionResultError, MultiplePredictionResultsError, PredictionNotAllowedError) as e: diff --git a/atcodertools/tools/envgen.py b/atcodertools/tools/envgen.py index 15a43e7e..ddd2d36a 100755 --- a/atcodertools/tools/envgen.py +++ b/atcodertools/tools/envgen.py @@ -120,7 +120,8 @@ def emit_info(text): constants = predict_constants(content.original_html) try: - prediction_result = predict_format(content, constants.is_format_analysis_allowed_by_rule or False) + prediction_result = predict_format( + content, constants.is_format_analysis_allowed_by_rule or False) emit_info( with_color("Format prediction succeeded", Fore.LIGHTGREEN_EX)) except (NoPredictionResultError, MultiplePredictionResultsError, PredictionNotAllowedError) as e: diff --git a/tests/test_language.py b/tests/test_language.py index edc8d49c..d9c19f2b 100755 --- a/tests/test_language.py +++ b/tests/test_language.py @@ -2,6 +2,7 @@ from atcodertools.common.language import CPP, JAVA, RUST, PYTHON, DLANG, NIM, CSHARP, SWIFT, GO, JULIA + class TestLanguage(unittest.TestCase): def test_compilers(self): language_compiler_map = { @@ -26,7 +27,7 @@ def test_previous_compilers(self): JAVA: 'Java (OpenJDK 11.0.6)', RUST: 'Rust (1.42.0)', PYTHON: 'Python (3.8.2)', - DLANG: 'D (DMD 2.091.0)', + DLANG: 'D (DMD 2.091.0)', NIM: 'Nim (1.0.6)', CSHARP: 'C# (Mono-mcs 6.8.0.105)', SWIFT: 'Swift (5.2.1)', @@ -36,5 +37,6 @@ def test_previous_compilers(self): for language, compiler in language_compiler_map.items(): self.assertRegex(compiler, language.submission_lang_pattern) + if __name__ == '__main__': unittest.main()