From 42cf11044e1b7546208805181ecb0c9b0b12f3df Mon Sep 17 00:00:00 2001 From: Stepland <16676308+Stepland@users.noreply.github.com> Date: Sun, 2 May 2021 13:52:07 +0200 Subject: [PATCH] Activate more mypy checks --- jubeatools/formats/jubeat_analyser/memo2/load.py | 10 +--------- jubeatools/formats/memon/test_memon.py | 2 +- jubeatools/formats/typing.py | 3 +-- jubeatools/testutils/strategies.py | 6 ++++-- mypy.ini | 15 ++++++++++++--- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/jubeatools/formats/jubeat_analyser/memo2/load.py b/jubeatools/formats/jubeat_analyser/memo2/load.py index 47d364d..3c817b3 100644 --- a/jubeatools/formats/jubeat_analyser/memo2/load.py +++ b/jubeatools/formats/jubeat_analyser/memo2/load.py @@ -205,8 +205,6 @@ class Memo2Parser(JubeatAnalyserParser): "offset increase command (r=...) found outside of the file " "header, this is not supported by jubeatools" ) - elif self.offset is None: - super().do_o(value) else: super().do_r(value) @@ -264,13 +262,7 @@ class Memo2Parser(JubeatAnalyserParser): "Chart contains a pause that's not happening at the " "very first beat, these are not supported by jubeatools" ) - if self.offset is None: - self.offset = event.duration - else: - # This could happen if several pauses exist at the first - # beat of the chart or if both an in-bar pause and an - # o=... command exist - self.offset += event.duration + self.offset += event.duration bar_notes = [e for e in bar if isinstance(e, str)] line = Memo2ChartLine(raw_line.position, bar_notes) diff --git a/jubeatools/formats/memon/test_memon.py b/jubeatools/formats/memon/test_memon.py index bb1c55c..8679abb 100644 --- a/jubeatools/formats/memon/test_memon.py +++ b/jubeatools/formats/memon/test_memon.py @@ -30,7 +30,7 @@ def dump_and_load( filename, contents = list(files.items())[0] file.write(contents) file.seek(0) - actual_song = load_function(file.name) + actual_song = load_function(Path(file.name)) assert expected_song == actual_song diff --git a/jubeatools/formats/typing.py b/jubeatools/formats/typing.py index 0047fb7..2ebfeb9 100644 --- a/jubeatools/formats/typing.py +++ b/jubeatools/formats/typing.py @@ -1,7 +1,6 @@ +from pathlib import Path from typing import Any, Callable, Dict, Protocol -from path import Path - from jubeatools.song import Song diff --git a/jubeatools/testutils/strategies.py b/jubeatools/testutils/strategies.py index 9c555a4..7252a92 100644 --- a/jubeatools/testutils/strategies.py +++ b/jubeatools/testutils/strategies.py @@ -4,7 +4,7 @@ Hypothesis strategies to generate notes and charts from decimal import Decimal from enum import Enum, Flag, auto from itertools import product -from typing import Any, Callable, List, Optional, Set, TypeVar, Union +from typing import Any, Callable, Dict, List, Optional, Set, TypeVar, Union import hypothesis.strategies as st from multidict import MultiDict @@ -118,7 +118,9 @@ def notes(draw: DrawFunc, options: NoteOption) -> Set[Union[TapNote, LongNote]]: if NoteOption.COLLISIONS in options: return raw_notes else: - last_notes = {NotePosition(x, y): None for y, x in product(range(4), range(4))} + last_notes: Dict[NotePosition, Optional[BeatsTime]] = { + NotePosition(x, y): None for y, x in product(range(4), range(4)) + } notes: Set[Union[TapNote, LongNote]] = set() for note in sorted(raw_notes, key=lambda n: (n.time, n.position)): last_note_time = last_notes[note.position] diff --git a/mypy.ini b/mypy.ini index 9d1de39..2699243 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,11 +1,20 @@ [mypy] -#disallow_untyped_calls = True +disallow_untyped_calls = True disallow_untyped_defs = True disallow_incomplete_defs = True check_untyped_defs = True -#disallow_untyped_decorator = True +#disallow_untyped_decorators = True no_implicit_optional = True +warn_redundant_casts = True warn_unused_ignores = True warn_return_any = True -warn_redundant_casts = True +warn_unreachable = True + +[mypy-constraint] +ignore_missing_imports = True + +[mypy-parsimonious.*] +ignore_missing_imports = True + +[mypy-sortedcontainers] ignore_missing_imports = True \ No newline at end of file