resolve "cannot find reference"

I'm getting an inspection error: "Cannot find reference 'setLineWidth' in 'canvas.py'"

However I can plainly see that this file is in External Libraries.  Inspection doesn't complain about the import statements or the initialization of Canvas.  I can also plainly see in the source that there truely is a setLineWidth method declared in Canvas.

    from reportlab.lib.pagesizes import letter
    from reportlab.pdfgen import canvas

    canvas = canvas.Canvas("form.pdf", pagesize=letter)
    canvas.setLineWidth(.3)

This is a screen shot form the External Libraries tree:

reportlab_screenshot.png


Does anyone know how I can get inspection to see this source code?
2 comments
Comment actions Permalink
Hi Jeremy,

This inspection tells that it cannot find setLineWidth class or method directly in canvas.py. That is because you have the same name for your variable as your import name. In case you will change this name:
    canvas1 = canvas.Canvas("form.pdf", pagesize=letter)
    canvas1.setLineWidth(.3)
the method will be searched in canvas.Canvas so you will not see this inspection.
0
Comment actions Permalink
That was the problem.  My bad! Thank you very much!
0

Please sign in to leave a comment.