Skip to content

Commit

Permalink
Python code: Disable more Pylint warnings (OSGeo#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
bje- authored and rouault committed May 7, 2018
1 parent e396255 commit 2d8f023
Show file tree
Hide file tree
Showing 28 changed files with 43 additions and 35 deletions.
1 change: 1 addition & 0 deletions autotest/gcore/rasterio.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def rasterio_7():


def rasterio_8_progress_callback(pct, message, user_data):
# pylint: disable=unused-argument
if abs(pct - (user_data[0] + 0.05)) > 1e-5:
print('Expected %f, got %f' % (user_data[0] + 0.05, pct))
user_data[1] = False
Expand Down
3 changes: 2 additions & 1 deletion autotest/gcore/vsiaz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,8 @@ def vsiaz_extra_1():
print(ret)
return 'fail'

if False: # we actually try to read at read() time and bSetError = false
if False: # pylint: disable=using-constant-test
# we actually try to read at read() time and bSetError = false
# Invalid bucket : "The specified bucket does not exist"
gdal.ErrorReset()
f = open_for_read('/vsiaz/not_existing_bucket/foo')
Expand Down
3 changes: 2 additions & 1 deletion autotest/gcore/vsigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,8 @@ def vsigs_extra_1():
print(ret)
return 'fail'

if False: # we actually try to read at read() time and bSetError = false
if False: # pylint: disable=using-constant-test
# we actually try to read at read() time and bSetError = false
# Invalid bucket : "The specified bucket does not exist"
gdal.ErrorReset()
f = open_for_read('/vsigs/not_existing_bucket/foo')
Expand Down
3 changes: 2 additions & 1 deletion autotest/gcore/vsioss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,8 @@ def visoss_extra_1():
print(ret)
return 'fail'

if False: # we actually try to read at read() time and bSetError = false:
if False: # pylint: disable=using-constant-test
# we actually try to read at read() time and bSetError = false:
# Invalid bucket : "The specified bucket does not exist"
gdal.ErrorReset()
f = open_for_read('/vsioss/not_existing_bucket/foo')
Expand Down
3 changes: 2 additions & 1 deletion autotest/gcore/vsis3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,8 @@ def vsis3_extra_1():
print(ret)
return 'fail'

if False: # we actually try to read at read() time and bSetError = false
if False: # pylint: disable=using-constant-test
# we actually try to read at read() time and bSetError = false
# Invalid bucket : "The specified bucket does not exist"
gdal.ErrorReset()
f = open_for_read('/vsis3/not_existing_bucket/foo')
Expand Down
4 changes: 2 additions & 2 deletions autotest/gdrivers/jp2lura.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ def jp2lura_22():
gdaltest.post_reason('Image too different from reference')
return 'fail'

if False:
if False: # pylint: disable=using-constant-test
# RGBA with 1BIT_ALPHA=YES
src_ds = gdal.Open('../gcore/data/stefan_full_rgba.tif')
out_ds = gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_22.jp2', src_ds, options=['1BIT_ALPHA=YES'])
Expand Down Expand Up @@ -1036,7 +1036,7 @@ def jp2lura_24():
gdaltest.post_reason('Image too different from reference')
return 'fail'

if False:
if False: # pylint: disable=using-constant-test
# Grey+alpha with 1BIT_ALPHA=YES
src_ds = gdal.Open('../gcore/data/stefan_full_greyalpha.tif')
gdaltest.jp2lura_drv.CreateCopy('/vsimem/jp2lura_24.jp2', src_ds, options=['1BIT_ALPHA=YES'])
Expand Down
2 changes: 1 addition & 1 deletion autotest/gdrivers/kea.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def kea_4():

# Disabled for now since some of them cause memory leaks or
# crash in the HDF5 library finalizer
if False:
if False: # pylint: disable=using-constant-test
gdal.PushErrorHandler('CPLQuietErrorHandler')
ret = ds.SetMetadataItem('foo', 'bar')
gdal.PopErrorHandler()
Expand Down
1 change: 1 addition & 0 deletions autotest/gdrivers/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def netcdf_setup():


def netcdf_test_copy(ifile, band, checksum, ofile, opts=None, driver='NETCDF'):
# pylint: disable=unused-argument
opts = [] if opts is None else opts
test = gdaltest.GDALTest('NETCDF', '../' + ifile, band, checksum, options=opts)
return test.testCreateCopy(check_gt=0, check_srs=0, new_filename=ofile, delete_copy=0, check_minmax=0)
Expand Down
4 changes: 1 addition & 3 deletions autotest/gdrivers/netcdf_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ def netcdf_cf_get_command(ifile, version='auto'):
###############################################################################
# Check a file for CF compliance
def netcdf_cf_check_file(ifile, version='auto', silent=True):

# if not silent:
# print 'checking file ' + ifile
# pylint: disable=unused-argument
gdaltest.netcdf_cf_check_error = ''

if not os.path.exists(ifile):
Expand Down
2 changes: 1 addition & 1 deletion autotest/gdrivers/ozi.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def ozi_online_1():
if ds is None:
return 'fail'

if False:
if False: # pylint: disable=using-constant-test
gt = ds.GetGeoTransform()
wkt = ds.GetProjectionRef()

Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def ogr_basic_12():
return 'fail'
feat_def.AddFieldDefn(field_def)

if False:
if False: # pylint: disable=using-constant-test
f = ogr.Feature(feat_def)
gdal.ErrorReset()
f.SetField('fld', '1.23')
Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def ogr_csv_3():
gdaltest.csv_lyr1 = ogr_csv_copy_layer('pm1', None)

# No longer valid since we have editing capabilities
if False:
if False: # pylint: disable=using-constant-test
# Check that we cannot add a new field now
if gdaltest.csv_lyr1.TestCapability(ogr.OLCCreateField) != 0:
gdaltest.post_reason('fail')
Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_fgdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def ogr_fgdb_DeleteField():
return 'fail'

# Needed since FileGDB v1.4, otherwise crash/error ...
if True:
if True: # pylint: disable=using-constant-test
ds = ogr.Open("tmp/test.gdb", update=1)
lyr = ds.GetLayerByIndex(0)

Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ def ogr_geom_linestring_limits():
if gdal.GetLastErrorType() == 0:
return 'fail'

if False:
if False: # pylint: disable=using-constant-test
gdal.ErrorReset()
gdal.PushErrorHandler('CPLQuietErrorHandler')
geom.SetPoint(2147000000, 5, 6, 7)
Expand Down
3 changes: 2 additions & 1 deletion autotest/ogr/ogr_gml_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,7 @@ def ogr_gml_43():
# The service times out
return 'skip'

# pylint: disable=unreachable
if not gdaltest.have_gml_reader:
return 'skip'

Expand Down Expand Up @@ -2428,7 +2429,7 @@ def ogr_gml_57():
feat = None
ds = None

if False:
if False: # pylint: disable=using-constant-test
f = gdal.VSIFOpenL('/vsimem/ogr_gml_57.gml', 'rb')
print(gdal.VSIFReadL(1, 1000, f))
gdal.VSIFCloseL(f)
Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2544,7 +2544,7 @@ def ogr_gpkg_26():
gdaltest.post_reason('fail')
return 'fail'

if False:
if False: # pylint: disable=using-constant-test
ds.StartTransaction()
lyr = ds.CreateLayer('test3', geom_type=ogr.wkbPoint)
lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString))
Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_ingres.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def ogr_ingres_5():

return 'skip'

# pylint: disable=unused-argument
# pylint: disable=unreachable
sql_lyr = gdaltest.ingres_ds.ExecuteSQL(
"select * from tpoly where prfedea = '35043413'")

Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ def ogr_mysql_25():
f = None

# Error case: missing non-nullable field
if False:
if False: # pylint: disable=using-constant-test
# hum mysql seems OK with unset non-nullable fields ??
f = ogr.Feature(lyr.GetLayerDefn())
f.SetGeometryDirectly(ogr.CreateGeometryFromWkt('POINT(0 0)'))
Expand Down
14 changes: 7 additions & 7 deletions autotest/ogr/ogr_openfilegdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def ogr_openfilegdb_make_test_data():
feat = ogr.Feature(lyr.GetLayerDefn())
lyr.CreateFeature(feat)

if False:
if False: # pylint: disable=using-constant-test
lyr = ds.CreateLayer('sparse_layer', geom_type=ogr.wkbPoint)
for i in range(4096):
feat = ogr.Feature(lyr.GetLayerDefn())
Expand All @@ -159,7 +159,7 @@ def ogr_openfilegdb_make_test_data():
feat = ogr.Feature(lyr.GetLayerDefn())
lyr.CreateFeature(feat)

if True:
if True: # pylint: disable=using-constant-test
lyr = ds.CreateLayer('big_layer', geom_type=ogr.wkbNone)
lyr.CreateField(ogr.FieldDefn("real", ogr.OFTReal))
gdal.SetConfigOption('FGDB_BULK_LOAD', 'YES')
Expand All @@ -170,7 +170,7 @@ def ogr_openfilegdb_make_test_data():
lyr.CreateFeature(feat)
gdal.SetConfigOption('FGDB_BULK_LOAD', None)

if True:
if True: # pylint: disable=using-constant-test
lyr = ds.CreateLayer('hole', geom_type=ogr.wkbPoint, srs=None)
lyr.CreateField(ogr.FieldDefn('str', ogr.OFTString))
feat = ogr.Feature(lyr.GetLayerDefn())
Expand Down Expand Up @@ -211,14 +211,14 @@ def ogr_openfilegdb_make_test_data():
lyr.CreateFeature(feat)
feat = None

if True:
if True: # pylint: disable=using-constant-test
lyr = ds.CreateLayer('no_field', geom_type=ogr.wkbNone, srs=None)
for i in range(5):
feat = ogr.Feature(lyr.GetLayerDefn())
lyr.CreateFeature(feat)
feat = None

if True:
if True: # pylint: disable=using-constant-test
lyr = ds.CreateLayer('several_polygons', geom_type=ogr.wkbPolygon, srs=None)
for i in range(3):
for j in range(3):
Expand All @@ -232,7 +232,7 @@ def ogr_openfilegdb_make_test_data():
lyr.CreateFeature(feat)
feat = None

if True:
if True: # pylint: disable=using-constant-test
lyr = ds.CreateLayer('testnotnullable', geom_type=ogr.wkbPoint, srs=None, options=['GEOMETRY_NULLABLE=NO'])
field_defn = ogr.FieldDefn('field_not_nullable', ogr.OFTString)
field_defn.SetNullable(0)
Expand Down Expand Up @@ -969,7 +969,7 @@ def ogr_openfilegdb_10():

shutil.copytree('tmp/testopenfilegdb.gdb', 'tmp/testopenfilegdb_fuzzed.gdb')

if False:
if False: # pylint: disable=using-constant-test
for filename in ['tmp/testopenfilegdb_fuzzed.gdb/a00000001.gdbtable',
'tmp/testopenfilegdb_fuzzed.gdb/a00000001.gdbtablx']:
errors = set()
Expand Down
1 change: 1 addition & 0 deletions autotest/ogr/ogr_osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ def ogr_osm_14():


def ogr_osm_15_progresscbk_return_true(pct, msg, user_data):
# pylint: disable=unused-argument
user_data[0] = pct
return 1

Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5757,7 +5757,7 @@ def ogr_pg_with_and_without_postgis():
return 'skip'
# gdaltest.run_tests( [ ogr_pg_71 ] )
# gdaltest.run_tests( [ ogr_pg_cleanup ] )
if True:
if True: # pylint: disable=using-constant-test
gdaltest.run_tests(gdaltest_list_internal)

if gdaltest.pg_has_postgis:
Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_rfc35_mem.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def ogr_rfc35_mem_1():


def Truncate(val, lyr_defn, fieldname):
# pylint: disable=argument-unused
# pylint: disable=unused-argument

# if val is None:
# return val
Expand Down
4 changes: 2 additions & 2 deletions autotest/ogr/ogr_rfc35_mitab.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def ogr_rfc35_mitab_4():
gdaltest.post_reason(ret)
return ret

if False:
if False: # pylint: disable=using-constant-test
fd.SetWidth(5)
lyr.AlterFieldDefn(lyr_defn.GetFieldIndex("intfield"), fd, ogr.ALTER_ALL_FLAG)

Expand All @@ -418,7 +418,7 @@ def ogr_rfc35_mitab_4():

ds = None

if False:
if False: # pylint: disable=using-constant-test
ds = ogr.Open('/vsimem/rfc35_test.tab', update=1)
lyr = ds.GetLayer(0)
lyr_defn = lyr.GetLayerDefn()
Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ def ogr_shape_32():
# 4.5 GB space available or give a new directory that does and delete the
# directory afterwards.

return 'skip'
return 'skip' # pylint: disable=unreachable

# pylint: disable=unreachable
from decimal import Decimal
Expand Down
2 changes: 1 addition & 1 deletion autotest/ogr/ogr_wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def ogr_wfs_geoserver():
feat.DumpReadable()
return 'fail'

if False:
if False: # pylint: disable=using-constant-test
# This GeoServer version doesn't understand <GmlObjectId>
lyr.SetAttributeFilter("gml_id = 'poi.1'")
feat_count = lyr.GetFeatureCount()
Expand Down
2 changes: 1 addition & 1 deletion autotest/pymod/gdaltest_python2.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def run_func(func):
traceback.print_exc()

raise x
except Exception:
except Exception: # pylint: disable=broad-except
result = 'fail (blowup)'
print(result)

Expand Down
1 change: 1 addition & 0 deletions autotest/utilities/test_ogr2ogr_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def test_ogr2ogr_lib_12():


def mycallback_with_failure(pct, msg, user_data):
# pylint: disable=unused-argument
if pct > 0.5:
return 0
return 1
Expand Down
5 changes: 3 additions & 2 deletions gdal/swig/python/samples/ogr2ogr.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def EQUAL(a, b):


def TermProgress(dfComplete, pszMessage, pProgressArg):
# pylint: disable=unused-argument

global nLastTick
nThisTick = int(dfComplete * 40.0)
Expand Down Expand Up @@ -1205,7 +1206,7 @@ def SetupTargetLayer(poSrcDS, poSrcLayer, poDstDS, papszLCO, pszNewLayerName,
bAppend, eGType, bPromoteToMulti, nCoordDim, bOverwrite,
papszFieldTypesToString, bWrapDateline,
bExplodeCollections, pszZField, pszWHERE):

# pylint: disable=unused-argument
if pszNewLayerName is None:
pszNewLayerName = poSrcLayer.GetLayerDefn().GetName()

Expand Down Expand Up @@ -1511,7 +1512,7 @@ def TranslateLayer(psInfo, poSrcDS, poSrcLayer, poDstDS,
nCountLayerFeatures,
poClipSrc, poClipDst, bExplodeCollections, nSrcFileSize,
pnReadFeatureCount, pfnProgress, pProgressArg):

# pylint: disable=unused-argument
bForceToPolygon = False
bForceToMultiPolygon = False
bForceToMultiLineString = False
Expand Down

0 comments on commit 2d8f023

Please sign in to comment.