Skip to content

Commit 3c462b9

Browse files
max-sixtycrusaderky
andcommitted
Python3.6 idioms (#3419)
* pyupgrade --py36-plus * Update xarray/core/nputils.py Co-Authored-By: crusaderky <[email protected]> * Update xarray/core/parallel.py Co-Authored-By: crusaderky <[email protected]> * Update xarray/tests/test_cftime_offsets.py Co-Authored-By: crusaderky <[email protected]> * Update xarray/tests/test_cftime_offsets.py Co-Authored-By: crusaderky <[email protected]>
1 parent 9886e3c commit 3c462b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+200
-221
lines changed

doc/gallery/plot_cartopy_facetgrid.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
==================================
43
Multiple plots and map projections

doc/gallery/plot_colorbar_center.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
==================
43
Centered colormaps

doc/gallery/plot_control_colorbar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
===========================
43
Control the plot's colorbar

doc/gallery/plot_lines_from_2d.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
==================================
43
Multiple lines from a 2d DataArray

doc/gallery/plot_rasterio.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
.. _recipes.rasterio:
43

doc/gallery/plot_rasterio_rgb.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
.. _recipes.rasterio_rgb:
43

xarray/_version.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=
9494
return None, None
9595
else:
9696
if verbose:
97-
print("unable to find command, tried %s" % (commands,))
97+
print(f"unable to find command, tried {commands}")
9898
return None, None
9999
stdout = p.communicate()[0].strip()
100100
if sys.version_info[0] >= 3:
@@ -302,9 +302,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
302302
if verbose:
303303
fmt = "tag '%s' doesn't start with prefix '%s'"
304304
print(fmt % (full_tag, tag_prefix))
305-
pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % (
306-
full_tag,
307-
tag_prefix,
305+
pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format(
306+
full_tag, tag_prefix
308307
)
309308
return pieces
310309
pieces["closest-tag"] = full_tag[len(tag_prefix) :]

xarray/backends/api.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ def open_mfdataset(
718718
autoclose=None,
719719
parallel=False,
720720
join="outer",
721-
**kwargs
721+
**kwargs,
722722
):
723723
"""Open multiple files as a single dataset.
724724
@@ -1258,9 +1258,7 @@ def _validate_append_dim_and_encoding(
12581258
return
12591259
if append_dim:
12601260
if append_dim not in ds.dims:
1261-
raise ValueError(
1262-
"{} not a valid dimension in the Dataset".format(append_dim)
1263-
)
1261+
raise ValueError(f"{append_dim} not a valid dimension in the Dataset")
12641262
for data_var in ds_to_append:
12651263
if data_var in ds:
12661264
if append_dim is None:

xarray/backends/file_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
kwargs=None,
8484
lock=None,
8585
cache=None,
86-
ref_counts=None
86+
ref_counts=None,
8787
):
8888
"""Initialize a FileManager.
8989
@@ -267,7 +267,7 @@ def __setstate__(self, state):
267267
def __repr__(self):
268268
args_string = ", ".join(map(repr, self._args))
269269
if self._mode is not _DEFAULT_MODE:
270-
args_string += ", mode={!r}".format(self._mode)
270+
args_string += f", mode={self._mode!r}"
271271
return "{}({!r}, {}, kwargs={})".format(
272272
type(self).__name__, self._opener, args_string, self._kwargs
273273
)

xarray/backends/netCDF4_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _nc4_dtype(var):
137137
elif var.dtype.kind in ["i", "u", "f", "c", "S"]:
138138
dtype = var.dtype
139139
else:
140-
raise ValueError("unsupported dtype for netCDF4 variable: {}".format(var.dtype))
140+
raise ValueError(f"unsupported dtype for netCDF4 variable: {var.dtype}")
141141
return dtype
142142

143143

0 commit comments

Comments
 (0)