diff --git a/autotest/conftest.py b/autotest/conftest.py index 1c962c5411..2e24b377f1 100755 --- a/autotest/conftest.py +++ b/autotest/conftest.py @@ -1,6 +1,4 @@ # coding: utf-8 -from __future__ import absolute_import, division, print_function - import os import sys diff --git a/autotest/gcore/basic_test.py b/autotest/gcore/basic_test.py index 33f9e58a36..aad4af0b5a 100755 --- a/autotest/gcore/basic_test.py +++ b/autotest/gcore/basic_test.py @@ -222,7 +222,7 @@ def test_basic_test_9(): # Test gdal.PushErrorHandler() with a Python error handler as a method (#5186) -class my_python_error_handler_class(object): +class my_python_error_handler_class: def __init__(self): self.eErrClass = None self.err_no = None diff --git a/autotest/gcore/cog.py b/autotest/gcore/cog.py index 0e58f0e18a..c65989e7cd 100755 --- a/autotest/gcore/cog.py +++ b/autotest/gcore/cog.py @@ -559,7 +559,7 @@ def test_cog_byte_to_web_mercator(): filename2 = directory + "/cog2.tif" src_ds = gdal.Open(filename) - class my_error_handler(object): + class my_error_handler: def __init__(self): self.debug_msg_list = [] self.other_msg_list = [] diff --git a/autotest/gcore/misc.py b/autotest/gcore/misc.py index 62f8b29a56..2c4b1d70c1 100755 --- a/autotest/gcore/misc.py +++ b/autotest/gcore/misc.py @@ -254,7 +254,7 @@ def test_misc_5(): ############################################################################### -class misc_6_interrupt_callback_class(object): +class misc_6_interrupt_callback_class: def __init__(self): pass diff --git a/autotest/gcore/tiff_read.py b/autotest/gcore/tiff_read.py index 250e067b92..150276bd0b 100755 --- a/autotest/gcore/tiff_read.py +++ b/autotest/gcore/tiff_read.py @@ -3266,7 +3266,7 @@ def test_tiff_read_gcp_internal_and_auxxml( # Test reading .tif + .aux -class myHandlerClass(object): +class myHandlerClass: def __init__(self): self.msg = None diff --git a/autotest/gcore/vsis3.py b/autotest/gcore/vsis3.py index 6402ba38c4..b990a243a3 100755 --- a/autotest/gcore/vsis3.py +++ b/autotest/gcore/vsis3.py @@ -893,7 +893,7 @@ def test_vsis3_2(aws_test_config_as_config_options_or_credentials, webserver_por # Test temporary redirect handler = webserver.SequentialHandler() - class HandlerClass(object): + class HandlerClass: def __init__(self, response_value): self.old_authorization = None self.response_value = response_value @@ -1484,7 +1484,7 @@ def test_vsis3_readdir(aws_test_config, webserver_port): # Test temporary redirect handler = webserver.SequentialHandler() - class HandlerClass(object): + class HandlerClass: def __init__(self, response_value): self.old_authorization = None self.response_value = response_value diff --git a/autotest/gdrivers/envisat.py b/autotest/gdrivers/envisat.py index 81b5d1784b..768cb241be 100755 --- a/autotest/gdrivers/envisat.py +++ b/autotest/gdrivers/envisat.py @@ -60,7 +60,7 @@ def _get_mds_num(filename): # -class EnvisatTestBase(object): +class EnvisatTestBase: # Just a base class def download_file(self): diff --git a/autotest/ogr/data/pydrivers/ogr_DUMMY.py b/autotest/ogr/data/pydrivers/ogr_DUMMY.py index 1e3f64976e..4760902927 100644 --- a/autotest/ogr/data/pydrivers/ogr_DUMMY.py +++ b/autotest/ogr/data/pydrivers/ogr_DUMMY.py @@ -25,13 +25,13 @@ try: from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer except ImportError: # To be able to run in standalone mode - class BaseDriver(object): + class BaseDriver: pass - class BaseDataset(object): + class BaseDataset: pass - class BaseLayer(object): + class BaseLayer: pass diff --git a/autotest/ogr/ogr_gmlas.py b/autotest/ogr/ogr_gmlas.py index 58a117a17a..5f333300d3 100755 --- a/autotest/ogr/ogr_gmlas.py +++ b/autotest/ogr/ogr_gmlas.py @@ -582,7 +582,7 @@ def test_ogr_gmlas_abstractgeometry(): # Test validation against schema -class MyHandler(object): +class MyHandler: def __init__(self): self.error_list = [] diff --git a/autotest/pymod/gdaltest.py b/autotest/pymod/gdaltest.py index e02254740f..3fc1b94899 100755 --- a/autotest/pymod/gdaltest.py +++ b/autotest/pymod/gdaltest.py @@ -74,7 +74,7 @@ def testCreateCopyInterruptCallback(pct, message, user_data): ############################################################################### -class GDALTest(object): +class GDALTest: def __init__( self, drivername, diff --git a/autotest/pymod/webserver.py b/autotest/pymod/webserver.py index 199d0b230d..e619a097c6 100755 --- a/autotest/pymod/webserver.py +++ b/autotest/pymod/webserver.py @@ -39,7 +39,7 @@ def install_http_handler(handler_instance): custom_handler = None -class RequestResponse(object): +class RequestResponse: def __init__( self, method, @@ -76,7 +76,7 @@ class RequestResponse(object): ) -class FileHandler(object): +class FileHandler: """ Handler that serves files from a dictionary and/or a fallback VSI location. """ @@ -197,7 +197,7 @@ class FileHandler(object): self.send_response(request, filedata) -class BaseMockedHttpHandler(object): +class BaseMockedHttpHandler: @staticmethod def _process_req_resp(req_resp, request): if req_resp.custom_method: diff --git a/autotest/utilities/test_gdalbuildvrt_lib.py b/autotest/utilities/test_gdalbuildvrt_lib.py index 1130ae6a1d..1b1b9b0a67 100755 --- a/autotest/utilities/test_gdalbuildvrt_lib.py +++ b/autotest/utilities/test_gdalbuildvrt_lib.py @@ -604,7 +604,7 @@ def test_gdalbuildvrt_lib_bandList_subset_of_bands_from_multiple_band_source(): ############################################################################### def test_gdalbuildvrt_lib_warnings_and_custom_error_handler(): - class GdalErrorHandler(object): + class GdalErrorHandler: def __init__(self): self.got_failure = False self.got_warning = False diff --git a/autotest/utilities/test_gdaltindex_lib.py b/autotest/utilities/test_gdaltindex_lib.py index 7927aeffa6..67bfd384b1 100644 --- a/autotest/utilities/test_gdaltindex_lib.py +++ b/autotest/utilities/test_gdaltindex_lib.py @@ -92,7 +92,7 @@ def test_gdaltindex_lib_basic(four_tile_index): def test_gdaltindex_lib_already_existing_rasters(four_tiles, four_tile_index, tmp_path): - class GdalErrorHandler(object): + class GdalErrorHandler: def __init__(self): self.warnings = [] @@ -147,7 +147,7 @@ def test_gdaltindex_skipDifferentProjection(tmp_path, four_tile_index): ds.SetGeoTransform([47, 0.1, 0, 2, 0, -0.1]) ds = None - class GdalErrorHandler(object): + class GdalErrorHandler: def __init__(self): self.warning = None diff --git a/doc/source/api/python_gotchas.rst b/doc/source/api/python_gotchas.rst index e1d9592e37..abcd19756f 100644 --- a/doc/source/api/python_gotchas.rst +++ b/doc/source/api/python_gotchas.rst @@ -232,7 +232,7 @@ But you can do something like this instead: from osgeo import gdal - class GdalErrorHandler(object): + class GdalErrorHandler: def __init__(self): self.err_level = gdal.CE_None self.err_no = 0 diff --git a/doc/source/drivers/raster/vrt.rst b/doc/source/drivers/raster/vrt.rst index ab3adfd0d6..a5d16963ec 100644 --- a/doc/source/drivers/raster/vrt.rst +++ b/doc/source/drivers/raster/vrt.rst @@ -1630,7 +1630,7 @@ Given the following :file:`mandelbrot.py` file : #print('Using numba') g_max_iterations = 100 except Exception: - class jit(object): + class jit: def __init__(self, nopython = True, nogil = True): pass diff --git a/examples/pydrivers/ogr_DUMMY.py b/examples/pydrivers/ogr_DUMMY.py index 0d740b74fd..3cb5c3660b 100644 --- a/examples/pydrivers/ogr_DUMMY.py +++ b/examples/pydrivers/ogr_DUMMY.py @@ -24,13 +24,13 @@ try: from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer except ImportError: # To be able to run in standalone mode - class BaseDriver(object): + class BaseDriver: pass - class BaseDataset(object): + class BaseDataset: pass - class BaseLayer(object): + class BaseLayer: pass diff --git a/examples/pydrivers/ogr_PASSTHROUGH.py b/examples/pydrivers/ogr_PASSTHROUGH.py index 6ad4106d66..6246be6227 100644 --- a/examples/pydrivers/ogr_PASSTHROUGH.py +++ b/examples/pydrivers/ogr_PASSTHROUGH.py @@ -23,19 +23,18 @@ try: from gdal_python_driver import BaseDataset, BaseDriver, BaseLayer except ImportError: # To be able to run in standalone mode - class BaseDriver(object): + class BaseDriver: pass - class BaseDataset(object): + class BaseDataset: pass - class BaseLayer(object): + class BaseLayer: RandomRead = "RandomRead" FastSpatialFilter = "FastSpatialFilter" FastFeatureCount = "FastFeatureCount" FastGetExtent = "FastGetExtent" StringsAsUTF8 = "StringsAsUTF8" - pass class Layer(BaseLayer): diff --git a/gcore/gdalpythondriverloader.cpp b/gcore/gdalpythondriverloader.cpp index 3ac054b5fe..364f35d8df 100644 --- a/gcore/gdalpythondriverloader.cpp +++ b/gcore/gdalpythondriverloader.cpp @@ -126,7 +126,7 @@ static bool InitializePythonAndLoadGDALPythonDriverModule() "import json\n" "import inspect\n" "import sys\n" - "class BaseLayer(object):\n" + "class BaseLayer:\n" " RandomRead='RandomRead'\n" " FastSpatialFilter='FastSpatialFilter'\n" " FastFeatureCount='FastFeatureCount'\n" @@ -141,11 +141,11 @@ static bool InitializePythonAndLoadGDALPythonDriverModule() "BaseLayer'\n" " return _gdal_python_driver.layer_featureCount(self, force)\n" "\n" - "class BaseDataset(object):\n" + "class BaseDataset:\n" " def __init__(self):\n" " pass\n" "\n" - "class BaseDriver(object):\n" + "class BaseDriver:\n" " def __init__(self):\n" " pass\n" "\n" diff --git a/scripts/generate_log_feature_release.py b/scripts/generate_log_feature_release.py index 2e2207259b..b6b00c2da0 100755 --- a/scripts/generate_log_feature_release.py +++ b/scripts/generate_log_feature_release.py @@ -20,7 +20,7 @@ os.system( ) -class Commit(object): +class Commit: def __init__(self): self.metadata = "" self.message = "" diff --git a/swig/include/python/python_exceptions.i b/swig/include/python/python_exceptions.i index c17c0be12d..e561ff53ad 100644 --- a/swig/include/python/python_exceptions.i +++ b/swig/include/python/python_exceptions.i @@ -293,7 +293,7 @@ static void popErrorHandler() } %pythoncode %{ - class ExceptionMgr(object): + class ExceptionMgr: """ Context manager to manage Python Exception state for GDAL/OGR/OSR/GNM. diff --git a/swig/python/gdal-utils/osgeo_utils/gdal2tiles.py b/swig/python/gdal-utils/osgeo_utils/gdal2tiles.py index df0f5f01c2..fc0bcef5c0 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal2tiles.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal2tiles.py @@ -20,8 +20,6 @@ # SPDX-License-Identifier: MIT # ****************************************************************************** -from __future__ import division - import contextlib import glob import json @@ -129,7 +127,7 @@ class UnsupportedTileMatrixSet(Exception): pass -class TileMatrixSet(object): +class TileMatrixSet: def __init__(self) -> None: self.identifier = None self.srs = None @@ -328,7 +326,7 @@ Class is available under the open-source GDAL license (www.gdal.org). MAXZOOMLEVEL = 32 -class GlobalMercator(object): +class GlobalMercator: r""" TMS Global Mercator Profile --------------------------- @@ -547,7 +545,7 @@ class GlobalMercator(object): return quadKey -class GlobalGeodetic(object): +class GlobalGeodetic: r""" TMS Global Geodetic Profile --------------------------- @@ -644,7 +642,7 @@ class GlobalGeodetic(object): return (b[1], b[0], b[3], b[2]) -class Zoomify(object): +class Zoomify: """ Tiles compatible with the Zoomify viewer ---------------------------------------- @@ -2126,7 +2124,7 @@ def options_post_processing( return options -class TileDetail(object): +class TileDetail: tx = 0 ty = 0 tz = 0 @@ -2155,7 +2153,7 @@ class TileDetail(object): return "TileDetail %s\n%s\n%s\n" % (self.tx, self.ty, self.tz) -class TileJobInfo(object): +class TileJobInfo: """ Plain object to hold tile job configuration for a dataset """ @@ -2196,7 +2194,7 @@ class Gdal2TilesError(Exception): pass -class GDAL2Tiles(object): +class GDAL2Tiles: def __init__(self, input_file: str, output_folder: str, options: Options) -> None: """Constructor function - initialization""" self.out_drv = None @@ -4463,7 +4461,7 @@ def worker_tile_details( return tile_job_info, tile_details -class ProgressBar(object): +class ProgressBar: def __init__(self, total_items: int, progress_cbk=gdal.TermProgress_nocb) -> None: self.total_items = total_items self.nb_items_done = 0 @@ -4632,7 +4630,7 @@ def multi_threaded_tiling( shutil.rmtree(os.path.dirname(conf.src_file)) -class DividedCache(object): +class DividedCache: def __init__(self, nb_processes): self.nb_processes = nb_processes diff --git a/swig/python/gdal-utils/osgeo_utils/gdal_merge.py b/swig/python/gdal-utils/osgeo_utils/gdal_merge.py index 1ca222dcd7..7768c68409 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal_merge.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal_merge.py @@ -219,7 +219,7 @@ def names_to_fileinfos(names): # ***************************************************************************** -class file_info(object): +class file_info: """A class holding information about a GDAL file.""" def __init__(self): diff --git a/swig/python/gdal-utils/osgeo_utils/gdal_retile.py b/swig/python/gdal-utils/osgeo_utils/gdal_retile.py index e16a800913..6a514712ba 100644 --- a/swig/python/gdal-utils/osgeo_utils/gdal_retile.py +++ b/swig/python/gdal-utils/osgeo_utils/gdal_retile.py @@ -12,8 +12,6 @@ # # SPDX-License-Identifier: MIT ############################################################################### -from __future__ import print_function - import os import sys @@ -23,7 +21,7 @@ from osgeo_utils.auxiliary.util import enable_gdal_exceptions progress = gdal.TermProgress_nocb -class AffineTransformDecorator(object): +class AffineTransformDecorator: """A class providing some useful methods for affine Transformations""" def __init__(self, transform): @@ -54,7 +52,7 @@ class AffineTransformDecorator(object): return [xlist, ylist] -class DataSetCache(object): +class DataSetCache: """A class for caching source tiles""" def __init__(self): @@ -84,7 +82,7 @@ class DataSetCache(object): del self.dict -class tile_info(object): +class tile_info: """A class holding info how to tile""" def __init__(self, xsize, ysize, tileWidth, tileHeight, overlap): @@ -113,7 +111,7 @@ class tile_info(object): print("overlap: %d" % self.overlap) -class mosaic_info(object): +class mosaic_info: """A class holding information about a GDAL file or a GDAL fileset""" def __init__(self, filename, inputDS): diff --git a/swig/python/gdal-utils/osgeo_utils/ogrmerge.py b/swig/python/gdal-utils/osgeo_utils/ogrmerge.py index 98a4e3353e..d55942ebc0 100644 --- a/swig/python/gdal-utils/osgeo_utils/ogrmerge.py +++ b/swig/python/gdal-utils/osgeo_utils/ogrmerge.py @@ -97,7 +97,7 @@ def _Esc(x): return gdal.EscapeString(x, gdal.CPLES_XML).decode("UTF-8") -class XMLWriter(object): +class XMLWriter: def __init__(self, f): self.f = f self.inc = 0 diff --git a/swig/python/gdal-utils/osgeo_utils/samples/build_jp2_from_xml.py b/swig/python/gdal-utils/osgeo_utils/samples/build_jp2_from_xml.py index 1a31713e90..9913bbb92d 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/build_jp2_from_xml.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/build_jp2_from_xml.py @@ -420,7 +420,7 @@ def parse_jp2file(inpath, xml_tree, out_f): # Wrapper class for GDAL VSI*L API with class Python file interface -class VSILFile(object): +class VSILFile: def __init__(self, filename, access): self.f = gdal.VSIFOpenL(filename, access) diff --git a/swig/python/gdal-utils/osgeo_utils/samples/densify.py b/swig/python/gdal-utils/osgeo_utils/samples/densify.py index 4da1e47b26..58b2727494 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/densify.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/densify.py @@ -29,7 +29,7 @@ def Usage(): return 2 -class Translator(object): +class Translator: def construct_parser(self): from optparse import OptionGroup, OptionParser diff --git a/swig/python/gdal-utils/osgeo_utils/samples/gdal_cp.py b/swig/python/gdal-utils/osgeo_utils/samples/gdal_cp.py index fecddfa889..864152562d 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/gdal_cp.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/gdal_cp.py @@ -33,7 +33,7 @@ def Usage(): return 2 -class ScaledProgress(object): +class ScaledProgress: def __init__(self, dfMin, dfMax, UnderlyingProgress): self.dfMin = dfMin self.dfMax = dfMax diff --git a/swig/python/gdal-utils/osgeo_utils/samples/gdal_vrtmerge.py b/swig/python/gdal-utils/osgeo_utils/samples/gdal_vrtmerge.py index 1cb4f559cc..7b70dce40f 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/gdal_vrtmerge.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/gdal_vrtmerge.py @@ -54,7 +54,7 @@ def names_to_fileinfos(names): # ***************************************************************************** -class file_info(object): +class file_info: """A class holding information about a GDAL file.""" def __init__(self): diff --git a/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py b/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py index cf5fc7a531..c6342f91bf 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/loslas2ntv2.py @@ -21,7 +21,7 @@ from osgeo import gdal # dummy object to hold options -class Options(object): +class Options: def __init__(self): self.verbose_flag = 0 self.append = 0 diff --git a/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py b/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py index 0f2733913b..35a5627679 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/ogr_dispatch.py @@ -83,7 +83,7 @@ def wkbFlatten(x): ############################################################### -class Options(object): +class Options: def __init__(self): self.lco = [] self.dispatch_fields = [] diff --git a/swig/python/gdal-utils/osgeo_utils/samples/tigerpoly.py b/swig/python/gdal-utils/osgeo_utils/samples/tigerpoly.py index 3b30fbb6a3..f014ddc2a9 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/tigerpoly.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/tigerpoly.py @@ -19,7 +19,7 @@ from osgeo import ogr, osr ############################################################################# -class Module(object): +class Module: def __init__(self): self.lines = {} self.poly_line_links = {} diff --git a/swig/python/gdal-utils/osgeo_utils/samples/validate_geoparquet.py b/swig/python/gdal-utils/osgeo_utils/samples/validate_geoparquet.py index 4ad09424f6..0e170ae379 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/validate_geoparquet.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/validate_geoparquet.py @@ -40,7 +40,7 @@ map_ogr_geom_type_to_geoparquet = { map_remote_resources = {} -class GeoParquetValidator(object): +class GeoParquetValidator: def __init__(self, filename, check_data=False, local_schema=None): self.filename = filename self.check_data = check_data diff --git a/swig/python/gdal-utils/osgeo_utils/samples/validate_gpkg.py b/swig/python/gdal-utils/osgeo_utils/samples/validate_gpkg.py index dd3f40330c..0ebe5e7eac 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/validate_gpkg.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/validate_gpkg.py @@ -65,7 +65,7 @@ class GPKGCheckException(Exception): pass -class GPKGChecker(object): +class GPKGChecker: BASE_GEOM_TYPES = ( "GEOMETRY", diff --git a/swig/python/gdal-utils/osgeo_utils/samples/validate_jp2.py b/swig/python/gdal-utils/osgeo_utils/samples/validate_jp2.py index e5fb9be66a..f561b80c01 100644 --- a/swig/python/gdal-utils/osgeo_utils/samples/validate_jp2.py +++ b/swig/python/gdal-utils/osgeo_utils/samples/validate_jp2.py @@ -191,7 +191,7 @@ def get_gmljp2(filename): return mdd[0] -class ErrorReport(object): +class ErrorReport: def __init__(self, collect_internally=False): self.error_count = 0 self.warning_count = 0