Intellisense for OGR

Feb 6 at 10:13 AM
Hi,

I am using gdal/ogr libraries but couldn't make the intellisense and auto-completion to work much deeper. Actually, it works on the first stage like creating an object, but no more intellisense when using that object to access its methods/properties. Example:
from osgeo import ogr
driver = ogr.GetDriverByName('ESRI Shapefile')
dataSource = driver.
Many thanks!
Coordinator
Feb 6 at 4:17 PM
This looks like a bug, since ogr has enough information that we should be able to figure this out. I'll file an issue.

As a workaround, if you add assert isinstance(driver, ogr.Driver) immediately after the assignment then we will be able to give you full completions.
Coordinator
Feb 6 at 4:21 PM
If you don't like the idea of having your program assert here, then you can use one of the following styles (which we still understand, but the assert will never be raised while you are running):
if False:
    assert isinstance(driver, ogr.Driver)
assert True or isinstance(driver, ogr.Driver)
Or you can make a helper function if you are calling this a lot:
def GetDriverByName(*args):
    from osgeo import ogr
    driver = ogr.GetDriverByName(*args)
    if False:
        assert isinstance(driver, ogr.Driver)
    return driver
Coordinator
Feb 6 at 4:25 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.