Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#354)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Steven Silvester <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and blink1073 authored Mar 10, 2023
1 parent 16b5325 commit 3bc1b53
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/parse_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) # noqa
print(tag_name)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.243
rev: v0.0.254
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 1 addition & 1 deletion nbformat/_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def __dict_invert(self, data):
outdict = {}
for k, lst in data.items():
if isinstance(lst, str):
lst = lst.split()
lst = lst.split() # noqa
for entry in lst:
outdict[entry] = k
return outdict
Expand Down
2 changes: 1 addition & 1 deletion nbformat/notebooknode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def update(self, *args, **kwargs):
raise TypeError("update expected at most 1 arguments, got %d" % len(args))
if args:
other = args[0]
if isinstance(other, Mapping):
if isinstance(other, Mapping): # noqa
for key in other:
self[key] = other[key]
elif hasattr(other, "keys"):
Expand Down
8 changes: 4 additions & 4 deletions nbformat/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,21 +596,21 @@ def sign_notebook_file(self, notebook_path):
def sign_notebook(self, nb, notebook_path="<stdin>"):
"""Sign a notebook that's been loaded"""
if self.notary.check_signature(nb):
print("Notebook already signed: %s" % notebook_path) # noqa
print("Notebook already signed: %s" % notebook_path)
else:
print("Signing notebook: %s" % notebook_path) # noqa
print("Signing notebook: %s" % notebook_path)
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) # noqa
print("Generating new notebook key: %s" % self.notary.secret_file)
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) # noqa
print("Removing trusted signature cache: %s" % self.notary.db_file)
os.remove(self.notary.db_file)
self.generate_new_key()
return
Expand Down
4 changes: 1 addition & 3 deletions nbformat/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def parse_filename(fname):
The filename, notebook name and format.
"""
basename, ext = os.path.splitext(fname)
if ext == ".ipynb":
format_ = "json"
elif ext == ".json":
if ext in [".ipynb", ".json"]:
format_ = "json"
elif ext == ".py":
format_ = "py"
Expand Down
2 changes: 1 addition & 1 deletion nbformat/v2/nbpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # noqa
def to_notebook(self, s, **kwargs):
"""Convert a string to a notebook."""
lines = s.splitlines()
cells = []
Expand Down
4 changes: 1 addition & 3 deletions nbformat/v3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ def parse_filename(fname):
The filename, notebook name and format.
"""
basename, ext = os.path.splitext(fname)
if ext == ".ipynb":
format_ = "json"
elif ext == ".json":
if ext in [".ipynb", ".json"]:
format_ = "json"
elif ext == ".py":
format_ = "py"
Expand Down
4 changes: 2 additions & 2 deletions nbformat/v3/nbpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # noqa
def new_cell(self, state, lines, **kwargs):
"""Create a new cell."""
if state == "codecell":
input_ = "\n".join(lines)
Expand Down Expand Up @@ -167,7 +167,7 @@ def split_lines_into_blocks(self, lines):
class PyWriter(NotebookWriter):
"""A Python notebook writer."""

def writes(self, nb, **kwargs): # noqa
def writes(self, nb, **kwargs):
"""Convert a notebook to a string."""
lines = ["# -*- coding: utf-8 -*-"]
lines.extend(
Expand Down
16 changes: 9 additions & 7 deletions nbformat/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def _relax_additional_properties(obj):
"""relax any `additionalProperties`"""
if isinstance(obj, dict):
for key, value in obj.items():
value = True if key == "additionalProperties" else _relax_additional_properties(value)
value = ( # noqa
True if key == "additionalProperties" else _relax_additional_properties(value)
)
obj[key] = value
elif isinstance(obj, list):
for i, value in enumerate(obj):
Expand Down Expand Up @@ -215,7 +217,7 @@ def __unicode__(self):
__str__ = __unicode__


def better_validation_error(error, version, version_minor): # noqa
def better_validation_error(error, version, version_minor):
"""Get better ValidationError on oneOf failures
oneOf errors aren't informative.
Expand Down Expand Up @@ -249,10 +251,10 @@ def better_validation_error(error, version, version_minor): # noqa
if better.ref is None:
better.ref = ref
return better
except Exception:
except Exception: # noqa
# if it fails for some reason,
# let the original error through
pass # noqa
pass
return NotebookValidationError(error, ref)


Expand Down Expand Up @@ -471,7 +473,7 @@ def validate( # noqa
version_minor = nbdict_version_minor
else:
# if ref is specified, and we don't have a version number, assume we're validating against 1.0
if version is None:
if version is None: # noqa
version, version_minor = 1, 0

if ref is None:
Expand Down Expand Up @@ -518,7 +520,7 @@ def _get_errors(
return iter(errors)


def _strip_invalida_metadata( # noqa
def _strip_invalida_metadata(
nbdict: Any, version: int, version_minor: int, relax_add_props: bool
) -> int:
"""
Expand Down Expand Up @@ -591,7 +593,7 @@ def _strip_invalida_metadata( # noqa
return changes


def iter_validate( # noqa
def iter_validate(
nbdict=None,
ref=None,
version=None,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.243"]
dependencies = ["black[jupyter]==23.1.0", "mdformat>0.7", "ruff==0.0.254"]
detached = true
[tool.hatch.envs.lint.scripts]
style = [
Expand Down
2 changes: 1 addition & 1 deletion tests/v4/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_base_version_matches_latest(self):
major=nbformat, minor=nbformat_minor
),
),
) as schema_file:
) as schema_file: # noqa
ver_schema = json.load(schema_file)
assert latest_schema == ver_schema

Expand Down

0 comments on commit 3bc1b53

Please sign in to comment.