Skip to content

Commit 9877235

Browse files
committed
Linting updates
1 parent b52f1e4 commit 9877235

13 files changed

+49
-37
lines changed

.flake8

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

.pylintrc

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ ignore=CVS
1313
# regex matches against base names, not paths.
1414
ignore-patterns=
1515

16+
# Add files or directories matching the regex patterns to the ignore-list.
17+
# The regex matches against paths.
18+
ignore-paths=^dash/dcc/.*$,
19+
^dash/html/.*$,
20+
^dash/dash_table/.*$
21+
1622
# Python code to execute, usually for sys.path manipulation such as
1723
# pygtk.require().
1824
#init-hook=

.pylintrc39

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ ignore=CVS
1313
# regex matches against base names, not paths.
1414
ignore-patterns=
1515

16+
# Add files or directories matching the regex patterns to the ignore-list.
17+
# The regex matches against paths.
18+
ignore-paths=^dash/dcc/.*$,
19+
^dash/html/.*$,
20+
^dash/dash_table/.*$
21+
1622
# Python code to execute, usually for sys.path manipulation such as
1723
# pygtk.require().
1824
#init-hook=

dash/_utils.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import io
1111
import json
1212
from functools import wraps
13-
import future.utils as utils
13+
from future import utils
1414
from . import exceptions
1515

1616
logger = logging.getLogger()
@@ -217,16 +217,16 @@ def inputs_to_vals(inputs):
217217

218218
def run_command_with_process(cmd):
219219
is_win = sys.platform == "win32"
220-
proc = subprocess.Popen(shlex.split(cmd, posix=is_win), shell=is_win)
221-
proc.wait()
222-
if proc.poll() is None:
223-
logger.warning("🚨 trying to terminate subprocess in safe way")
224-
try:
225-
proc.communicate()
226-
except Exception: # pylint: disable=broad-except
227-
logger.exception("🚨 first try communicate failed")
228-
proc.kill()
229-
proc.communicate()
220+
with subprocess.Popen(shlex.split(cmd, posix=is_win), shell=is_win) as proc:
221+
proc.wait()
222+
if proc.poll() is None:
223+
logger.warning("🚨 trying to terminate subprocess in safe way")
224+
try:
225+
proc.communicate()
226+
except Exception: # pylint: disable=broad-except
227+
logger.exception("🚨 first try communicate failed")
228+
proc.kill()
229+
proc.communicate()
230230

231231

232232
def compute_md5(path):

dash/dash.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def _collect_and_register_resources(self, resources):
583583
# add the version number of the package as a query parameter
584584
# for cache busting
585585
def _relative_url_path(relative_package_path="", namespace=""):
586-
if any(x in relative_package_path for x in ["dcc" "html", "dash_table"]):
586+
if any(x in relative_package_path for x in ["dcc", "html", "dash_table"]):
587587
relative_package_path = relative_package_path.replace("dash.", "")
588588
version = importlib.import_module(
589589
"{}.{}".format(namespace, os.path.split(relative_package_path)[0])

dash/development/base_component.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, **kwargs):
8383
for k, v in list(kwargs.items()):
8484
# pylint: disable=no-member
8585
k_in_propnames = k in self._prop_names
86-
k_in_wildcards = any(
86+
k_in_wildcards = any( # pylint: disable=use-a-generator
8787
[k.startswith(w) for w in self._valid_wildcard_attributes]
8888
)
8989
# e.g. "The dash_core_components.Dropdown component (version 1.6.0)

dash/development/component_generator.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def generate_components(
7272
"package.json", os.path.join(project_shortname, package_info_filename)
7373
)
7474

75-
proc = subprocess.Popen(
75+
with subprocess.Popen(
7676
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=is_windows
77-
)
78-
out, err = proc.communicate()
79-
status = proc.poll()
77+
) as proc:
78+
out, err = proc.communicate()
79+
status = proc.poll()
8080

8181
if err:
8282
print(err.decode(), file=sys.stderr)

dash/development/update_components.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def booststrap_components(components_source):
2828
"npx lerna bootstrap --scope *@({})*".format(source_glob), posix=not is_windows,
2929
)
3030

31-
proc = subprocess.Popen(
31+
with subprocess.Popen(
3232
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=is_windows
33-
)
34-
out, err = proc.communicate()
35-
status = proc.poll()
33+
) as proc:
34+
out, err = proc.communicate()
35+
status = proc.poll()
3636

3737
if err:
3838
print(err.decode(), file=sys.stderr)
@@ -44,7 +44,7 @@ def booststrap_components(components_source):
4444
),
4545
file=sys.stderr,
4646
)
47-
else:
47+
if not out:
4848
print(
4949
"Failed bootstrapping the following component packages {} (status={})".format(
5050
source_glob, status
@@ -68,11 +68,11 @@ def build_components(components_source):
6868
posix=not is_windows,
6969
)
7070

71-
proc = subprocess.Popen(
71+
with subprocess.Popen(
7272
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=is_windows
73-
)
74-
out, err = proc.communicate()
75-
status = proc.poll()
73+
) as proc:
74+
out, err = proc.communicate()
75+
status = proc.poll()
7676

7777
if err:
7878
print(err.decode(), file=sys.stderr)

dash/testing/application_runners.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import inspect
1212

1313
import runpy
14-
import future.utils as utils
1514
import flask
1615
import requests
1716

17+
from future import utils
1818
from dash.testing.errors import NoAppFoundError, TestingTimeoutError, ServerCloseError
19-
import dash.testing.wait as wait
19+
from dash.testing import wait
2020

2121

2222
logger = logging.getLogger(__name__)
@@ -202,7 +202,7 @@ def start(
202202
logger.debug("start dash process with %s", args)
203203

204204
try:
205-
self.proc = subprocess.Popen(
205+
self.proc = subprocess.Popen( # pylint: disable=consider-using-with
206206
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE
207207
)
208208
# wait until server is able to answer http request
@@ -323,7 +323,7 @@ def start(self, app, start_timeout=2, cwd=None):
323323
logger.debug("start dash process with %s", args)
324324

325325
try:
326-
self.proc = subprocess.Popen(
326+
self.proc = subprocess.Popen( # pylint: disable=consider-using-with
327327
args,
328328
stdout=subprocess.PIPE,
329329
stderr=subprocess.PIPE,
@@ -423,7 +423,7 @@ def start(self, app, start_timeout=30, cwd=None):
423423
logger.debug("start Dash.jl process with %s", args)
424424

425425
try:
426-
self.proc = subprocess.Popen(
426+
self.proc = subprocess.Popen( # pylint: disable=consider-using-with
427427
args,
428428
stdout=subprocess.PIPE,
429429
stderr=subprocess.PIPE,

dash/testing/browser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def get_webdriver(self):
412412
try:
413413
return getattr(self, "_get_{}".format(self._browser))()
414414
except WebDriverException:
415-
logger.exception("<<<Webdriver not initialized correctly>>>")
415+
return logger.exception("<<<Webdriver not initialized correctly>>>")
416416

417417
def _get_wd_options(self):
418418
options = (

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"private::format.renderer": "cd dash/dash-renderer && npm run format",
77
"private::initialize.renderer": "cd dash/dash-renderer && npm ci",
88
"private::lint.black": "if [ ${PYLINTRC:-x} != '.pylintrc' ]; then black dash tests --exclude metadata_test.py --check; fi",
9-
"private::lint.flake8": "flake8 --exclude=metadata_test.py dash tests",
9+
"private::lint.flake8": "flake8 --exclude=metadata_test.py,dash/html/I.py dash tests",
1010
"private::lint.pylint-dash": "PYLINTRC=${PYLINTRC:=.pylintrc39} && pylint dash setup.py --rcfile=$PYLINTRC",
1111
"private::lint.pylint-tests": "PYLINTRC=${PYLINTRC:=.pylintrc39} && pylint tests/unit tests/integration -d all --rcfile=$PYLINTRC",
1212
"private::lint.renderer": "cd dash/dash-renderer && npm run lint",

requires-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mock==3.0.5;python_version=="2.7"
66
flake8==3.8.4
77
PyYAML==5.3.1
88
pylint==1.9.5;python_version<"3.7"
9-
pylint==2.6.0;python_version>="3.7"
9+
pylint==2.9.3;python_version>="3.7"
1010
astroid==2.4.2;python_version>="3.7"
1111
black==19.10b0;python_version>="3.0"
1212
virtualenv==20.2.2;python_version=="2.7"

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from setuptools import setup, find_packages
33

44
main_ns = {}
5-
exec(open("dash/version.py").read(), main_ns) # pylint: disable=exec-used
5+
exec(open("dash/version.py").read(), main_ns) # pylint: disable=exec-used, consider-using-with
66

77

88
def read_req_file(req_type):
@@ -23,7 +23,7 @@ def read_req_file(req_type):
2323
"A Python framework for building reactive web-apps. "
2424
"Developed by Plotly."
2525
),
26-
long_description=io.open("README.md", encoding="utf-8").read(),
26+
long_description=io.open("README.md", encoding="utf-8").read(), # pylint: disable=consider-using-with
2727
long_description_content_type="text/markdown",
2828
install_requires=read_req_file("install"),
2929
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*",

0 commit comments

Comments
 (0)