Skip to content

Commit

Permalink
fix: upgrade mypy, pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
koba-e964 committed May 3, 2024
1 parent 0fdcda9 commit 1b9a12c
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 33 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ on: [push, pull_request]

jobs:
format:
strategy:
matrix:
python-version:
- '3.8'
- '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]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 1 addition & 1 deletion onlinejudge_command/download_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
6 changes: 2 additions & 4 deletions onlinejudge_command/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
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
import onlinejudge_command.subcommand.login as subcommand_login
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__)

Expand Down Expand Up @@ -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.')
Expand Down
6 changes: 2 additions & 4 deletions onlinejudge_command/subcommand/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
3 changes: 1 addition & 2 deletions onlinejudge_command/subcommand/generate_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
3 changes: 1 addition & 2 deletions onlinejudge_command/subcommand/generate_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
4 changes: 2 additions & 2 deletions onlinejudge_command/subcommand/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
12 changes: 7 additions & 5 deletions onlinejudge_command/subcommand/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]))
Expand Down
4 changes: 1 addition & 3 deletions onlinejudge_command/subcommand/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
2 changes: 1 addition & 1 deletion onlinejudge_command/subcommand/test_reactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
2 changes: 1 addition & 1 deletion onlinejudge_command/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
9 changes: 6 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/implementation_language_guessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 1b9a12c

Please sign in to comment.