Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace basestring by str since Python 2 is no longer supported #572

Merged
merged 2 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion geoviews/element/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def __init__(self, data, kdims=None, vdims=None, **params):
data = data.url
elif WebMapTileService and isinstance(data, WebMapTileService):
pass
elif not isinstance(data, util.basestring):
elif not isinstance(data, str):
raise TypeError('%s data should be a tile service URL not a %s type.'
% (type(self).__name__, type(data).__name__) )
super(WMTS, self).__init__(data, kdims=kdims, vdims=vdims, **params)
Expand Down
2 changes: 1 addition & 1 deletion geoviews/plotting/bokeh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_extents(self, element, ranges, range_type='combined'):
return extents

def get_data(self, element, ranges, style):
if not isinstance(element.data, util.basestring):
if not isinstance(element.data, str):
SkipRendering("WMTS element data must be a URL string, "
"bokeh cannot render %r" % element.data)
if '{Q}' in element.data.upper():
Expand Down
4 changes: 2 additions & 2 deletions geoviews/plotting/bokeh/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from bokeh.models.tools import BoxZoomTool, WheelZoomTool
from bokeh.models import MercatorTickFormatter, MercatorTicker
from holoviews.core.dimension import Dimension
from holoviews.core.util import dimension_sanitizer, basestring
from holoviews.core.util import dimension_sanitizer
from holoviews.plotting.bokeh.element import ElementPlot, OverlayPlot as HvOverlayPlot

from ...element import is_geographic, _Element, Shape
Expand Down Expand Up @@ -126,7 +126,7 @@ def _postprocess_hover(self, renderer, source):
except:
CustomJSHover = None
if (not self.geographic or None in (hover, CustomJSHover) or
isinstance(hover.tooltips, basestring) or self.projection is not GOOGLE_MERCATOR
isinstance(hover.tooltips, str) or self.projection is not GOOGLE_MERCATOR
or hover.tooltips is None or 'hv_created' not in hover.tags):
return
element = self.current_frame
Expand Down
2 changes: 1 addition & 1 deletion geoviews/plotting/mpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class WMTSPlot(GeoPlot):
'filterrad', 'clims', 'norm']

def get_data(self, element, ranges, style):
if isinstance(element.data, util.basestring):
if isinstance(element.data, str):
if '{Q}' in element.data:
tile_source = QuadtreeTiles(url=element.data)
else:
Expand Down
7 changes: 3 additions & 4 deletions geoviews/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from cartopy import crs as ccrs
from cartopy.io.img_tiles import GoogleTiles, QuadtreeTiles
from holoviews.element import Tiles
from holoviews.core.util import basestring
from packaging.version import Version
from shapely.geometry.base import BaseMultipartGeometry
from shapely.geometry import (
Expand Down Expand Up @@ -461,7 +460,7 @@ def check_crs(crs):
import pyproj
if isinstance(crs, pyproj.Proj):
out = crs
elif isinstance(crs, dict) or isinstance(crs, basestring):
elif isinstance(crs, dict) or isinstance(crs, str):
try:
out = pyproj.Proj(crs)
except RuntimeError:
Expand Down Expand Up @@ -591,14 +590,14 @@ def process_crs(crs):
if crs is None:
return ccrs.PlateCarree()

if isinstance(crs, basestring) and crs.lower().startswith('epsg'):
if isinstance(crs, str) and crs.lower().startswith('epsg'):
try:
crs = ccrs.epsg(crs[5:].lstrip().rstrip())
except:
raise ValueError("Could not parse EPSG code as CRS, must be of the format 'EPSG: {code}.'")
elif isinstance(crs, int):
crs = ccrs.epsg(crs)
elif isinstance(crs, basestring) or is_pyproj(crs):
elif isinstance(crs, str) or is_pyproj(crs):
try:
crs = proj_to_cartopy(crs)
except:
Expand Down