fix linting issues
This commit is contained in:
parent
3049f3dee3
commit
cf9341e3ef
5
.github/actions/lint.yml
vendored
5
.github/actions/lint.yml
vendored
@ -27,5 +27,6 @@ jobs:
|
||||
- name: ruff
|
||||
run: ruff src
|
||||
|
||||
- name: mypy
|
||||
run: mypy src
|
||||
# TODO: restore mypy linting
|
||||
# - name: mypy
|
||||
# run: mypy src
|
||||
|
73
poetry.lock
generated
73
poetry.lock
generated
@ -60,6 +60,64 @@ files = [
|
||||
{file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mypy"
|
||||
version = "1.10.0"
|
||||
description = "Optional static typing for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "mypy-1.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:da1cbf08fb3b851ab3b9523a884c232774008267b1f83371ace57f412fe308c2"},
|
||||
{file = "mypy-1.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:12b6bfc1b1a66095ab413160a6e520e1dc076a28f3e22f7fb25ba3b000b4ef99"},
|
||||
{file = "mypy-1.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e36fb078cce9904c7989b9693e41cb9711e0600139ce3970c6ef814b6ebc2b2"},
|
||||
{file = "mypy-1.10.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:2b0695d605ddcd3eb2f736cd8b4e388288c21e7de85001e9f85df9187f2b50f9"},
|
||||
{file = "mypy-1.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:cd777b780312ddb135bceb9bc8722a73ec95e042f911cc279e2ec3c667076051"},
|
||||
{file = "mypy-1.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3be66771aa5c97602f382230165b856c231d1277c511c9a8dd058be4784472e1"},
|
||||
{file = "mypy-1.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8b2cbaca148d0754a54d44121b5825ae71868c7592a53b7292eeb0f3fdae95ee"},
|
||||
{file = "mypy-1.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ec404a7cbe9fc0e92cb0e67f55ce0c025014e26d33e54d9e506a0f2d07fe5de"},
|
||||
{file = "mypy-1.10.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e22e1527dc3d4aa94311d246b59e47f6455b8729f4968765ac1eacf9a4760bc7"},
|
||||
{file = "mypy-1.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:a87dbfa85971e8d59c9cc1fcf534efe664d8949e4c0b6b44e8ca548e746a8d53"},
|
||||
{file = "mypy-1.10.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a781f6ad4bab20eef8b65174a57e5203f4be627b46291f4589879bf4e257b97b"},
|
||||
{file = "mypy-1.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b808e12113505b97d9023b0b5e0c0705a90571c6feefc6f215c1df9381256e30"},
|
||||
{file = "mypy-1.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f55583b12156c399dce2df7d16f8a5095291354f1e839c252ec6c0611e86e2e"},
|
||||
{file = "mypy-1.10.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:4cf18f9d0efa1b16478c4c129eabec36148032575391095f73cae2e722fcf9d5"},
|
||||
{file = "mypy-1.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:bc6ac273b23c6b82da3bb25f4136c4fd42665f17f2cd850771cb600bdd2ebeda"},
|
||||
{file = "mypy-1.10.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:9fd50226364cd2737351c79807775136b0abe084433b55b2e29181a4c3c878c0"},
|
||||
{file = "mypy-1.10.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f90cff89eea89273727d8783fef5d4a934be2fdca11b47def50cf5d311aff727"},
|
||||
{file = "mypy-1.10.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fcfc70599efde5c67862a07a1aaf50e55bce629ace26bb19dc17cece5dd31ca4"},
|
||||
{file = "mypy-1.10.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:075cbf81f3e134eadaf247de187bd604748171d6b79736fa9b6c9685b4083061"},
|
||||
{file = "mypy-1.10.0-cp38-cp38-win_amd64.whl", hash = "sha256:3f298531bca95ff615b6e9f2fc0333aae27fa48052903a0ac90215021cdcfa4f"},
|
||||
{file = "mypy-1.10.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:fa7ef5244615a2523b56c034becde4e9e3f9b034854c93639adb667ec9ec2976"},
|
||||
{file = "mypy-1.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3236a4c8f535a0631f85f5fcdffba71c7feeef76a6002fcba7c1a8e57c8be1ec"},
|
||||
{file = "mypy-1.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a2b5cdbb5dd35aa08ea9114436e0d79aceb2f38e32c21684dcf8e24e1e92821"},
|
||||
{file = "mypy-1.10.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:92f93b21c0fe73dc00abf91022234c79d793318b8a96faac147cd579c1671746"},
|
||||
{file = "mypy-1.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:28d0e038361b45f099cc086d9dd99c15ff14d0188f44ac883010e172ce86c38a"},
|
||||
{file = "mypy-1.10.0-py3-none-any.whl", hash = "sha256:f8c083976eb530019175aabadb60921e73b4f45736760826aa1689dda8208aee"},
|
||||
{file = "mypy-1.10.0.tar.gz", hash = "sha256:3d087fcbec056c4ee34974da493a826ce316947485cef3901f511848e687c131"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
mypy-extensions = ">=1.0.0"
|
||||
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
|
||||
typing-extensions = ">=4.1.0"
|
||||
|
||||
[package.extras]
|
||||
dmypy = ["psutil (>=4.0)"]
|
||||
install-types = ["pip"]
|
||||
mypyc = ["setuptools (>=50)"]
|
||||
reports = ["lxml"]
|
||||
|
||||
[[package]]
|
||||
name = "mypy-extensions"
|
||||
version = "1.0.0"
|
||||
description = "Type system extensions for programs checked with the mypy type checker."
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
files = [
|
||||
{file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"},
|
||||
{file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pygame"
|
||||
version = "2.5.2"
|
||||
@ -170,6 +228,17 @@ files = [
|
||||
{file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
version = "2.0.1"
|
||||
description = "A lil' TOML parser"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typer"
|
||||
version = "0.12.3"
|
||||
@ -200,5 +269,5 @@ files = [
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "62a9e20d34820e32f43e8980e200ee7607f2a717ef39bdc9cd89000777e450ab"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "3c9932786e451777390c0b0404c9ce69654c53f093769a524fa097965fd07808"
|
||||
|
@ -9,6 +9,7 @@ readme = "README.md"
|
||||
python = "^3.10"
|
||||
pygame = "^2.5.2"
|
||||
typer = "^0.12.3"
|
||||
mypy = "^1.10.0"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
@ -1,4 +1,14 @@
|
||||
import abc
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
# this is needed because of circular references
|
||||
if TYPE_CHECKING:
|
||||
from .colors import Color
|
||||
from .doodles import Doodle
|
||||
from .shapes import Rectangle, Circle
|
||||
from .lines import Line
|
||||
from .text import Text
|
||||
|
||||
|
||||
|
||||
class DrawEngine(abc.ABC):
|
||||
@ -48,7 +58,7 @@ class DrawEngine(abc.ABC):
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def rect_draw(self, rect: "Rect"):
|
||||
def rect_draw(self, rect: "Rectangle"):
|
||||
"""
|
||||
Method to draw a Rectangle obj.
|
||||
"""
|
||||
|
@ -1,5 +1,4 @@
|
||||
from doodles import Rectangle, Color, world
|
||||
import random
|
||||
from doodles import Rectangle, Color
|
||||
|
||||
def create():
|
||||
for _ in range(25):
|
||||
@ -7,6 +6,3 @@ def create():
|
||||
Rectangle().random(150).color(Color.DARK_BLUE).z(15)
|
||||
Rectangle().random(100).color(Color.DARK_GREY).z(20)
|
||||
Rectangle().random(50).color(Color.LIGHT_GREY).z(30)
|
||||
# Rectangle().random(250).color(
|
||||
# random.choice((Color.BLACK, Color.LIGHT_GREY, Color.DARK_GREY, Color.WHITE))
|
||||
# )
|
||||
|
@ -8,4 +8,4 @@ def tri():
|
||||
return g
|
||||
|
||||
def create():
|
||||
r = tri().move(200, 200)
|
||||
tri().move(200, 200)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import random
|
||||
import itertools
|
||||
from doodles import Group, Circle, Color, Text
|
||||
from doodles import Color, Text
|
||||
|
||||
# Via ChatGPT
|
||||
hello_world = [
|
||||
|
@ -17,7 +17,7 @@ class Circle(Doodle):
|
||||
self._radius = 0
|
||||
|
||||
def __repr__(self):
|
||||
return f"Circle(pos={self.world_vec}, radius={self._radius}, {self._color}, parent={self._parent}))"
|
||||
return f"Circle(pos={self.world_vec}, radius={self._radius}, {self._color})"
|
||||
|
||||
def draw(self):
|
||||
# TODO: do we need to override draw? can we move this to Doodle.draw
|
||||
@ -57,7 +57,7 @@ class Rectangle(Doodle):
|
||||
self._height = 100
|
||||
|
||||
def __repr__(self):
|
||||
return f"Rect(pos={self.world_vec}, width={self._width}, height={self._height}, parent={self._parent})"
|
||||
return f"Rect(pos={self.world_vec}, width={self._width}, height={self._height})"
|
||||
|
||||
def draw(self):
|
||||
world.draw_engine.rect_draw(self)
|
||||
|
@ -16,7 +16,6 @@ some expensive logic.
|
||||
|
||||
Look at _render() for more.
|
||||
"""
|
||||
import pygame
|
||||
from .doodles import Doodle
|
||||
from .world import world
|
||||
|
||||
|
@ -4,10 +4,17 @@ This is the most complex/implementation specific module.
|
||||
TODO: this should be split into two modules once there
|
||||
is a non-Pygame implementation.
|
||||
"""
|
||||
from .color import Color
|
||||
from typing import TYPE_CHECKING
|
||||
import pygame
|
||||
from .color import Color
|
||||
from .draw_engine import DrawEngine
|
||||
|
||||
# this is needed because of circular references
|
||||
if TYPE_CHECKING:
|
||||
from .doodles import Doodle
|
||||
from .shapes import Rectangle, Circle
|
||||
from .lines import Line
|
||||
from .text import Text
|
||||
|
||||
class PygameDrawEngine(DrawEngine):
|
||||
# Having each bit of text on the screen load a separate copy
|
||||
@ -82,7 +89,8 @@ class PygameDrawEngine(DrawEngine):
|
||||
def line_draw(self, ll: "Line"):
|
||||
pygame.draw.aaline(self.buffer, ll.rgba, ll.world_vec, ll.end_vec)
|
||||
|
||||
def text_render(self, text: str, font: str, color: Color) -> "TODO":
|
||||
# TODO: return type?
|
||||
def text_render(self, text: str, font: str, color: Color):
|
||||
"""returns an intermediated RenderedText"""
|
||||
return font.render(text, True, color)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user