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

[pre-commit.ci] pre-commit autoupdate #1576

Merged
merged 4 commits into from
Aug 9, 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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.20.2
rev: v2.0.0
hooks:
- id: setup-cfg-fmt

- repo: https://github.com/asottile/pyupgrade
rev: "v2.37.2"
rev: "v2.37.3"
hooks:
- id: pyupgrade
args: ["--py36-plus"]
Expand All @@ -38,7 +38,7 @@ repos:
additional_dependencies: [pyyaml]

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear, flake8-print>=5]
Expand Down
13 changes: 4 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Information Analysis
Topic :: Scientific/Engineering :: Mathematics
Expand Down Expand Up @@ -62,14 +57,14 @@ numba_extensions =

[flake8]
extend-select = C,B,B9,T,AK1
extend-ignore = E203,E501,E266
extend-ignore = E203,E501,B950,E266
max-complexity = 100
exclude = studies, pybind11, rapidjson, dlpack, docs-*, src/awkward/_typeparser/generated_parser.py, awkward/_typeparser/generated_parser.py
per-file-ignores =
tests/*: T, AK1
dev/*: T, AK1
setup.py: T, AK1
localbuild.py: T, AK1
dev/*: T, T201, AK1
setup.py: T, T201, AK1
localbuild.py: T, T201, AK1
src/awkward/__init__.py: E402, F401, F403, AK1
awkward/__init__.py: E402, F401, F403, AK1
src/awkward/_v2/__init__.py: F401, F403
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class CMakeBuild(setuptools.command.build_ext.build_ext):
def build_extensions(self):
try:
subprocess.check_output([CMAKE, "--version"])
except OSError:
except OSError as err:
raise RuntimeError(
"CMake must be installed to build the following extensions: "
+ ", ".join(x.name for x in self.extensions)
)
) from err

setuptools.command.build_ext.build_ext.build_extensions(self)

Expand Down
8 changes: 4 additions & 4 deletions src/awkward/_connect/_numexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def import_numexpr():
global checked_version
try:
import numexpr
except ModuleNotFoundError:
except ModuleNotFoundError as err:
raise ModuleNotFoundError(
"""install the 'numexpr' package with:

Expand All @@ -24,7 +24,7 @@ def import_numexpr():
or

conda install numexpr"""
) from None
) from err
else:
if not checked_version and ak._v2._util.parse_version(
numexpr.__version__
Expand Down Expand Up @@ -121,11 +121,11 @@ def re_evaluate(local_dict=None):

try:
compiled_ex = numexpr.necompiler._numexpr_last["ex"] # noqa: F841
except KeyError:
except KeyError as err:
raise RuntimeError(
"not a previous evaluate() execution found"
+ ak._util.exception_suffix(__file__)
)
) from err
names = numexpr.necompiler._numexpr_last["argnames"]
arguments = getArguments(names, local_dict)

Expand Down
12 changes: 10 additions & 2 deletions src/awkward/_v2/_connect/cuda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,16 @@ def populate_kernel_errors(kernel_name, cu_file):

class Invocation:
def __init__(self, name, error_context):
self.name = name
self.error_context = error_context
self._name = name
self._error_context = error_context

@property
def name(self):
return self._name

@property
def error_context(self):
return self._error_context


def import_cupy(name="Awkward Arrays with CUDA"):
Expand Down
8 changes: 4 additions & 4 deletions src/awkward/_v2/_connect/numexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def import_numexpr():
global checked_version
try:
import numexpr
except ModuleNotFoundError:
except ModuleNotFoundError as err:
raise ak._v2._util.error(
ModuleNotFoundError(
"""install the 'numexpr' package with:
Expand All @@ -25,7 +25,7 @@ def import_numexpr():

conda install numexpr"""
)
) from None
) from err
else:
if not checked_version and ak._v2._util.parse_version(
numexpr.__version__
Expand Down Expand Up @@ -123,13 +123,13 @@ def re_evaluate(local_dict=None):

try:
compiled_ex = numexpr.necompiler._numexpr_last["ex"] # noqa: F841
except KeyError:
except KeyError as err:
raise ak._v2._util.error(
RuntimeError(
"not a previous evaluate() execution found"
+ ak._v2._util.exception_suffix(__file__)
)
)
) from err
names = numexpr.necompiler._numexpr_last["argnames"]
arguments = getArguments(names, local_dict)

Expand Down
4 changes: 2 additions & 2 deletions src/awkward/_v2/_connect/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def import_fsspec(name):
try:
import fsspec

except ModuleNotFoundError:
except ModuleNotFoundError as err:
raise ImportError(
f"""to use {name}, you must install fsspec:

Expand All @@ -62,7 +62,7 @@ def import_fsspec(name):

conda install -c conda-forge fsspec
"""
)
) from err

import_pyarrow_parquet(name)

Expand Down
2 changes: 1 addition & 1 deletion src/awkward/_v2/contents/bytemaskedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _carry(self, carry, allow_lazy):
try:
nextmask = self._mask[carry.data]
except IndexError as err:
raise ak._v2._util.indexerror(self, carry.data, str(err))
raise ak._v2._util.indexerror(self, carry.data, str(err)) from err

return ByteMaskedArray(
nextmask,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/_v2/contents/indexedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _carry(self, carry, allow_lazy):
try:
nextindex = self._index[carry.data]
except IndexError as err:
raise ak._v2._util.indexerror(self, carry.data, str(err))
raise ak._v2._util.indexerror(self, carry.data, str(err)) from err

return IndexedArray(
nextindex,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/_v2/contents/indexedoptionarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def _carry(self, carry, allow_lazy):
try:
nextindex = self._index[carry.data]
except IndexError as err:
raise ak._v2._util.indexerror(self, carry.data, str(err))
raise ak._v2._util.indexerror(self, carry.data, str(err)) from err

return IndexedOptionArray(
nextindex,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/_v2/contents/listarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _carry(self, carry, allow_lazy):
nextstarts = self._starts[carry.data]
nextstops = self._stops[: self._starts.length][carry.data]
except IndexError as err:
raise ak._v2._util.indexerror(self, carry.data, str(err))
raise ak._v2._util.indexerror(self, carry.data, str(err)) from err

return ListArray(
nextstarts,
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/_v2/contents/listoffsetarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _carry(self, carry, allow_lazy):
nextstarts = self.starts[carry.data]
nextstops = self.stops[carry.data]
except IndexError as err:
raise ak._v2._util.indexerror(self, carry.data, str(err))
raise ak._v2._util.indexerror(self, carry.data, str(err)) from err

return ak._v2.contents.listarray.ListArray(
nextstarts,
Expand Down
14 changes: 7 additions & 7 deletions src/awkward/_v2/contents/numpyarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def _getitem_at(self, where):
try:
out = self._data[where]
except IndexError as err:
raise ak._v2._util.indexerror(self, where, str(err))
raise ak._v2._util.indexerror(self, where, str(err)) from err

if hasattr(out, "shape") and len(out.shape) != 0:
return NumpyArray(out, None, None, self._nplike)
Expand All @@ -257,7 +257,7 @@ def _getitem_range(self, where):
try:
out = self._data[where]
except IndexError as err:
raise ak._v2._util.indexerror(self, where, str(err))
raise ak._v2._util.indexerror(self, where, str(err)) from err

return NumpyArray(
out,
Expand All @@ -279,7 +279,7 @@ def _carry(self, carry, allow_lazy):
try:
nextdata = self._data[carry.data]
except IndexError as err:
raise ak._v2._util.indexerror(self, carry.data, str(err))
raise ak._v2._util.indexerror(self, carry.data, str(err)) from err
return NumpyArray(
nextdata,
self._carry_identifier(carry),
Expand Down Expand Up @@ -312,7 +312,7 @@ def _getitem_next(self, head, tail, advanced):
try:
out = self._data[where]
except IndexError as err:
raise ak._v2._util.indexerror(self, (head,) + tail, str(err))
raise ak._v2._util.indexerror(self, (head,) + tail, str(err)) from err

if hasattr(out, "shape") and len(out.shape) != 0:
return NumpyArray(out, None, None, self._nplike)
Expand All @@ -324,7 +324,7 @@ def _getitem_next(self, head, tail, advanced):
try:
out = self._data[where]
except IndexError as err:
raise ak._v2._util.indexerror(self, (head,) + tail, str(err))
raise ak._v2._util.indexerror(self, (head,) + tail, str(err)) from err
out2 = NumpyArray(out, None, self._parameters, self._nplike)
return out2

Expand All @@ -346,7 +346,7 @@ def _getitem_next(self, head, tail, advanced):
try:
out = self._data[where]
except IndexError as err:
raise ak._v2._util.indexerror(self, (head,) + tail, str(err))
raise ak._v2._util.indexerror(self, (head,) + tail, str(err)) from err

return NumpyArray(out, None, self._parameters, self._nplike)

Expand All @@ -355,7 +355,7 @@ def _getitem_next(self, head, tail, advanced):
try:
out = self._data[where]
except IndexError as err:
raise ak._v2._util.indexerror(self, (head,) + tail, str(err))
raise ak._v2._util.indexerror(self, (head,) + tail, str(err)) from err
out2 = NumpyArray(out, None, self._parameters, self._nplike)
return out2

Expand Down
10 changes: 5 additions & 5 deletions src/awkward/_v2/contents/unionarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _carry(self, carry, allow_lazy):
nexttags = self._tags[carry.data]
nextindex = self._index[: self._tags.length][carry.data]
except IndexError as err:
raise ak._v2._util.indexerror(self, carry.data, str(err))
raise ak._v2._util.indexerror(self, carry.data, str(err)) from err

return UnionArray(
nexttags,
Expand Down Expand Up @@ -1288,17 +1288,17 @@ def _to_numpy(self, allow_missing):
if any(isinstance(x, self._nplike.ma.MaskedArray) for x in contents):
try:
out = self._nplike.ma.concatenate(contents)
except Exception:
except Exception as err:
raise ak._v2._util.error(
ValueError(f"cannot convert {self} into numpy.ma.MaskedArray")
)
) from err
else:
try:
out = numpy.concatenate(contents)
except Exception:
except Exception as err:
raise ak._v2._util.error(
ValueError(f"cannot convert {self} into np.ndarray")
)
) from err

tags = numpy.asarray(self.tags)
for tag, content in enumerate(contents):
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/_v2/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ def __getattr__(self, where):
"while trying to get field {}, an exception "
"occurred:\n{}: {}".format(repr(where), type(err), str(err))
)
)
) from err
else:
raise ak._v2._util.error(AttributeError(f"no field named {where!r}"))

Expand Down Expand Up @@ -1791,7 +1791,7 @@ def __getattr__(self, where):
"while trying to get field {}, an exception "
"occurred:\n{}: {}".format(repr(where), type(err), str(err))
)
)
) from err
else:
raise ak._v2._util.error(AttributeError(f"no field named {where!r}"))

Expand Down
4 changes: 2 additions & 2 deletions src/awkward/_v2/numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def register_and_check():
if not checked_version:
try:
import numba
except ImportError:
except ImportError as err:
raise ImportError(
"""install the 'numba' package with:

Expand All @@ -20,7 +20,7 @@ def register_and_check():
or

conda install numba"""
)
) from err

checked_version = True
if ak._v2._util.parse_version(numba.__version__) < ak._v2._util.parse_version(
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/_v2/operations/ak_from_avro_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ def from_avro_file(
opened_file, limit_entries, debug_forth
).outcontents
return _impl(form, length, container, highlevel, behavior)
except ImportError:
except ImportError as err:
raise ak._v2._util.error(
"the filename is incorrect or the file does not exist"
)
) from err

else:
if not hasattr(file, "read"):
Expand Down
2 changes: 1 addition & 1 deletion src/awkward/_v2/operations/ak_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def opener():
)

except Exception as err:
raise ak._v2._util.error(err)
raise ak._v2._util.error(err) from err


class _NoContextManager:
Expand Down
4 changes: 2 additions & 2 deletions src/awkward/_v2/operations/ak_to_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def to_pandas(
def _impl(array, how, levelname, anonymous):
try:
import pandas
except ImportError:
except ImportError as err:
raise ak._v2._util.error(
ImportError(
"""install the 'pandas' package with:
Expand All @@ -146,7 +146,7 @@ def _impl(array, how, levelname, anonymous):

conda install pandas"""
)
)
) from err

if how is not None:
out = None
Expand Down
Loading