Skip to content

Commit 3384083

Browse files
authored
Merge pull request #919 from krinsman/master
Automatic code formatting
2 parents c0df02f + dda3107 commit 3384083

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2394
-1853
lines changed

.flake8

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[flake8]
2+
# Ignore style and complexity
3+
# E: style errors
4+
# W: style warnings
5+
# F401: module imported but unused
6+
# F811: redefinition of unused `name` from line `N`
7+
# F841: local variable assigned but never used
8+
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
9+
exclude =
10+
helm-chart,
11+
hooks,
12+
setup.py,
13+
statuspage,
14+
versioneer.py

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/asottile/reorder_python_imports
3+
rev: v1.3.5
4+
hooks:
5+
- id: reorder-python-imports
6+
language_version: python3.6
7+
- repo: https://github.com/ambv/black
8+
rev: 18.9b0
9+
hooks:
10+
- id: black
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v2.1.0
13+
hooks:
14+
- id: end-of-file-fixer
15+
- id: check-json
16+
- id: check-yaml
17+
exclude: ^helm-chart/nbviewer/templates/
18+
- id: check-case-conflict
19+
- id: check-executables-have-shebangs
20+
- id: requirements-txt-fixer
21+
- id: flake8

.travis.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,32 @@ install:
1818
- pip install -r requirements.txt
1919
- pip install -e .
2020

21+
# run tests
2122
script:
2223
- invoke test
2324

25+
# list the jobs
26+
jobs:
27+
include:
28+
- name: autoformatting check
29+
python: 3.6
30+
# NOTE: It does not suffice to override to: null, [], or [""]. Travis will
31+
# fall back to the default if we do.
32+
before_install: echo "Do nothing before install."
33+
install: pip install pre-commit
34+
script:
35+
- pre-commit run --all-files
36+
after_success: echo "Do nothing after success."
37+
after_failure:
38+
- |
39+
echo "You can install pre-commit hooks to automatically run formatting"
40+
echo "on each commit with:"
41+
echo " pre-commit install"
42+
echo "or you can run by hand on staged files with"
43+
echo " pre-commit run"
44+
echo "or after-the-fact on already committed files with"
45+
echo " pre-commit run --all-files"
46+
2447
env:
2548
global:
2649
- secure: Sv53YMdsVTin1hUPRqIuvdAOJ0UwklEowW49qpxY9wSgiAM79D+e1b5Yxrn+RTtS3WGlvK1aKHICc+2ajccEJkKFL8WDy2SnTnoWPadrEy4NAGLkNMGK+bAYMnLNoNRbSGVz5JpvNJ7JkeaEplhJ572OJOxa1X7ZF9165ZbOWng=

CONTRIBUTING.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Contributing to NBViewer
2+
3+
4+
Welcome! As a [Jupyter](https://jupyter.org) project,
5+
you can follow the [Jupyter contributor guide](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html).
6+
7+
Make sure to also follow [Project Jupyter's Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md)
8+
for a friendly and welcoming collaborative environment.
9+
10+
## Setting up a development environment
11+
12+
See the instructions for local development or local installation first.
13+
14+
NBViewer has adopted automatic code formatting so you shouldn't
15+
need to worry too much about your code style.
16+
As long as your code is valid,
17+
the pre-commit hook should take care of how it should look. Here is how to set up pre-commit hooks for automatic code formatting, etc.
18+
19+
```bash
20+
pre-commit install
21+
```
22+
23+
You can also invoke the pre-commit hook manually at any time with
24+
25+
```bash
26+
pre-commit run
27+
```
28+
29+
which should run any autoformatting on your code
30+
and tell you about any errors it couldn't fix automatically.
31+
You may also install [black integration](https://github.com/ambv/black#editor-integration)
32+
into your text editor to format code automatically.
33+
34+
If you have already committed files before setting up the pre-commit
35+
hook with `pre-commit install`, you can fix everything up using
36+
`pre-commit run --all-files`. You need to make the fixing commit
37+
yourself after that.
38+
39+
#### Running the Tests
40+
41+
It's a good idea to write tests to exercise any new features,
42+
or that trigger any bugs that you have fixed to catch regressions. `nose` is used to run the test suite. The tests currently make calls to
43+
external APIs such as GitHub, so it is best to use your Github API Token when
44+
running:
45+
46+
```shell
47+
$ cd <path to repo>
48+
$ pip install -r requirements-dev.txt
49+
$ GITHUB_API_TOKEN=<your token> python setup.py test
50+
```
51+
52+
You can run the tests with:
53+
54+
```bash
55+
nosetests -v
56+
```
57+
58+
in the repo directory.

LICENSE.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
3333
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3434
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3535
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36-

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
**[Quick Run](#quick-run)** |
2+
**[GitHub Enterprise](#github-enterprise)** |
3+
**[Base URL](#base-url)** |
4+
**[Local Development](#local-development)** |
5+
**[Contributing](#contributing)** |
6+
**[Extensions](#extending-the-notebook-viewer)** |
7+
**[Configuration](#config-file-and-command-line-configuration)** |
8+
**[Security](#securing-the-notebook-viewer)**
9+
10+
111
# Jupyter Notebook Viewer
212

3-
Jupyter nbviewer is the web application behind
13+
[![Latest PyPI version](https://img.shields.io/pypi/v/nbviewer?logo=pypi)](https://pypi.python.org/pypi/nbviewer)
14+
[![TravisCI build status](https://img.shields.io/travis/jupyter/nbviewer/master?logo=travis)](https://travis-ci.org/jupyter/nbviewer)
15+
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyter/nbviewer/issues)
16+
[![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyter/nbviewer)
17+
18+
Jupyter NBViewer is the web application behind
419
[The Jupyter Notebook Viewer](http://nbviewer.jupyter.org),
520
which is graciously hosted by [OVHcloud](https://ovhcloud.com).
621

@@ -129,17 +144,10 @@ $ python -m nbviewer --debug --no-cache
129144
This will automatically relaunch the server if a change is detected on a python file, and not cache any results. You can then just do the modifications you like to the source code and/or the templates then refresh the pages.
130145

131146

132-
#### Running the Tests
133-
134-
`nose` is used to run the test suite. The tests currently make calls to
135-
external APIs such as GitHub, so it is best to use your Github API Token when
136-
running:
147+
## Contributing
137148

138-
```shell
139-
$ cd <path to repo>
140-
$ pip install -r requirements-dev.txt
141-
$ GITHUB_API_TOKEN=<your token> python setup.py test
142-
```
149+
If you would like to contribute to the project, please read the [`CONTRIBUTING.md`](CONTRIBUTING.md). The `CONTRIBUTING.md` file
150+
explains how to set up a development installation and how to run the test suite.
143151

144152

145153
## Extending the Notebook Viewer

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ nbviewer:
55
ports:
66
- 8080:8080
77
nbcache:
8-
image: memcached
8+
image: memcached

nbviewer/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from ._version import get_versions
2-
__version__ = get_versions()['version']
2+
3+
__version__ = get_versions()["version"]
34
del get_versions

nbviewer/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
from nbviewer.app import main
2+
23
main()

0 commit comments

Comments
 (0)