From 4692b54b283fd5e0c068116f1c02fe5ba8b9b034 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Apr 2023 06:53:04 -0500 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#357) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester --- .github/scripts/parse_ref.py | 2 +- .pre-commit-config.yaml | 6 +++--- nbformat/current.py | 4 +++- nbformat/sign.py | 8 ++++---- nbformat/v2/nbpy.py | 2 +- nbformat/v3/nbpy.py | 4 ++-- nbformat/validator.py | 2 +- pyproject.toml | 6 ++++-- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/scripts/parse_ref.py b/.github/scripts/parse_ref.py index 5b82504d..f27e9187 100644 --- a/.github/scripts/parse_ref.py +++ b/.github/scripts/parse_ref.py @@ -25,7 +25,7 @@ def parse_ref(current_ref): raise Exception(f"Invalid ref `{current_ref}`!") # noqa tag_name = current_ref.replace("refs/tags/", "") - print(tag_name) + print(tag_name) # noqa if __name__ == "__main__": diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af0fc9ed..fe6c715f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.21.0 + rev: 0.22.0 hooks: - id: check-github-workflows @@ -30,12 +30,12 @@ repos: - id: mdformat - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.254 + rev: v0.0.260 hooks: - id: ruff args: ["--fix"] diff --git a/nbformat/current.py b/nbformat/current.py index b27682fc..ce1daf04 100644 --- a/nbformat/current.py +++ b/nbformat/current.py @@ -43,6 +43,7 @@ - use nbformat.vX directly to composing notebooks of a particular version """, DeprecationWarning, + stacklevel=2, ) __all__ = [ @@ -88,7 +89,8 @@ class NBFormatError(ValueError): def _warn_format(): warnings.warn( """Non-JSON file support in nbformat is deprecated since nbformat 1.0. - Use nbconvert to create files of other formats.""" + Use nbconvert to create files of other formats.""", + stacklevel=2, ) diff --git a/nbformat/sign.py b/nbformat/sign.py index d498bb9a..2e1dbca5 100644 --- a/nbformat/sign.py +++ b/nbformat/sign.py @@ -596,21 +596,21 @@ def sign_notebook_file(self, notebook_path): def sign_notebook(self, nb, notebook_path=""): """Sign a notebook that's been loaded""" if self.notary.check_signature(nb): - print("Notebook already signed: %s" % notebook_path) + print("Notebook already signed: %s" % notebook_path) # noqa else: - print("Signing notebook: %s" % notebook_path) + print("Signing notebook: %s" % notebook_path) # noqa self.notary.sign(nb) def generate_new_key(self): """Generate a new notebook signature key""" - print("Generating new notebook key: %s" % self.notary.secret_file) + print("Generating new notebook key: %s" % self.notary.secret_file) # noqa self.notary._write_secret_file(os.urandom(1024)) def start(self): """Start the trust notebook app.""" if self.reset: if os.path.exists(self.notary.db_file): - print("Removing trusted signature cache: %s" % self.notary.db_file) + print("Removing trusted signature cache: %s" % self.notary.db_file) # noqa os.remove(self.notary.db_file) self.generate_new_key() return diff --git a/nbformat/v2/nbpy.py b/nbformat/v2/nbpy.py index f0cde2d1..015d7265 100644 --- a/nbformat/v2/nbpy.py +++ b/nbformat/v2/nbpy.py @@ -42,7 +42,7 @@ def reads(self, s, **kwargs): """Convert a string to a notebook.""" return self.to_notebook(s, **kwargs) - def to_notebook(self, s, **kwargs): + def to_notebook(self, s, **kwargs): # noqa """Convert a string to a notebook.""" lines = s.splitlines() cells = [] diff --git a/nbformat/v3/nbpy.py b/nbformat/v3/nbpy.py index c9323437..cde4ca43 100644 --- a/nbformat/v3/nbpy.py +++ b/nbformat/v3/nbpy.py @@ -113,7 +113,7 @@ def to_notebook(self, s, **kwargs): # noqa nb = new_notebook(worksheets=[ws]) return nb - def new_cell(self, state, lines, **kwargs): + def new_cell(self, state, lines, **kwargs): # noqa """Create a new cell.""" if state == "codecell": input_ = "\n".join(lines) @@ -167,7 +167,7 @@ def split_lines_into_blocks(self, lines): class PyWriter(NotebookWriter): """A Python notebook writer.""" - def writes(self, nb, **kwargs): + def writes(self, nb, **kwargs): # noqa """Convert a notebook to a string.""" lines = ["# -*- coding: utf-8 -*-"] lines.extend( diff --git a/nbformat/validator.py b/nbformat/validator.py index 92861c9c..22d3dcbb 100644 --- a/nbformat/validator.py +++ b/nbformat/validator.py @@ -524,7 +524,7 @@ def _get_errors( return iter(errors) -def _strip_invalida_metadata( +def _strip_invalida_metadata( # noqa nbdict: Any, version: int, version_minor: int, relax_add_props: bool ) -> int: """ diff --git a/pyproject.toml b/pyproject.toml index 45773a60..5a68f106 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ dependencies = ["mypy>=0.990"] test = "mypy --install-types --non-interactive {args:nbformat tests}" [tool.hatch.envs.lint] -dependencies = ["black[jupyter]==23.1.0", "mdformat>0.7", "ruff==0.0.254"] +dependencies = ["black[jupyter]==23.3.0", "mdformat>0.7", "ruff==0.0.260"] detached = true [tool.hatch.envs.lint.scripts] style = [ @@ -192,7 +192,9 @@ unfixable = [ # RUF001 contains ambiguous unicode character '–' (did you mean '-'?) # S101 Use of `assert` detected # PLR2004 Magic value used in comparison -"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "RUF001", "RUF002", "S101", "PLR2004"] +# PLC1901 `cell.source == ""` can be simplified +"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "RUF001", "RUF002", "S101", "PLR2004", + "PLC1901"] # F401 `nbxml.to_notebook` imported but unused "nbformat/*__init__.py" = ["F401"]