Skip to content

Commit

Permalink
Remove unused import and cleanup a few other things
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Mar 24, 2022
1 parent 3c6f95a commit 1211cb2
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion nbconvert/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utilities for converting notebooks to and from different formats."""

from ._version import version_info, __version__
from ._version import version_info, __version__ # noqa
from .exporters import *
from . import filters
from . import preprocessors
Expand Down
1 change: 0 additions & 1 deletion nbconvert/exporters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Distributed under the terms of the Modified BSD License.

import os
import warnings

import entrypoints

Expand Down
2 changes: 1 addition & 1 deletion nbconvert/exporters/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def resources_include_url(name):
data = f.read()
break
else:
raise ValueError("No file %r found in %r" % (name, searchpaths))
raise ValueError("No file %r found in %r" % (name, searchpath))
data = base64.b64encode(data)
data = data.replace(b'\n', b'').decode('ascii')
src = 'data:{mime_type};base64,{data}'.format(mime_type=mime_type, data=data)
Expand Down
4 changes: 1 addition & 3 deletions nbconvert/exporters/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import os

from traitlets import Unicode, default
from traitlets import default
from traitlets.config import Config
from jupyter_core.paths import jupyter_path

from nbconvert.filters.highlight import Highlight2Latex
from nbconvert.filters.filter_links import resolve_references
Expand Down
1 change: 0 additions & 1 deletion nbconvert/exporters/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import shutil
from traitlets import Integer, List, Bool, Instance, Unicode, default
from testpath.tempdir import TemporaryWorkingDirectory
from typing import Optional
from .latex import LatexExporter

class LatexFailed(IOError):
Expand Down
1 change: 0 additions & 1 deletion nbconvert/exporters/templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import warnings
from pathlib import Path

from jupyter_core.paths import jupyter_path
from traitlets import HasTraits, Unicode, List, Dict, Bool, default, observe, validate
from traitlets.config import Config
from traitlets.utils.importstring import import_item
Expand Down
4 changes: 2 additions & 2 deletions nbconvert/exporters/tests/test_templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from traitlets import default
from traitlets.config import Config
from jinja2 import DictLoader, TemplateNotFound
from jinja2 import TemplateNotFound
from nbformat import v4
from unittest.mock import patch
from concurrent.futures import ProcessPoolExecutor
Expand Down Expand Up @@ -636,4 +636,4 @@ def test_remove_elements_with_tags(self):

def _make_exporter(self, config=None):
exporter = SampleExporter(config=config)
return exporter
return exporter
1 change: 0 additions & 1 deletion nbconvert/exporters/webpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import tempfile, os

from traitlets import Bool, default
from jupyter_core.paths import jupyter_path
import concurrent.futures

from .html import HTMLExporter
Expand Down
1 change: 0 additions & 1 deletion nbconvert/filters/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# Imports
#-----------------------------------------------------------------------------
import re
from nbconvert.utils.pandoc import pandoc

#-----------------------------------------------------------------------------
# Globals and constants
Expand Down
1 change: 0 additions & 1 deletion nbconvert/filters/markdown_mistune.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

from nbconvert.filters.strings import add_anchor


class InvalidNotebook(Exception):
pass

Expand Down
1 change: 0 additions & 1 deletion nbconvert/nbconvertapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ def initialize(self, argv=None):
def default_export_format(self):
return 'html'


#-----------------------------------------------------------------------------
# Main entry point
#-----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions nbconvert/preprocessors/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from typing import Optional
from nbformat import NotebookNode
from nbclient import NotebookClient, execute as _execute
# Backwards compatability for imported name
Expand Down Expand Up @@ -37,7 +36,7 @@ def _check_assign_resources(self, resources):
if resources or not hasattr(self, 'resources'):
self.resources = resources

def preprocess(self, nb, resources=None, km=None):
def preprocess(self, nb: NotebookNode, resources=None, km=None):
"""
Preprocess notebook executing each code cell.
Expand Down
13 changes: 4 additions & 9 deletions nbconvert/preprocessors/extractoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
from traitlets import Unicode, Set
from .base import Preprocessor

if sys.version_info < (3,):
text_type = basestring
else:
text_type = str


def guess_extension_without_jpe(mimetype):
"""
Expand All @@ -34,7 +29,7 @@ def guess_extension_without_jpe(mimetype):
return ext

def platform_utf_8_encode(data):
if isinstance(data, text_type):
if isinstance(data, str):
if sys.platform == 'win32':
data = data.replace('\n', '\r\n')
data = data.encode('utf-8')
Expand Down Expand Up @@ -95,14 +90,14 @@ def preprocess_cell(self, cell, resources, cell_index):
# data is b64-encoded as text (str, unicode),
# we want the original bytes
data = a2b_base64(data)
elif mime_type == 'application/json' or not isinstance(data, text_type):
elif mime_type == "application/json" or not isinstance(data, str):
# Data is either JSON-like and was parsed into a Python
# object according to the spec, or data is for sure
# JSON. In the latter case we want to go extra sure that
# we enclose a scalar string value into extra quotes by
# serializing it properly.
if isinstance(data, bytes) and not isinstance(data, text_type):
# In python 3 we need to guess the encoding in this
if isinstance(data, bytes):
# We need to guess the encoding in this
# instance. Some modules that return raw data like
# svg can leave the data in byte form instead of str
data = data.decode('utf-8')
Expand Down
32 changes: 32 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,35 @@ ignore =
[tool:pytest]
markers =
network: marks tests which require network connection

[flake8]
ignore = E121, # continuation line under-indented for hanging indent
E123, # closing bracket does not match indentation of opening bracket's line
E124, # closing bracket does not match visual indentation
E126, # continuation line over-indented for hanging indent
E127, # continuation line over-indented for visual indent
E128, # continuation line under-indented for visual indent
E201, # whitespace after '{'
E202, # whitespace before '}'
E203, # whitespace before ':'
E221, # multiple spaces before operator
E222, # multiple spaces after operator
E225, # missing whitespace around operator
E226, # missing whitespace around arithmetic operator
E231, # missing whitespace after ','
E241, # multiple spaces after '
E251, # unexpected spaces around keyword / parameter equals
E261, # at least two spaces before inline comment
E265, # block comment should start with '# '
E301, # expected 1 blank line, found 0
E302, # expected 2 blank lines, found 1
E303, # too many blank lines (2)
E305, # expected 2 blank lines after class or function definition, found 1
E306, # expected 1 blank line before a nested definition, found 0
E501, # line too long (90 > 79 characters)
F403, # 'from ... import *' used; unable to detect undefined names
W291, # trailing whitespace
W293, # blank line contains whitespace
W391, # blank line at end of file
W503, # line break before binary operator
W504, # line break after binary operator

0 comments on commit 1211cb2

Please sign in to comment.