Skip to content

Commit f911ff5

Browse files
committed
Linting.
1 parent 7218432 commit f911ff5

10 files changed

Lines changed: 52 additions & 67 deletions

File tree

.pre-commit-config.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repos:
99
hooks:
1010
- id: check-added-large-files
1111
- id: check-ast
12+
- id: fix-byte-order-marker
1213
- id: check-byte-order-marker
1314
- id: check-case-conflict
1415
- id: check-executables-have-shebangs
@@ -19,12 +20,12 @@ repos:
1920
- id: check-symlinks
2021
- id: check-vcs-permalinks
2122
- id: detect-private-key
22-
- id: end-of-file-fixer
2323
- id: trailing-whitespace
2424
- id: mixed-line-ending
25+
- id: end-of-file-fixer
2526

2627
- repo: https://github.com/domdfcoding/pre-commit-hooks
27-
rev: v0.0.4
28+
rev: v0.1.1
2829
hooks:
2930
- id: requirements-txt-sorter
3031
args:
@@ -58,7 +59,16 @@ repos:
5859
- id: forbid-crlf
5960

6061
- repo: https://github.com/domdfcoding/yapf-isort
61-
rev: v0.4.4
62+
rev: v0.5.1
6263
hooks:
6364
- id: yapf-isort
6465
exclude: ^(doc-source/conf|__pkginfo__|make_conda_recipe|setup)\.py$
66+
67+
- repo: https://github.com/domdfcoding/dep_checker
68+
rev: v0.3.1
69+
hooks:
70+
- id: dep_checker
71+
args:
72+
- notebook2script
73+
74+
# Custom hooks can be added below this comment

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file is managed by 'repo_helper'. Don't edit it directly.
22
---
33

4+
os: linux
45
language: python
56
dist: focal
67
cache: pip
@@ -32,7 +33,6 @@ stages:
3233
jobs:
3334
allow_failures:
3435
- arch: arm64
35-
3636
exclude:
3737
- python: '3.7'
3838
arch: arm64
@@ -52,7 +52,7 @@ jobs:
5252
tags: true
5353
repo: domdfcoding/notebook2script
5454
provider: pypi
55-
user: "DomDF"
55+
username: "DomDF"
5656
password:
5757
secure:
5858
distributions: "sdist bdist_wheel"

CONTRIBUTING.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ Install ``pre-commit`` with ``pip`` and install the git hook:
1717
Coding style
1818
--------------
1919

20-
`Yapf <https://github.com/google/yapf>`_ is used for code formatting, and `isort <https://timothycrosley.github.io/isort/>`_ is used to sort imports.
20+
`yapf-isort <https://pypi.org/project/yapf-isort/>`_ is used for code formatting.
2121

22-
``yapf`` and ``isort`` can be run manually via ``pre-commit``:
22+
It can be run manually via ``pre-commit``:
2323

2424
.. code-block:: bash
2525
26-
$ pre-commit run yapf -a
27-
$ pre-commit run isort -a
26+
$ pre-commit run yapf-isort -a
2827
2928
30-
The complete autoformatting suite can be run with ``pre-commit``:
29+
Or, to run the complete autoformatting suite:
3130

3231
.. code-block:: bash
3332

notebook2script/ipynb2py.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@
33
44
Requires nbconvert (pip install nbconvert) and pandoc (apt-get install pandoc)
55
"""
6-
################################################################################
7-
# #
8-
# Copyright (C) 2020 Dominic Davis-Foster #
9-
# #
10-
# This program is free software; you can redistribute it and/or modify #
11-
# it under the terms of the GNU General Public License version 2 as #
12-
# published by the Free Software Foundation. #
13-
# #
14-
# This program is distributed in the hope that it will be useful, #
15-
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17-
# GNU General Public License for more details. #
18-
# #
19-
# You should have received a copy of the GNU General Public License #
20-
# along with this program; if not, write to the Free Software #
21-
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
22-
# #
23-
################################################################################
6+
#
7+
# Copyright © 2020 Dominic Davis-Foster <dominic@davis-foster.co.uk>
8+
#
9+
# This program is free software; you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License version 2
11+
# as published by the Free Software Foundation.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program; if not, write to the Free Software
20+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21+
# MA 02110-1301, USA.
22+
#
2423

2524
# 3rd party
2625
import isort

notebook2script/pointless_checker/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ class BasicChecker(BaseChecker):
7272

7373
@utils.check_messages("pointless-statement", "pointless-string-statement", "expression-not-assigned")
7474
def visit_expr(self, node) -> None:
75-
"""Check for various kind of statements without effect"""
75+
"""
76+
Check for various kinds of statements without effect.
77+
"""
78+
7679
expr = node.value
7780

7881
if isinstance(expr, astroid.Const) and isinstance(expr.value, str):

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
astroid<=2.5,>=2.4.0
2-
domdf_python_tools>=1.0.0
3-
IPython>=7.14.0
2+
domdf-python-tools>=1.0.0
3+
ipython>=7.14.0
4+
isort>=5.5.2
45
nbconvert>=5.6.1
56
pylint>=2.5.2
67
yapf-isort>=0.3.3

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# * options
55
# * options.packages.find
66
# * mypy
7+
# * options.entry_points
78

89
[metadata]
910
name = notebook2script

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
coverage>=5.1
22
coverage-pyver-pragma>=0.0.6
3+
domdf-python-tools[testing]>=1.5.0
34
iniconfig!=1.1.0,>=1.0.1
45
pytest>=6.0.0
56
pytest-cov>=2.8.1

tests/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ def test_cli_backend():
4949
type('3')
5050
# In[11]:
5151
print('3' + '3')
52-
""".split("\n"):
52+
""".split('\n'):
5353
if not re.match(r"^#*\s*$", line):
5454
continue
5555
else:
5656
expected.append(line)
5757

5858
actual = []
5959

60-
for line in outfile.read_text().split("\n"):
60+
for line in outfile.read_text().split('\n'):
6161
if not re.match(r"^#*\s*$", line):
6262
continue
6363
else:

tox.ini

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# * testenv:docs
99
# * testenv:build
1010
# * testenv:lint
11-
# * testenv:yapf
1211
# * testenv:mypy
1312
# * testenv:pyup
1413
# * testenv:coverage
@@ -59,7 +58,7 @@ deps =
5958
check-wheel-contents>=0.1.0
6059
commands =
6160
python -m pep517.build --source --binary "{toxinidir}"
62-
twine check dist/*
61+
twine check dist/*.tar.gz dist/*.whl
6362
check-wheel-contents dist/
6463

6564
[testenv:lint]
@@ -72,7 +71,7 @@ deps =
7271
flake8-2020 >= 1.6.0
7372
flake8-builtins>=1.5.3
7473
flake8-docstrings>=1.5.0
75-
flake8-dunder-all>=0.0.4
74+
flake8-dunder-all>=0.1.1
7675
flake8-pyi>=20.10.0
7776
flake8-pytest-style>=1.3.0
7877
flake8-sphinx-links>=0.0.4
@@ -85,14 +84,6 @@ deps =
8584
pygments>=2.7.1
8685
commands = python3 -m flake8_rst_docstrings_sphinx notebook2script tests --allow-toolbox
8786

88-
[testenv:yapf]
89-
basepython = python3.7
90-
changedir = {toxinidir}
91-
skip_install = True
92-
ignore_errors = True
93-
deps = yapf
94-
commands = yapf -i --recursive notebook2script tests
95-
9687
[testenv:mypy]
9788
basepython = python3.6
9889
ignore_errors = True
@@ -127,7 +118,7 @@ commands =
127118

128119
[flake8]
129120
max-line-length = 120
130-
select = E301 E303 E304 E305 E306 E502 W291 W293 W391 E226 E225 E241 E231 W292 E265 E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E227 E228 E242 E251 E261 E262 E271 E272 E402 E703 E711 E712 E713 E714 E721 W504 E302 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001 PT001 PT002 PT003 PT004 PT005 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q000 Q001 Q002 Q003 A001 A002 A003 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000
121+
select = E301 E303 E304 E305 E306 E502 W291 W293 W391 E226 E225 E241 E231 W292 E265 E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E227 E228 E242 E251 E261 E262 E271 E272 E402 E703 E711 E712 E713 E714 E721 W504 E302 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001 PT001 PT002 PT003 PT005 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q001 Q002 Q003 A001 A002 A003 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000
131122
exclude = .git,__pycache__,doc-source,old,build,dist,make_conda_recipe.py,__pkginfo__.py,setup.py
132123
rst-directives =
133124
TODO
@@ -164,25 +155,5 @@ package = notebook2script
164155
addopts = --color yes --durations 25
165156
timeout = 300
166157
167-
[testenv:bumpversion]
168-
skip_install = true
169-
deps = bump2version
170-
commands = bumpversion --verbose {posargs}
171-
172-
173-
[testenv:isort]
174-
basepython = python3.6
175-
skip_install = true
176-
ignore_errors = true
177-
changedir = {toxinidir}
178-
deps = isort >=5.1.4
179-
commands = isort notebook2script tests
180-
181-
182-
[testenv:qa]
183-
basepython = python3.6
184-
skip_install = True
185-
ignore_errors = true
186-
whitelist_externals = tox
187-
changedir = {toxinidir}
188-
commands = tox -e pyup,isort,yapf,mypy,lint {posargs}
158+
[dep_checker]
159+
allowed_unused = ipython

0 commit comments

Comments
 (0)