From acba884a5824de00d4f3728ace9b9940b966820c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:43:48 +0000 Subject: [PATCH] style: pre-commit fixes --- dev/generate-tests.py | 12 +++--------- src/awkward/_connect/numpy.py | 6 ++---- src/awkward/_do.py | 18 ++++++------------ src/awkward/_errors.py | 6 ++---- src/awkward/contents/content.py | 4 +--- src/awkward/operations/ak_unflatten.py | 4 ++-- 6 files changed, 16 insertions(+), 34 deletions(-) diff --git a/dev/generate-tests.py b/dev/generate-tests.py index 3e678c923f..63ef72d275 100644 --- a/dev/generate-tests.py +++ b/dev/generate-tests.py @@ -368,9 +368,7 @@ def genspectests(specdict): if isinstance(val, list): f.write( " " * 4 - + "assert {0}[:len(pytest_{0})] == pytest.approx(pytest_{0})\n".format( - arg - ) + + f"assert {arg}[:len(pytest_{arg})] == pytest.approx(pytest_{arg})\n" ) else: f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n") @@ -516,9 +514,7 @@ def gencpukerneltests(specdict): if isinstance(val, list): f.write( " " * 4 - + "assert {0}[:len(pytest_{0})] == pytest.approx(pytest_{0})\n".format( - arg - ) + + f"assert {arg}[:len(pytest_{arg})] == pytest.approx(pytest_{arg})\n" ) else: f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n") @@ -735,9 +731,7 @@ def gencudakerneltests(specdict): if isinstance(val, list): f.write( " " * 4 - + "assert cupy.array_equal({0}[:len(pytest_{0})], cupy.array(pytest_{0}))\n".format( - arg - ) + + f"assert cupy.array_equal({arg}[:len(pytest_{arg})], cupy.array(pytest_{arg}))\n" ) else: f.write(" " * 4 + f"assert {arg} == pytest_{arg}\n") diff --git a/src/awkward/_connect/numpy.py b/src/awkward/_connect/numpy.py index a597f93a64..282b3fef6a 100644 --- a/src/awkward/_connect/numpy.py +++ b/src/awkward/_connect/numpy.py @@ -357,10 +357,8 @@ def action(inputs, **ignore): for x in contents ): raise TypeError( - "{}.{} is not implemented for string types. " - "To register an implementation, add a name to these string(s) and register a behavior overload".format( - type(ufunc).__module__, ufunc.__name__ - ) + f"{type(ufunc).__module__}.{ufunc.__name__} is not implemented for string types. " + "To register an implementation, add a name to these string(s) and register a behavior overload" ) if ufunc is numpy.matmul: diff --git a/src/awkward/_do.py b/src/awkward/_do.py index f1983dd5f8..e30af1bbe2 100644 --- a/src/awkward/_do.py +++ b/src/awkward/_do.py @@ -162,10 +162,8 @@ def unique(layout: Content, axis=None): ) if negaxis > depth: raise AxisError( - "cannot use axis={} on a nested list structure that splits into " - "different depths, the minimum of which is depth={} from the leaves".format( - axis, depth - ) + f"cannot use axis={axis} on a nested list structure that splits into " + f"different depths, the minimum of which is depth={depth} from the leaves" ) else: if negaxis <= 0: @@ -368,10 +366,8 @@ def argsort( ) if negaxis > depth: raise ValueError( - "cannot use axis={} on a nested list structure that splits into " - "different depths, the minimum of which is depth={} from the leaves".format( - axis, depth - ) + f"cannot use axis={axis} on a nested list structure that splits into " + f"different depths, the minimum of which is depth={depth} from the leaves" ) else: if negaxis <= 0: @@ -409,10 +405,8 @@ def sort( ) if negaxis > depth: raise ValueError( - "cannot use axis={} on a nested list structure that splits into " - "different depths, the minimum of which is depth={} from the leaves".format( - axis, depth - ) + f"cannot use axis={axis} on a nested list structure that splits into " + f"different depths, the minimum of which is depth={depth} from the leaves" ) else: if negaxis <= 0: diff --git a/src/awkward/_errors.py b/src/awkward/_errors.py index f757ab7302..8877ed66ef 100644 --- a/src/awkward/_errors.py +++ b/src/awkward/_errors.py @@ -410,14 +410,12 @@ def deprecate( date = "" else: date = " (target date: " + date + ")" - warning = """In version {}{}, this will be {}. + warning = f"""In version {version}{date}, this will be {will_be}. To raise these warnings as errors (and get stack traces to find out where they're called), run import warnings warnings.filterwarnings("error", module="awkward.*") after the first `import awkward` or use `@pytest.mark.filterwarnings("error:::awkward.*")` in pytest. -Issue: {}.""".format( - version, date, will_be, message - ) +Issue: {message}.""" warnings.warn(warning, category, stacklevel=stacklevel + 1) diff --git a/src/awkward/contents/content.py b/src/awkward/contents/content.py index a41a2514d1..4ad34d5152 100644 --- a/src/awkward/contents/content.py +++ b/src/awkward/contents/content.py @@ -498,9 +498,7 @@ def _getitem_next_missing( ) else: raise NotImplementedError( - "FIXME: unhandled case of SliceMissing with RecordArray containing {}".format( - content - ) + f"FIXME: unhandled case of SliceMissing with RecordArray containing {content}" ) return ak.contents.RecordArray( diff --git a/src/awkward/operations/ak_unflatten.py b/src/awkward/operations/ak_unflatten.py index cdded04853..17d8be6725 100644 --- a/src/awkward/operations/ak_unflatten.py +++ b/src/awkward/operations/ak_unflatten.py @@ -160,7 +160,7 @@ def unflatten_this_layout(layout): ): raise ValueError( "structure imposed by 'counts' does not fit in the array or partition " - "at axis={}".format(axis) + f"at axis={axis}" ) offsets = current_offsets[: position + 1] @@ -214,7 +214,7 @@ def apply(layout, depth, **kwargs): ): raise ValueError( "structure imposed by 'counts' does not fit in the array or partition " - "at axis={}".format(axis) + f"at axis={axis}" ) positions[0] = 0