Skip to content

Commit

Permalink
fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
flopp committed Apr 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c92512b commit c0bf850
Showing 9 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions examples/custom_objects.py
Original file line number Diff line number Diff line change
@@ -157,8 +157,8 @@ def render_svg(self, renderer: staticmaps.SvgRenderer) -> None:

# render png via cairo
if staticmaps.cairo_is_supported():
image = context.render_cairo(800, 500)
image.write_to_png("custom_objects.cairo.png")
cairo_image = context.render_cairo(800, 500)
cairo_image.write_to_png("custom_objects.cairo.png")

# render svg
svg_image = context.render_svg(800, 500)
4 changes: 2 additions & 2 deletions examples/draw_gpx.py
Original file line number Diff line number Diff line change
@@ -32,8 +32,8 @@

# render png via cairo
if staticmaps.cairo_is_supported():
image = context.render_cairo(800, 500)
image.write_to_png("running.cairo.png")
cairo_image = context.render_cairo(800, 500)
cairo_image.write_to_png("running.cairo.png")

# render svg
svg_image = context.render_svg(800, 500)
4 changes: 2 additions & 2 deletions examples/frankfurt_newyork.py
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@

# render png via cairo
if staticmaps.cairo_is_supported():
image = context.render_cairo(800, 500)
image.write_to_png("frankfurt_newyork.cairo.png")
cairo_image = context.render_cairo(800, 500)
cairo_image.write_to_png("frankfurt_newyork.cairo.png")

# render svg
svg_image = context.render_svg(800, 500)
4 changes: 2 additions & 2 deletions examples/freiburg_area.py
Original file line number Diff line number Diff line change
@@ -450,8 +450,8 @@

# render png via cairo
if staticmaps.cairo_is_supported():
image = context.render_cairo(800, 500)
image.write_to_png("freiburg_area.cairo.png")
cairo_image = context.render_cairo(800, 500)
cairo_image.write_to_png("freiburg_area.cairo.png")

# render svg
svg_image = context.render_svg(800, 500)
4 changes: 2 additions & 2 deletions examples/geodesic_circles.py
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@

# render png via cairo
if staticmaps.cairo_is_supported():
image = context.render_cairo(800, 600)
image.write_to_png("geodesic_circles.cairo.png")
cairo_image = context.render_cairo(800, 600)
cairo_image.write_to_png("geodesic_circles.cairo.png")

# render svg
svg_image = context.render_svg(800, 600)
4 changes: 2 additions & 2 deletions examples/tile_providers.py
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@

# render png via cairo
if staticmaps.cairo_is_supported():
image = context.render_cairo(800, 500)
image.write_to_png(f"provider_{name}.cairo.png")
cairo_image = context.render_cairo(800, 500)
cairo_image.write_to_png(f"provider_{name}.cairo.png")

# render svg
svg_image = context.render_svg(800, 500)
4 changes: 2 additions & 2 deletions examples/us_capitals.py
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@

# render png via cairo
if staticmaps.cairo_is_supported():
image = context.render_cairo(800, 500)
image.write_to_png("us_capitals.cairo.png")
cairo_image = context.render_cairo(800, 500)
cairo_image.write_to_png("us_capitals.cairo.png")

# render svg
svg_image = context.render_svg(800, 500)
2 changes: 1 addition & 1 deletion staticmaps/context.py
Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ def render_cairo(self, width: int, height: int) -> typing.Any:

return renderer.image_surface()

def render_pillow(self, width: int, height: int) -> PIL_Image:
def render_pillow(self, width: int, height: int) -> PIL_Image.Image:
"""Render context using PILLOW
:param width: width of static map
6 changes: 3 additions & 3 deletions staticmaps/pillow_renderer.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def __init__(self, transformer: Transformer) -> None:
self._draw = PIL_ImageDraw.Draw(self._image)
self._offset_x = 0

def draw(self) -> PIL_ImageDraw.Draw:
def draw(self) -> PIL_ImageDraw.ImageDraw:
return self._draw

def image(self) -> PIL_Image.Image:
@@ -99,7 +99,7 @@ def render_attribution(self, attribution: typing.Optional[str]) -> None:
margin = 2
w = self._trans.image_width()
h = self._trans.image_height()
left, top, right, bottom = self.draw().textbbox((margin, h - margin), attribution)
_, top, _, bottom = self.draw().textbbox((margin, h - margin), attribution)
th = bottom - top
overlay = PIL_Image.new("RGBA", self._image.size, (255, 255, 255, 0))
draw = PIL_ImageDraw.Draw(overlay)
@@ -128,7 +128,7 @@ def fetch_tile(
return PIL_Image.open(io.BytesIO(image_data))

@staticmethod
def create_image(image_data: bytes) -> PIL_Image:
def create_image(image_data: bytes) -> PIL_Image.Image:
"""Create a pillow image
:param image_data: Image data

0 comments on commit c0bf850

Please sign in to comment.