diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a509e16..d08a30b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,6 @@ linters: stage: quality-assurance image: python:3-alpine before_script: - - pip instal tox + - pip install tox script: tox -e linters allow_failure: true diff --git a/dungeonbattle/interfaces.py b/dungeonbattle/interfaces.py index 03550d1..1674427 100644 --- a/dungeonbattle/interfaces.py +++ b/dungeonbattle/interfaces.py @@ -11,17 +11,19 @@ class Map: self.tiles = tiles @staticmethod - def load(filename): + def load(filename: str): with open(filename, "r") as f: file = f.read() return Map.load_from_string(file) @staticmethod - def load_from_string(content): + def load_from_string(content: str): lines = content.split("\n") + lines = [line for line in lines if line] height = len(lines) - width = len(lines[0]) - 1 - chars = [[Tile.from_char(c, x, y) for x, c in enumerate(line)] for y, line in enumerate(lines)] + width = len(lines[0]) + chars = [[Tile.from_char(c, x, y) + for x, c in enumerate(line)] for y, line in enumerate(lines)] return Map(width, height, chars) @@ -42,6 +44,6 @@ class Tile: class Entity: tile: Tile - def move(self, x, y): + def move(self, x: int, y: int) -> None: self.tile.x = x self.tile.y = y diff --git a/dungeonbattle/interfaces_test.py b/dungeonbattle/interfaces_test.py index 35fffe0..a987b37 100644 --- a/dungeonbattle/interfaces_test.py +++ b/dungeonbattle/interfaces_test.py @@ -4,7 +4,7 @@ from dungeonbattle.interfaces import Map class TestInterfaces(unittest.TestCase): - def test_map(self): + def test_map(self) -> None: m = Map.load_from_string("ab\ncd\n") self.assertEqual(m.width, 2) self.assertEqual(m.height, 2) diff --git a/tox.ini b/tox.ini index 72c18d6..098a080 100644 --- a/tox.ini +++ b/tox.ini @@ -27,7 +27,7 @@ commands = flake8 main.py dungeonbattle [flake8] -ignore = W503 ANN002 ANN03 ANN101 ANN102 ANN204 +ignore = W503 ANN002 ANN003 ANN101 ANN102 ANN204 ANN205 exclude = .tox, .git,