-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Issue 480 - Add .map file extension support to dash #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
6e8cbb7
d02047c
e9adb52
656e24d
481d15f
2f39135
191b34b
c4f4c49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,15 +378,27 @@ def _relative_url_path(relative_package_path='', namespace=''): | |
|
||
srcs = [] | ||
for resource in resources: | ||
is_dynamic_resource = ( | ||
'dynamic' in resource and | ||
resource['dynamic'] is True | ||
) | ||
|
||
if 'relative_package_path' in resource: | ||
if isinstance(resource['relative_package_path'], str): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternate way might solve the too-many-branches 🐫
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure.. I'm in, if only because it makes me learn the language haha! |
||
srcs.append(_relative_url_path(**resource)) | ||
path = _relative_url_path( | ||
resource['relative_package_path'], | ||
resource['namespace'] | ||
) | ||
if not is_dynamic_resource: | ||
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
srcs.append(path) | ||
else: | ||
for rel_path in resource['relative_package_path']: | ||
srcs.append(_relative_url_path( | ||
path = _relative_url_path( | ||
relative_package_path=rel_path, | ||
namespace=resource['namespace'] | ||
)) | ||
) | ||
if not is_dynamic_resource: | ||
srcs.append(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here.. |
||
elif 'external_url' in resource: | ||
if isinstance(resource['external_url'], str): | ||
srcs.append(resource['external_url']) | ||
|
@@ -492,7 +504,8 @@ def serve_component_suites(self, package_name, path_in_package_dist): | |
|
||
mimetype = ({ | ||
'js': 'application/JavaScript', | ||
'css': 'text/css' | ||
'css': 'text/css', | ||
'map': 'application/json' | ||
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
})[path_in_package_dist.split('.')[-1]] | ||
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
headers = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ def _filter_resources(self, all_resources, dev_bundles=False): | |
filtered_resources = [] | ||
for s in all_resources: | ||
filtered_resource = {} | ||
if 'dynamic' in s: | ||
filtered_resource['dynamic'] = s['dynamic'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if 'namespace' in s: | ||
filtered_resource['namespace'] = s['namespace'] | ||
if 'external_url' in s and not self.config.serve_locally: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.31.1' | ||
__version__ = '0.31.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the preferred indentation pattern is for Python -- went with something that seemed natural with the syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
()
and single line, we prefer explicit:if 'dynamic' in resources and resource.get('dynamic')
. Also.get
over[key]
to avoid unnecessary KeyErrors. Only useis
for comparing pointer references, ieis None
to assert null and not just falsy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this because the line is too long for flake8's taste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I one line this and make flake8 happy? Apart from an actual function, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break them using
\
at the end of the line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the same error from pylint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And now this.. dash/dash.py:355:4: R0912: Too many branches (13/12) (too-many-branches
I guess the additional
if
triggered this rule.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer
if cond
tois True
,is True
is when you need to assert that it the actualTrue
and not another type that evaluate to True in a condition like a string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! Misread! No need for the explicit comparison... all good haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
# pylint: disable=too-many-branches
to the start of the function.