Skip to content

Commit

Permalink
use .warning
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Mar 30, 2022
1 parent 1146f5e commit 5e24e39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 5 additions & 6 deletions nbformat/current.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import re
import warnings

warnings.warn("""nbformat.current is deprecated.
warnings.warning("""nbformat.current is deprecated.
- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version
Expand Down Expand Up @@ -50,15 +50,15 @@ class NBFormatError(ValueError):


def _warn_format():
warnings.warn("""Non-JSON file support in nbformat is deprecated.
warnings.warning("""Non-JSON file support in nbformat is deprecated.
Use nbconvert to create files of other formats.""")


def parse_py(s, **kwargs):
"""Parse a string into a (nbformat, string) tuple."""
nbf = current_nbformat
nbm = current_nbformat_minor

pattern = r'# <nbformat>(?P<nbformat>\d+[\.\d+]*)</nbformat>'
m = re.search(pattern,s)
if m is not None:
Expand All @@ -72,12 +72,12 @@ def parse_py(s, **kwargs):

def reads_json(nbjson, **kwargs):
"""DEPRECATED, use reads"""
warnings.warn("reads_json is deprecated, use reads")
warnings.warning("reads_json is deprecated, use reads")
return reads(nbjson)

def writes_json(nb, **kwargs):
"""DEPRECATED, use writes"""
warnings.warn("writes_json is deprecated, use writes")
warnings.warning("writes_json is deprecated, use writes")
return writes(nb, **kwargs)

def reads_py(s, **kwargs):
Expand Down Expand Up @@ -189,4 +189,3 @@ def write(nb, fp, format='DEPRECATED', **kwargs):
if isinstance(s, bytes):
s = s.decode('utf8')
return fp.write(s)

3 changes: 1 addition & 2 deletions nbformat/v3/nbbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def cast_str(obj):
if isinstance(obj, bytes):
# really this should never happend, it should
# have been base64 encoded before.
warnings.warn(
warnings.warning(
"A notebook got bytes instead of likely base64 encoded values."
"The content will likely be corrupted.",
UserWarning,
Expand Down Expand Up @@ -225,4 +225,3 @@ def new_author(name=None, email=None, affiliation=None, url=None):
if url is not None:
author.url = str_passthrough(url)
return author

0 comments on commit 5e24e39

Please sign in to comment.