Distrotech / reportlab

Mirror of https://bitbucket.org/rptlab/reportlab
Other
59 stars 42 forks source link

Rest of the code is marked as unreachable, even though it isn't #24

Closed emircetinmemis closed 1 year ago

emircetinmemis commented 1 year ago

Machine

Python 3.9.13 reportlab 3.6.12

Expected Behaviour

Rest of the code should not be marked as unreachable.

Current Behaviour

Rest of the code after call being marked as unreachable.

Code snippet used

from svglib.svglib import svg2rlg
from reportlab.graphics import renderPM

print("LINE 4")

drawing = svg2rlg("index.svg")
renderPM.drawToFile(drawing, "temp.png", fmt="PNG", dpi=250)

print("LINE 9")

Example of Situation

Capture

emircetinmemis commented 1 year ago

Good news

I've solve the issue, while searching out some similar problems i seen this closed issue. https://github.com/microsoft/pylance-release/issues/473#issuecomment-706764012

Solution Approach

To solve it I have went down into "renderPM.py", and it line "63" I have add an annotation to the @draw method, which was creating the problem.

Before and After

# the main entry point for users...
def draw(drawing, canvas, x, y, showBoundary=rl_config._unset_):
    """As it says"""
    R = _PMRenderer()
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
# the main entry point for users...
def draw(drawing, canvas, x, y, showBoundary=rl_config._unset_) -> None:
    """As it says"""
    R = _PMRenderer()
    R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)