Skip to content

Commit

Permalink
shapes: minor docstring/typing fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
benmoran56 committed May 9, 2024
1 parent 6e2bf55 commit 0d6fee7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
26 changes: 14 additions & 12 deletions pyglet/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def on_draw():
import math

from abc import ABC, abstractmethod
from typing import Sequence
from typing import Sequence, TYPE_CHECKING

import pyglet

Expand All @@ -77,6 +77,10 @@ def on_draw():
from pyglet.graphics import Batch, Group
from pyglet.math import Vec2

if TYPE_CHECKING:
from pyglet.graphics.shader import ShaderProgram


vertex_source = """#version 150 core
in vec2 position;
in vec2 translation;
Expand Down Expand Up @@ -120,7 +124,7 @@ def on_draw():
"""


def get_default_shader():
def get_default_shader() -> ShaderProgram:
return pyglet.gl.current_context.create_program((vertex_source, 'vertex'),
(fragment_source, 'fragment'))

Expand Down Expand Up @@ -225,22 +229,20 @@ class _ShapeGroup(Group):
sharing the same parent group and blend parameters.
"""

def __init__(self, blend_src, blend_dest, program, parent=None):
def __init__(self, blend_src: int, blend_dest: int, program: ShaderProgram, parent: Group | None = None):
"""Create a Shape group.
The group is created internally. Usually you do not
need to explicitly create it.
:Parameters:
`blend_src` : int
OpenGL blend source mode; for example,
``GL_SRC_ALPHA``.
`blend_dest` : int
OpenGL blend destination mode; for example,
``GL_ONE_MINUS_SRC_ALPHA``.
`program` : `~pyglet.graphics.shader.ShaderProgram`
Args:
blend_src:
OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
blend_dest:
OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
program:
The ShaderProgram to use.
`parent` : `~pyglet.graphics.Group`
parent:
Optional parent group.
"""
super().__init__(parent=parent)
Expand Down
5 changes: 2 additions & 3 deletions pyglet/sprite.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def on_draw():

import sys

from typing import TYPE_CHECKING, List, Tuple
from typing import TYPE_CHECKING

import pyglet

Expand All @@ -81,8 +81,7 @@ def on_draw():
_is_pyglet_doc_run = hasattr(sys, "is_pyglet_doc_run") and sys.is_pyglet_doc_run

if TYPE_CHECKING:
from pyglet.image import AbstractImage, Texture
from pyglet.image.animation import Animation
from pyglet.image import AbstractImage, Texture, Animation
from pyglet.graphics import Batch, Group
from pyglet.graphics.shader import ShaderProgram

Expand Down

0 comments on commit 0d6fee7

Please sign in to comment.