Skip to content

Commit

Permalink
setup.py cleanup and mypy (#48)
Browse files Browse the repository at this point in the history
* Remove unneeded travis file

* README polish

* Remove deprecated setup.py options

* Add mypy type checking

* Add code review use case to docstring

* Add MIT license
  • Loading branch information
jayqi committed Jul 28, 2020
1 parent dcd19cd commit 58ab28d
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 58 deletions.
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2020 DrivenData Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include AUTHORS.md
include CONTRIBUTING.md
include HISTORY.md
include LICENSE
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ install: clean ## install the package to the active Python's site-packages
lint: ## check style with flake8
black --check nbautoexport tests
flake8 nbautoexport tests
mypy nbautoexport tests

release: dist ## package and upload a release
twine upload dist/*
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

> Making it easier to code review Jupyter notebooks, one script at a time.
`nbautoexport` automatically exports Jupyter notebooks to various file formats (.py, .html, and more) upon save.
`nbautoexport` automatically exports Jupyter notebooks to various file formats (.py, .html, and more) upon save. One great use case is to automatically have script versions of your notebooks to facilitate code review commenting.

## Installation

First, you will need to install `nbautoexport`.
First, you will need to install `nbautoexport`. This should be installed in the same environment you are running Jupyter Notebook or Jupyter Lab from.

```bash
pip install nbautoexport
Expand Down Expand Up @@ -131,7 +131,8 @@ nbautoexport --help
Usage: nbautoexport [OPTIONS] COMMAND [ARGS]...
Automatically export Jupyter notebooks to various file formats (.py,
.html, and more) upon save.
.html, and more) upon save. One great use case is to automatically have
script versions of your notebooks to facilitate code review commenting.
To set up, first use the 'install' command to register nbautoexport with
Jupyter. If you already have a Jupyter server running, you will need to
Expand Down
4 changes: 2 additions & 2 deletions nbautoexport/clean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, List
from typing import Iterable, List, Set
from pathlib import Path

from nbconvert.exporters import get_exporter
Expand Down Expand Up @@ -79,7 +79,7 @@ def get_expected_exports(
List[Path]: list of expected nbautoexport output files, relative to notebook files
"""

export_paths = set()
export_paths: Set[Path] = set()
for notebook in notebooks:
for export_format in config.export_formats:
export_paths.update(
Expand Down
2 changes: 1 addition & 1 deletion nbautoexport/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def postprocess(self, input: str):
if self.subfolder is None:
return

input = Path(input)
input: Path = Path(input)

new_dir = input.parent / self.subfolder
new_dir.mkdir(exist_ok=True)
Expand Down
7 changes: 4 additions & 3 deletions nbautoexport/nbautoexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def main(
),
):
"""Automatically export Jupyter notebooks to various file formats (.py, .html, and more) upon
save.
save. One great use case is to automatically have script versions of your notebooks to
facilitate code review commenting.
To set up, first use the 'install' command to register nbautoexport with Jupyter. If you
already have a Jupyter server running, you will need to restart it.
Expand Down Expand Up @@ -132,8 +133,8 @@ def export(
writable=True,
help="Path to notebook file or directory of notebook files to export.",
),
export_formats: Optional[List[ExportFormat]] = typer.Option(
None,
export_formats: List[ExportFormat] = typer.Option(
[],
"--export-format",
"-f",
show_default=True,
Expand Down
6 changes: 4 additions & 2 deletions nbautoexport/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@


SAVE_PROGRESS_INDICATOR_FILE = ".nbautoexport"
DEFAULT_EXPORT_FORMATS = ["script"]
DEFAULT_ORGANIZE_BY = "extension"


class ExportFormat(str, Enum):
Expand All @@ -33,6 +31,10 @@ class OrganizeBy(str, Enum):
extension = "extension"


DEFAULT_EXPORT_FORMATS = [ExportFormat.script]
DEFAULT_ORGANIZE_BY = OrganizeBy.extension


class NbAutoexportConfig(BaseModel):
export_formats: List[ExportFormat] = [ExportFormat(fmt) for fmt in DEFAULT_EXPORT_FORMATS]
organize_by: OrganizeBy = OrganizeBy(DEFAULT_ORGANIZE_BY)
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ flake8>=3.7.8
mkdocs>=1.1
mkdocs-material
mkdocstrings
mypy>=0.782
pip>=19.2.3
pytest-runner>=5.1
pytest>=4.6.5
Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ exclude = .git
max-line-length = 99
exclude = .git

[mypy]
ignore_missing_imports = True
allow_redefinition = True

[mypy-nbautoexport._version]
ignore_errors = True

[tool:pytest]
collect_ignore = ['setup.py']
testpaths = tests
Expand Down
32 changes: 15 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,38 @@ def load_requirements(path: Path):

requirements = load_requirements(Path(__file__).parent / "requirements.txt")

setup_requirements = [
"pytest-runner",
]

test_requirements = [
"pytest>=3",
]

setup(
author="DrivenData",
author_email="info@drivendata.org",
python_requires=">=3.5",
python_requires=">=3.6",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Natural Language :: English",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
description="Automatically export Jupyter notebooks to various file formats (.py, .html, and more) on save.",
description=(
"Automatically export Jupyter notebooks to various file formats (.py, .html, and more) on "
"save."
),
entry_points={"console_scripts": ["nbautoexport=nbautoexport.nbautoexport:app"]},
install_requires=requirements,
long_description=readme + "\n\n" + history,
long_description_content_type="text/markdown",
include_package_data=True,
keywords="nbautoexport",
keywords=["nbautoexport", "jupyter", "nbconvert"],
name="nbautoexport",
packages=find_packages(include=["nbautoexport", "nbautoexport.*"]),
setup_requires=setup_requirements,
test_suite="tests",
tests_require=test_requirements,
project_urls={
"Bug Tracker": "https://github.com/drivendataorg/nbautoexport/issues",
"Documentation": "https://nbautoexport.drivendata.org/",
"Source Code": "https://github.com/drivendataorg/nbautoexport",
},
url="https://github.com/drivendataorg/nbautoexport",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
Expand Down

0 comments on commit 58ab28d

Please sign in to comment.