Skip to content

Commit

Permalink
Merge pull request #4395 from yt-project/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros authored Apr 5, 2023
2 parents 79ff29d + b3fe5fc commit 93b47d9
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
- id: check-yaml

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black-jupyter

Expand All @@ -39,13 +39,13 @@ repos:
additional_dependencies: [black==23.1.0]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
rev: v0.0.261
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.6.3
rev: 1.7.0
hooks:
- id: nbqa-ruff
args: [--fix, --extend-ignore=E402]
Expand All @@ -56,7 +56,7 @@ repos:
- id: rst-backticks

- repo: https://github.com/MarcoGorelli/cython-lint
rev: v0.12.5
rev: v0.15.0
hooks:
- id: cython-lint
args: [--no-pycodestyle]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ exclude = '''
'''

[tool.ruff]
target-version = "py38" # https://github.com/charliermarsh/ruff/issues/2039
exclude = [
"doc",
"benchmarks",
Expand Down Expand Up @@ -293,6 +292,7 @@ select = [
ignore = [
"E501", # line too long
"E741", # Do not use variables named 'I', 'O', or 'l'
"B018", # Found useless expression. # disabled because ds.index is idiomatic
]


Expand Down
1 change: 1 addition & 0 deletions yt/data_objects/construction_data_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@ def _fill_fields(self, fields):
"This is likely due to missing ghost-zones support "
f"in class {type(self.ds)}",
category=RuntimeWarning,
stacklevel=1,
)
mylog.debug("Caught %d runtime errors.", runtime_errors_count)
for field, v in zip(fields, ls.fields):
Expand Down
3 changes: 2 additions & 1 deletion yt/data_objects/static_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ def __init_subclass__(cls, *args, **kwargs):
warnings.warn(
f"Overwritting {cls.__name__}, which was previously registered. "
"This is expected if you're importing a yt extension with a "
"frontend that was already migrated to the main code base."
"frontend that was already migrated to the main code base.",
stacklevel=2,
)
output_type_registry[cls.__name__] = cls
mylog.debug("Registering: %s as %s", cls.__name__, cls)
Expand Down
1 change: 1 addition & 0 deletions yt/frontends/amrvac/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def retrieve_ghost_zones(self, n_zones, fields, all_levels=False, smoothed=False
"ghost-zones interpolation/smoothing is not "
"currently supported for AMRVAC data.",
category=RuntimeWarning,
stacklevel=2,
)
smoothed = False
return super().retrieve_ghost_zones(
Expand Down
3 changes: 2 additions & 1 deletion yt/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ def fancy_download_file(url, filename, requests=None):
iterations = int(float(total_length) / float(blocksize))

pbar = get_pbar(
"Downloading %s to %s " % os.path.split(filename)[::-1], iterations
"Downloading {} to {} ".format(*os.path.split(filename)[::-1]),
iterations,
)
iteration = 0
for chunk in response.iter_content(chunk_size=blocksize):
Expand Down
3 changes: 2 additions & 1 deletion yt/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,8 @@ def load_archive(
"""

warnings.warn(
"The 'load_archive' function is still experimental and may be unstable."
"The 'load_archive' function is still experimental and may be unstable.",
stacklevel=2,
)

fn = os.path.expanduser(fn)
Expand Down
3 changes: 2 additions & 1 deletion yt/utilities/answer_testing/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ def ensure_image_comparability(a, b):

warnings.warn(
f"Images have different shapes {a.shape} and {b.shape}. "
"Padding nans to make them comparable."
"Padding nans to make them comparable.",
stacklevel=2,
)
smallest_containing_shape = (
max(a.shape[0], b.shape[0]),
Expand Down
7 changes: 5 additions & 2 deletions yt/utilities/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def read(self, file_names):
data = tomllib.load(fh)
except tomllib.TOMLDecodeError as exc:
warnings.warn(
f"Could not load configuration file {fname} (invalid TOML: {exc})"
f"Could not load configuration file {fname} (invalid TOML: {exc})",
stacklevel=2,
)
else:
self.update(data, metadata=metadata)
Expand All @@ -117,7 +118,9 @@ def write(self, file_handler):
else:
pdir = file_path.parent
if not pdir.exists():
warnings.warn(f"{pdir!s} does not exist, creating it (recursively)")
warnings.warn(
f"{pdir!s} does not exist, creating it (recursively)", stacklevel=2
)
os.makedirs(pdir)
file_path.write_text(config_as_str)

Expand Down
3 changes: 2 additions & 1 deletion yt/visualization/_commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def validate_image_name(filename, suffix: Optional[str] = None) -> str:
if suffix in _get_supported_image_file_formats() and suffix != psuffix:
warnings.warn(
f"Received two valid image formats {psuffix!r} (from filename) "
f"and {suffix!r} (from suffix). The former is ignored."
f"and {suffix!r} (from suffix). The former is ignored.",
stacklevel=2,
)
return f"{name}.{suffix}"
return str(filename)
Expand Down
3 changes: 2 additions & 1 deletion yt/visualization/base_plot_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ def _set_axes(self, norm: Normalize) -> None:
"with matplotlib versions older than 3.5\n"
"Please try upgrading matplotlib to a more recent version. "
"If the problem persists, please file a report to "
"https://github.com/yt-project/yt/issues/new"
"https://github.com/yt-project/yt/issues/new",
stacklevel=2,
)
else:
raise exc
Expand Down
3 changes: 2 additions & 1 deletion yt/visualization/plot_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ def save(
if new_suffix != suffix:
warnings.warn(
f"Overriding suffix {suffix!r} with mpl_kwargs['format'] = {new_suffix!r}. "
"Use the `suffix` argument directly to suppress this warning."
"Use the `suffix` argument directly to suppress this warning.",
stacklevel=2,
)
suffix = new_suffix

Expand Down
5 changes: 3 additions & 2 deletions yt/visualization/plot_modifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ def __call__(self, plot):
dy = (yy1 - yy0) * 2 ** (0.5) * self.length
# If the arrow is 0 length
if dx == dy == 0:
warnings.warn("The arrow has zero length. Not annotating.")
warnings.warn("The arrow has zero length. Not annotating.", stacklevel=2)
return

x, y, dx, dy = self._sanitize_xy_order(plot, x, y, dx, dy)
Expand Down Expand Up @@ -2586,7 +2586,8 @@ def __call__(self, plot):
if self.redshift and not hasattr(plot.data.ds, "current_redshift"):
warnings.warn(
f"dataset {plot.data.ds} does not have current_redshift attribute. "
"Set redshift=False to silence this warning."
"Set redshift=False to silence this warning.",
stacklevel=2,
)
self.redshift = False

Expand Down

0 comments on commit 93b47d9

Please sign in to comment.