Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ exclude = [
"module/build/",
]

ignore = [
"renpycoverage.py"
]

reportOptionalSubscript = false
reportOptionalMemberAccess = false
reportOptionalCall = false
reportOptionalIterable = false
reportOptionalContextManager = false
reportOptionalOperand = false
reportMissingModuleSource = false
3 changes: 2 additions & 1 deletion renpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# order.

from __future__ import division, absolute_import, with_statement, print_function, unicode_literals
from typing import Any

# All imports should go below renpy.compat.

Expand Down Expand Up @@ -660,7 +661,7 @@ def reload_all():
renpy.loader.init_importer()

if 1 == 0:
from . import defaultstore as store; store
store = None # type: Any

# Generated by scripts/relative_imports.py, do not edit below this line.
if 1 == 0:
Expand Down
3 changes: 2 additions & 1 deletion renpy/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def compat_open(*args, **kwargs):
unicode = future.utils.text_type # @ReservedAssignment

bord = future.utils.bord
bchr = future.utils.bchr
def bchr(i): # types: (int) -> bytes
return bytes([i])
tobytes = future.utils.tobytes

from future.builtins import chr
Expand Down
52 changes: 31 additions & 21 deletions renpy/display/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ class Displayable(renpy.object.Object):
# Does this displayable have a tooltip?
_tooltip = None

# Used by a transition (or transition-like object) to determine how long to
# delay for.
delay = None # type: float|None

def __ne__(self, o):
return not (self == o)

Expand Down Expand Up @@ -844,7 +848,7 @@ def after_upgrade(self, version):
self.drag_group = None

if version < 6:
self.shown = self.image_predict_info
self.shown = self.image_predict_info # type: ignore

if version < 7:
self.layer_transform = { }
Expand Down Expand Up @@ -1649,8 +1653,8 @@ def get_safe_mode():

VK_SHIFT = 0x10

ctypes.windll.user32.GetKeyState.restype = ctypes.c_ushort
if ctypes.windll.user32.GetKeyState(VK_SHIFT) & 0x8000:
ctypes.windll.user32.GetKeyState.restype = ctypes.c_ushort # type: ignore
if ctypes.windll.user32.GetKeyState(VK_SHIFT) & 0x8000: # type: ignore
return True
else:
return False
Expand Down Expand Up @@ -1680,6 +1684,8 @@ class Renderer(object):
- "models", true if model-based rendering is being used.
"""

texture_cache = { }

def get_texture_size(self):
"""
This returns a pair contining the total amount of memory consumed by
Expand Down Expand Up @@ -1825,22 +1831,30 @@ def translate_point(self, x, y):
Translates (`x`, `y`) from physical to virtual coordinates.
"""

return (0, 0) # type

def untranslate_point(self, x, y):
"""
Untranslates (`x`, `y`) from virtual to physical coordinates.
"""

return (0, 0) # type

def mouse_event(self, ev):
"""
This translates the .pos field of `ev` from physical coordinates to
virtual coordinates. Returns an (x, y) pait of virtual coordinates.
"""

return ev

def get_mouse_pos(self):
"""
Returns the x and y coordinates of the mouse, in virtual coordinates.
"""

return (0, 0) # type

def set_mouse_pos(self, x, y):
"""
Moves the mouse to the virtual coordinates `x` and `y`.
Expand Down Expand Up @@ -2103,7 +2117,7 @@ def __init__(self):
self.frame_duration = 1.0 / 60.0

# The cursor cache.
self.cursor_cache = None
self.cursor_cache = None # type: dict|None

# The old mouse.
self.old_mouse = None
Expand Down Expand Up @@ -2152,16 +2166,16 @@ def setup_dpi_scaling(self):
import ctypes
from ctypes import c_void_p, c_int

ctypes.windll.user32.SetProcessDPIAware()
ctypes.windll.user32.SetProcessDPIAware() # type: ignore

GetDC = ctypes.windll.user32.GetDC
GetDC = ctypes.windll.user32.GetDC # type: ignore
GetDC.restype = c_void_p
GetDC.argtypes = [ c_void_p ]

ReleaseDC = ctypes.windll.user32.ReleaseDC
ReleaseDC = ctypes.windll.user32.ReleaseDC # type: ignore
ReleaseDC.argtypes = [ c_void_p, c_void_p ]

GetDeviceCaps = ctypes.windll.gdi32.GetDeviceCaps
GetDeviceCaps = ctypes.windll.gdi32.GetDeviceCaps # type: ignore
GetDeviceCaps.restype = c_int
GetDeviceCaps.argtypes = [ c_void_p, c_int ]

Expand Down Expand Up @@ -2547,7 +2561,7 @@ def set_mode(self):
raise Exception("Could not set video mode.")

renpy.session["renderer"] = draw.info["renderer"]
renpy.game.persistent._gl2 = renpy.config.gl2
renpy.game.persistent._gl2 = renpy.config.gl2

if renpy.android:
android.init()
Expand Down Expand Up @@ -2730,14 +2744,13 @@ def show_window(self):
old_history = renpy.store._history # @UndefinedVariable
renpy.store._history = False

PPP("empty window")
PPP("empty window") # type: ignore

try:
old_say_attributes = renpy.game.context().say_attributes
old_temporary_attributes = renpy.game.context().temporary_attributes

old_say_attributes = renpy.game.context().say_attributes
try:
renpy.game.context().say_attributes = None

old_temporary_attributes = renpy.game.context().temporary_attributes
renpy.game.context().temporary_attributes = None

renpy.config.empty_window()
Expand Down Expand Up @@ -2769,7 +2782,7 @@ def with_none(self, overlay=True):
be transitioning from.
"""

PPP("start of with none")
PPP("start of with none") # type: ignore

# Show the window, if that's necessary.
self.show_window()
Expand Down Expand Up @@ -3027,7 +3040,7 @@ def is_mouse_visible(self):

def get_mouse_name(self, cache_only=False, interaction=True):

mouse_kind = renpy.display.focus.get_mouse()
mouse_kind = renpy.display.focus.get_mouse() # type: str

if interaction and (mouse_kind is None):
mouse_kind = self.mouse
Expand Down Expand Up @@ -3293,9 +3306,6 @@ def interact(self, clear=True, suppress_window=False, trans_pause=False, pause=N

self.trans_pause = trans_pause

# Cancel magic error reporting.
renpy.bootstrap.report_error = None

context = renpy.game.context()

if context.interacting:
Expand Down Expand Up @@ -3326,7 +3336,7 @@ def interact(self, clear=True, suppress_window=False, trans_pause=False, pause=N
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
self.start_interact = False

return rv
return rv # type: ignore

finally:

Expand Down Expand Up @@ -3695,7 +3705,7 @@ def add_layer(where, layer):
root_widget.add(sb)
focus_roots.append(sb)

pb = renpy.display.behavior.PauseBehavior(trans.delay)
pb = renpy.display.behavior.PauseBehavior(trans.delay) # type: ignore
root_widget.add(pb, transition_time, transition_time)
focus_roots.append(pb)

Expand Down
32 changes: 17 additions & 15 deletions renpy/display/dragdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __init__(self,
self.target_at_delay = 0

# The displayable we were last dropping on.
self.last_drop = None
self.last_drop = None # type: renpy.display.core.Displayable|None

# Did we move over the course of this drag?
self.drag_moved = False
Expand Down Expand Up @@ -519,8 +519,8 @@ def render(self, width, height, st, at):
else:
# Snap in progress
done = (at - self.at) / (self.target_at - self.at)
self.x = absolute(self.x + done * (self.target_x - self.x))
self.y = absolute(self.y + done * (self.target_y - self.y))
self.x = absolute(self.x + done * (self.target_x - self.x)) # type: ignore
self.y = absolute(self.y + done * (self.target_y - self.y)) # type: ignore
redraw(self, 0)

if self.draggable or self.clicked is not None:
Expand Down Expand Up @@ -582,14 +582,16 @@ def event(self, ev, x, y, st):
self.click_time = st
renpy.game.interface.timeout(renpy.config.longpress_duration)

joined = [ ] # typing

if grabbed:
joined_offsets = self.drag_joined(self)
joined = [ i[0] for i in joined_offsets ]
joined = [ i[0] for i in joined_offsets ] # type: list[Drag]

elif self.draggable and map_event(ev, "drag_activate"):

joined_offsets = self.drag_joined(self)
joined = [ i[0] for i in joined_offsets ]
joined = [ i[0] for i in joined_offsets ] # type: list[Drag]

if not joined:
raise renpy.display.core.IgnoreEvent()
Expand Down Expand Up @@ -662,13 +664,13 @@ def event(self, ev, x, y, st):

# Raise the joined items.
if self.drag_raise and self.drag_group is not None:
self.drag_group.raise_children(joined)
self.drag_group.raise_children(joined) # type: ignore

if self.drag_moved:
for i, xo, yo in joined_offsets:
for i, xo, yo in joined_offsets: # type: ignore

new_x = int(par_x - self.grab_x + xo)
new_y = int(par_y - self.grab_y + yo)
new_x = int(par_x - self.grab_x + xo) # type: ignore
new_y = int(par_y - self.grab_y + yo) # type: ignore

if not self.drag_offscreen:
new_x = max(new_x, 0)
Expand All @@ -691,9 +693,9 @@ def event(self, ev, x, y, st):

if (self.drag_group is not None) and self.drag_moved:
if self.mouse_drop:
drop = self.drag_group.get_drop_at(joined, par_x, par_y)
drop = self.drag_group.get_drop_at(joined, par_x, par_y) # type: ignore
else:
drop = self.drag_group.get_best_drop(joined)
drop = self.drag_group.get_best_drop(joined) # type: ignore
else:
drop = None

Expand All @@ -702,7 +704,7 @@ def event(self, ev, x, y, st):
if self.last_drop is not None:
self.last_drop.set_style_prefix("idle_", True)

self.last_drop = drop
self.last_drop = drop # type: ignore

if self.drag_moved:
self.update_style_prefix()
Expand All @@ -714,7 +716,7 @@ def event(self, ev, x, y, st):
renpy.display.focus.set_grab(None)

if drop is not None:
drop.set_style_prefix("idle_", True)
drop.set_style_prefix("idle_", True) # type: ignore

for i in joined:
i.set_style_prefix("idle_", True)
Expand All @@ -735,8 +737,8 @@ def event(self, ev, x, y, st):
return rv

# Call the drop callback.
if drop is not None and drop.dropped is not None:
rv = run(drop.dropped, drop, joined)
if drop is not None and drop.dropped is not None: # type: ignore
rv = run(drop.dropped, drop, joined) # type: ignore
if rv is not None:
return rv

Expand Down
Loading