Skip to content

Commit aa20bd4

Browse files
Git hooks, linting, and other toolchain fixes (#1151)
1 parent 74594b0 commit aa20bd4

Some content is hidden

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

58 files changed

+2595
-2051
lines changed

Diff for: .circleci/config.yml

+9-15
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
docker:
3030
- image: circleci/python:3.7-stretch-node-browsers
3131
environment:
32-
PYLINTRC: .pylintrc37
3332
PYVERSION: python37
3433

3534
steps:
@@ -53,20 +52,13 @@ jobs:
5352
. venv/bin/activate
5453
set -eo pipefail
5554
pip install -e . --progress-bar off && pip list | grep dash
56-
flake8 dash setup.py && flake8 --ignore=E123,E126,E501,E722,E731,F401,F841,W503,W504 --exclude=metadata_test.py tests
57-
pylint dash setup.py --rcfile=$PYLINTRC
58-
pylint tests/unit tests/integration/devtools tests/integration/renderer tests/integration/dash_assets -d all -e C0410,C0411,C0412,C0413,W0109
59-
cd dash-renderer && npm ci
60-
npm run lint:test && npm run format:test
55+
npm install --production && npm run initialize
56+
npm run lint
6157
- run:
62-
name: 🐍 Python Unit Tests
58+
name: 🐍 Python Unit Tests & ☕ JS Unit Tests
6359
command: |
6460
. venv/bin/activate
65-
PYTHONPATH=~/dash/tests/assets pytest tests/unit
66-
- run:
67-
name: ☕ JS Unit Tests
68-
command: |
69-
cd dash-renderer && npm run test:js
61+
npm run test.unit
7062
7163
lint-unit-36:
7264
<<: *lint-unit
@@ -89,6 +81,7 @@ jobs:
8981
docker:
9082
- image: circleci/python:3.7-stretch-node-browsers
9183
environment:
84+
PYLINTRC: .pylintrc37
9285
PYVERSION: python37
9386
steps:
9487
- checkout
@@ -243,7 +236,9 @@ jobs:
243236
- run:
244237
name: ️️🏗️ Install packages
245238
command: |
246-
. venv/bin/activate && cd packages && ls -la
239+
. venv/bin/activate
240+
npm install --production
241+
cd packages && ls -la
247242
find . -name "*.gz" | xargs pip install --no-cache-dir --ignore-installed && cd ..
248243
sed -i '/dash/d' requires-install.txt
249244
pip install --no-cache-dir --ignore-installed .
@@ -252,8 +247,7 @@ jobs:
252247
name: 🧪 Run Integration Tests
253248
command: |
254249
. venv/bin/activate
255-
TESTFILES=$(circleci tests glob "tests/integration/**/test_*.py" | circleci tests split --split-by=timings)
256-
pytest --headless --nopercyfinalize --junitxml=test-reports/junit_intg.xml ${TESTFILES}
250+
npm run test.integration
257251
- store_artifacts:
258252
path: test-reports
259253
- store_test_results:

Diff for: .flake8

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
ignore = C901, E203, E266, E501, E731, W503
3+
select = B,C,E,F,W,T4
4+
per-file-ignores =
5+
tests/*: E722, F811

Diff for: .huskyrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "npm run lint"
4+
}
5+
}

Diff for: .pylintrc

+2-4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ disable=fixme,
6161
old-style-class,
6262
superfluous-parens,
6363
bad-continuation,
64+
line-too-long
6465

6566

6667
# Enable the message, report, category or checker with the given id(s). You can
@@ -223,9 +224,6 @@ indent-after-paren=4
223224
# tab).
224225
indent-string=' '
225226

226-
# Maximum number of characters on a single line.
227-
max-line-length=100
228-
229227
# Maximum number of lines in a module
230228
max-module-lines=1000
231229

@@ -468,4 +466,4 @@ known-third-party=enchant
468466

469467
# Exceptions that will emit a warning when being caught. Defaults to
470468
# "Exception"
471-
overgeneral-exceptions=Exception
469+
overgeneral-exceptions=Exception

Diff for: .pylintrc37

+3-5
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ disable=invalid-name,
148148
possibly-unused-variable,
149149
too-many-lines,
150150
too-many-statements,
151-
bad-continuation
151+
bad-continuation,
152+
line-too-long
152153

153154
# Enable the message, report, category or checker with the given id(s). You can
154155
# either give multiple identifier separated by comma (,) or put this option
@@ -318,9 +319,6 @@ indent-after-paren=4
318319
# tab).
319320
indent-string=' '
320321

321-
# Maximum number of characters on a single line.
322-
max-line-length=100
323-
324322
# Maximum number of lines in a module.
325323
max-module-lines=1000
326324

@@ -567,4 +565,4 @@ known-third-party=enchant
567565

568566
# Exceptions that will emit a warning when being caught. Defaults to
569567
# "Exception".
570-
overgeneral-exceptions=Exception
568+
overgeneral-exceptions=Exception

Diff for: dash-renderer/package-lock.json

+164
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dash-renderer/package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
"description": "render dash components in react",
55
"main": "dash_renderer/dash_renderer.min.js",
66
"scripts": {
7-
"lint": "./node_modules/.bin/eslint --quiet --fix .",
8-
"lint:test": "./node_modules/.bin/eslint .",
7+
"private::format.js-eslint": "eslint --quiet --fix .",
8+
"private::format.js-prettier": "prettier --config .prettierrc --write \"src/**/*.js\"",
9+
"private::lint.js-eslint": "eslint .",
10+
"private::lint.js-prettier": "prettier --config .prettierrc \"src/**/*.js\" --list-different",
911
"build:js": "webpack --build release",
1012
"build:dev": "webpack --build local",
1113
"build:local": "renderer build local",
1214
"build": "renderer build",
1315
"postbuild": "es-check es5 dash_renderer/*.js",
1416
"start": "webpack-serve ./webpack.serve.config.js",
15-
"format": "prettier --config .prettierrc --write \"src/**/*.js\"",
16-
"format:test": "prettier --config .prettierrc \"src/**/*.js\" --list-different",
17-
"test": "npm run lint",
18-
"test:js": "jest"
17+
"test": "jest",
18+
"format": "run-s private::format.*",
19+
"lint": "run-s private::lint.*"
1920
},
2021
"author": "chriddyp",
2122
"license": "MIT",

Diff for: dash/_callback_context.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ def has_context(func):
99
def assert_context(*args, **kwargs):
1010
if not flask.has_request_context():
1111
raise exceptions.MissingCallbackContextException(
12-
(
13-
'dash.callback_context.{} '
14-
'is only available from a callback!'
15-
).format(getattr(func, '__name__'))
12+
("dash.callback_context.{} is only available from a callback!").format(
13+
getattr(func, "__name__")
14+
)
1615
)
1716
return func(*args, **kwargs)
17+
1818
return assert_context
1919

2020

@@ -23,19 +23,19 @@ class CallbackContext:
2323
@property
2424
@has_context
2525
def inputs(self):
26-
return getattr(flask.g, 'input_values', {})
26+
return getattr(flask.g, "input_values", {})
2727

2828
@property
2929
@has_context
3030
def states(self):
31-
return getattr(flask.g, 'state_values', {})
31+
return getattr(flask.g, "state_values", {})
3232

3333
@property
3434
@has_context
3535
def triggered(self):
36-
return getattr(flask.g, 'triggered_inputs', [])
36+
return getattr(flask.g, "triggered_inputs", [])
3737

3838
@property
3939
@has_context
4040
def response(self):
41-
return getattr(flask.g, 'dash_response')
41+
return getattr(flask.g, "dash_response")

0 commit comments

Comments
 (0)