diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 64a989cf..764fb579 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -4,18 +4,25 @@ on: [push, pull_request] jobs: format: + strategy: + matrix: + python-version: + - '3.12' + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} - name: Install dependencies - run: pip3 install .[dev] + run: | + pip3 install --upgrade setuptools + pip3 install .[dev] - name: Run --version run: oj --version diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d2919a9f..acbe8953 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/onlinejudge_command/download_history.py b/onlinejudge_command/download_history.py index cb87db65..8be5372e 100644 --- a/onlinejudge_command/download_history.py +++ b/onlinejudge_command/download_history.py @@ -5,8 +5,8 @@ from logging import getLogger from typing import * -import onlinejudge_command.utils as utils from onlinejudge.type import Problem +from onlinejudge_command import utils logger = getLogger(__name__) diff --git a/onlinejudge_command/main.py b/onlinejudge_command/main.py index 1bd14509..66351be9 100644 --- a/onlinejudge_command/main.py +++ b/onlinejudge_command/main.py @@ -8,7 +8,6 @@ import onlinejudge.__about__ as api_version import onlinejudge_command.__0_workaround_for_conflict # pylint: disable=unused-import import onlinejudge_command.__about__ as version -import onlinejudge_command.log_formatter as log_formatter import onlinejudge_command.subcommand.download as subcommand_download import onlinejudge_command.subcommand.generate_input as subcommand_generate_input import onlinejudge_command.subcommand.generate_output as subcommand_generate_output @@ -16,8 +15,7 @@ import onlinejudge_command.subcommand.submit as subcommand_submit import onlinejudge_command.subcommand.test as subcommand_test import onlinejudge_command.subcommand.test_reactive as subcommand_test_reactive -import onlinejudge_command.update_checking as update_checking -import onlinejudge_command.utils as utils +from onlinejudge_command import log_formatter, update_checking, utils logger = getLogger(__name__) @@ -99,7 +97,7 @@ def main(args: Optional[List[str]] = None) -> 'NoReturn': try: sys.exit(run_program(parsed, parser=parser)) - except NotImplementedError as e: + except NotImplementedError: logger.debug('\n' + traceback.format_exc()) logger.error('NotImplementedError') logger.info('The operation you specified is not supported yet. Pull requests are welcome.') diff --git a/onlinejudge_command/subcommand/download.py b/onlinejudge_command/subcommand/download.py index bbd287e6..fd53a4ab 100644 --- a/onlinejudge_command/subcommand/download.py +++ b/onlinejudge_command/subcommand/download.py @@ -8,14 +8,12 @@ import requests.exceptions -import onlinejudge.dispatch as dispatch import onlinejudge_command.download_history -import onlinejudge_command.format_utils as format_utils -import onlinejudge_command.pretty_printers as pretty_printers -import onlinejudge_command.utils as utils +from onlinejudge import dispatch from onlinejudge.service.atcoder import AtCoderProblem from onlinejudge.service.yukicoder import YukicoderProblem from onlinejudge.type import SampleParseError, TestCase +from onlinejudge_command import format_utils, pretty_printers, utils logger = getLogger(__name__) diff --git a/onlinejudge_command/subcommand/generate_input.py b/onlinejudge_command/subcommand/generate_input.py index cbeea835..9c4fba98 100644 --- a/onlinejudge_command/subcommand/generate_input.py +++ b/onlinejudge_command/subcommand/generate_input.py @@ -11,8 +11,7 @@ from typing import * import onlinejudge_command.format_utils as fmtutils -import onlinejudge_command.pretty_printers as pretty_printers -import onlinejudge_command.utils as utils +from onlinejudge_command import pretty_printers, utils logger = getLogger(__name__) diff --git a/onlinejudge_command/subcommand/generate_output.py b/onlinejudge_command/subcommand/generate_output.py index 9637490b..6f59a2d0 100644 --- a/onlinejudge_command/subcommand/generate_output.py +++ b/onlinejudge_command/subcommand/generate_output.py @@ -8,8 +8,7 @@ from typing import * import onlinejudge_command.format_utils as fmtutils -import onlinejudge_command.pretty_printers as pretty_printers -import onlinejudge_command.utils as utils +from onlinejudge_command import pretty_printers, utils logger = getLogger(__name__) diff --git a/onlinejudge_command/subcommand/login.py b/onlinejudge_command/subcommand/login.py index 392c6587..0c30910d 100644 --- a/onlinejudge_command/subcommand/login.py +++ b/onlinejudge_command/subcommand/login.py @@ -9,9 +9,9 @@ import requests -import onlinejudge.dispatch as dispatch -import onlinejudge_command.utils as utils +from onlinejudge import dispatch from onlinejudge.type import LoginError, Service +from onlinejudge_command import utils logger = getLogger(__name__) diff --git a/onlinejudge_command/subcommand/submit.py b/onlinejudge_command/subcommand/submit.py index e50ccca8..075ed77a 100644 --- a/onlinejudge_command/subcommand/submit.py +++ b/onlinejudge_command/subcommand/submit.py @@ -7,11 +7,10 @@ from logging import getLogger from typing import * -import onlinejudge.dispatch as dispatch import onlinejudge_command.download_history -import onlinejudge_command.pretty_printers as pretty_printers -import onlinejudge_command.utils as utils +from onlinejudge import dispatch from onlinejudge.type import * +from onlinejudge_command import pretty_printers, utils logger = getLogger(__name__) @@ -142,7 +141,7 @@ def run(args: argparse.Namespace) -> bool: return False # confirm - guessed_unmatch = ([problem.get_url()] != guessed_urls) + guessed_unmatch = [problem.get_url()] != guessed_urls if guessed_unmatch: samples_text = ('samples of "{}'.format('", "'.join(guessed_urls)) if guessed_urls else 'no samples') logger.warning('the problem "%s" is specified to submit, but %s were downloaded in this directory. this may be mis-operation', problem.get_url(), samples_text) @@ -321,7 +320,10 @@ def guess_lang_ids_of_file(filename: pathlib.Path, code: bytes, language_dict, c saved_lang_ids = lang_ids lang_ids = [] for compiler in ('gcc', 'clang'): # use the latest for each compiler - ids = list(filter(lambda lang_id: parse_cplusplus_compiler(language_dict[lang_id]) in (compiler, None), saved_lang_ids)) + ids = [] + for lang_id in saved_lang_ids: + if parse_cplusplus_compiler(language_dict[lang_id]) in (compiler, None): + ids.append(lang_id) if not ids: continue ids.sort(key=lambda lang_id: (parse_cplusplus_version(language_dict[lang_id]) or '', language_dict[lang_id])) diff --git a/onlinejudge_command/subcommand/test.py b/onlinejudge_command/subcommand/test.py index e4587012..465b5ab0 100644 --- a/onlinejudge_command/subcommand/test.py +++ b/onlinejudge_command/subcommand/test.py @@ -14,9 +14,7 @@ from typing import * import onlinejudge_command.format_utils as fmtutils -import onlinejudge_command.output_comparators as output_comparators -import onlinejudge_command.pretty_printers as pretty_printers -import onlinejudge_command.utils as utils +from onlinejudge_command import output_comparators, pretty_printers, utils from onlinejudge_command.output_comparators import CompareMode logger = getLogger(__name__) diff --git a/onlinejudge_command/subcommand/test_reactive.py b/onlinejudge_command/subcommand/test_reactive.py index c31a9a64..31c58318 100644 --- a/onlinejudge_command/subcommand/test_reactive.py +++ b/onlinejudge_command/subcommand/test_reactive.py @@ -6,7 +6,7 @@ from logging import getLogger from typing import * -import onlinejudge_command.utils as utils +from onlinejudge_command import utils logger = getLogger(__name__) diff --git a/onlinejudge_command/utils.py b/onlinejudge_command/utils.py index 24c420d6..6bc21685 100644 --- a/onlinejudge_command/utils.py +++ b/onlinejudge_command/utils.py @@ -19,8 +19,8 @@ import colorama import requests -import onlinejudge.utils as utils import onlinejudge_command.__about__ as version +from onlinejudge import utils from onlinejudge.type import * logger = getLogger(__name__) diff --git a/setup.cfg b/setup.cfg index 2c6a3e84..79d48daf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,8 +20,8 @@ selenium = selenium >= 3.141.0 dev = isort == 5.7.0 - mypy == 0.812 - pylint == 2.7.0 + mypy == 1.10.0 + pylint == 3.1.0 yapf == 0.30.0 pytest >= 6.2.2, < 7 @@ -38,6 +38,8 @@ known_first_party = onlinejudge disable = broad-except, consider-using-enumerate, + consider-using-f-string, # TODO: remove this + consider-using-with, # TODO: remove this duplicate-code, fixme, invalid-name, @@ -50,7 +52,6 @@ disable = no-else-raise, no-else-return, no-member, - no-self-use, redefined-builtin, too-few-public-methods, too-many-arguments, @@ -62,6 +63,8 @@ disable = too-many-public-methods, too-many-return-statements, too-many-statements, + unnecessary-lambda-assignment, # TODO: remove this + unspecified-encoding, # TODO: remove this unused-argument, unused-wildcard-import, wildcard-import, diff --git a/tests/implementation_language_guessing.py b/tests/implementation_language_guessing.py index 8a17d639..fadcfd6b 100644 --- a/tests/implementation_language_guessing.py +++ b/tests/implementation_language_guessing.py @@ -2,8 +2,8 @@ import textwrap import unittest -import onlinejudge_command.subcommand.submit as submit from onlinejudge.type import Language, LanguageId +from onlinejudge_command.subcommand import submit # https://atcoder.jp/contests/language-test-ver1 languages_atcoder_3 = [