Skip to content

Commit 1a24ed1

Browse files
committed
Typing fixes, backends package is excluded from typing for now
1 parent 62cf4ae commit 1a24ed1

7 files changed

Lines changed: 33 additions & 7 deletions

File tree

arcade/gl/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def texture(
859859
filter=None,
860860
samples: int = 0,
861861
immutable: bool = False,
862-
internal_format,
862+
internal_format=None,
863863
compressed: bool = False,
864864
compressed_data: bool = False,
865865
) -> Texture2D:

arcade/gl/provider.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
if TYPE_CHECKING:
88
from arcade.context import ArcadeContext
99

10-
from .context import Context
10+
from .context import Context, Info
1111

1212
_current_provider: Optional[BaseProvider] = None
1313

@@ -31,13 +31,17 @@ def get_context(*args, **kwargs) -> Context:
3131
if _current_provider is None:
3232
set_provider("opengl")
3333

34+
assert _current_provider is not None # this can't really be None at this point, but mypy
35+
3436
return _current_provider.create_context(*args, **kwargs)
3537

3638

3739
def get_arcade_context(*args, **kwargs) -> ArcadeContext:
3840
if _current_provider is None:
3941
set_provider("opengl")
4042

43+
assert _current_provider is not None # this can't really be None at this point, but mypy
44+
4145
return _current_provider.create_arcade_context(*args, **kwargs)
4246

4347

@@ -47,7 +51,7 @@ def create_context(self, *args, **kwargs) -> Context:
4751
pass
4852

4953
@abstractmethod
50-
def create_info(self, ctx: Context):
54+
def create_info(self, ctx: Context) -> Info:
5155
pass
5256

5357
@abstractmethod

arcade/gl/sampler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def __init__(
3030
# We're creating them here first to trick some of the methods on the
3131
# base class to being able to see them. So that we don't have to
3232
# implement a getter on every backend
33-
self._filter = None
34-
self._wrap_x = None
35-
self._wrap_y = None
33+
self._filter = (0, 0) # Mypy needs this to be a tuple[int, int] to be happy
34+
self._wrap_x = 0 # Mypy needs this to be an int to be happy
35+
self._wrap_y = 0 # Mypy needs this to be an int to be happy
3636

3737
self.texture = texture
3838

arcade/gl/texture.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ def __init__(
132132
self._compressed = compressed
133133
self._compressed_data = compressed_data
134134

135+
# _filter ultimately need to be set by the implementing backend.
136+
# We're creating it here first to trick some of the methods on the
137+
# base class to being able to see it. So that we don't have to
138+
# implement a getter on every backend
139+
self._filter = (0, 0) # Mypy needs this to be a tuple[int, int] to be happy
140+
135141
self._wrap_x = enums.REPEAT
136142
self._wrap_y = enums.REPEAT
137143

arcade/gl/texture_array.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ def __init__(
133133
self._compressed = compressed
134134
self._compressed_data = compressed_data
135135

136+
# These three ultimately need to be set by the implementing backend.
137+
# We're creating them here first to trick some of the methods on the
138+
# base class to being able to see them. So that we don't have to
139+
# implement a getter on every backend
140+
self._filter = (0, 0) # Mypy needs this to be a tuple[int, int] to be happy
141+
self._wrap_x = 0 # Mypy needs this to be an int to be happy
142+
self._wrap_y = 0 # Mypy needs this to be an int to be happy
143+
136144
if self._components not in [1, 2, 3, 4]:
137145
raise ValueError("Components must be 1, 2, 3 or 4")
138146

arcade/management/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ def show_info():
2828
print("-" * len(version_str))
2929
print("vendor:", window.ctx.info.VENDOR)
3030
print("renderer:", window.ctx.info.RENDERER)
31-
print("version:", window.ctx.gl_version)
31+
# TODO: Abstracted GL backend
32+
# The context doesn't necessarily have this, this will need changed later
33+
# Probably the context needs to provide an info function that will spit back relevent stuff
34+
# rather than hardcoding the things we want here
35+
print("version:", window.ctx.gl_version) # type: ignore
3236
print("python:", sys.version)
3337
print("platform:", sys.platform)
3438
print("pyglet version:", pyglet.version)

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ exclude = ["arcade/examples/*", "benchmarks/*"]
125125

126126
[tool.mypy]
127127
disable_error_code = "annotation-unchecked"
128+
exclude = [
129+
"arcade/gl/backends"
130+
]
128131

129132
[tool.pytest.ini_options]
130133
norecursedirs = [
@@ -149,6 +152,7 @@ exclude = [
149152
"arcade/__pyinstaller",
150153
"arcade/examples",
151154
"arcade/experimental",
155+
"arcade/gl/backends",
152156
"tests",
153157
"doc",
154158
"make.py",

0 commit comments

Comments
 (0)