Skip to content

Commit d9b8d17

Browse files
authored
Merge pull request #2635 from plotly/optim/refact
Refactors
2 parents 6eaf2e1 + 8ae9488 commit d9b8d17

28 files changed

+923
-702
lines changed

Diff for: .circleci/config.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
orbs:
44
win: circleci/[email protected]
55
percy: percy/[email protected]
6-
browser-tools: circleci/[email protected].3
6+
browser-tools: circleci/[email protected].6
77

88
jobs:
99
artifacts:
@@ -102,11 +102,13 @@ jobs:
102102

103103
steps:
104104
- checkout
105+
- run: sudo apt-get update
105106
- run: echo $PYVERSION > ver.txt
106107
- run: cat requires-*.txt > requires-all.txt
107108
- restore_cache:
108109
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
109-
- browser-tools/install-browser-tools
110+
- browser-tools/install-browser-tools:
111+
chrome-version: 116.0.5845.110
110112
- run:
111113
name: ️️🏗️ pip dev requirements
112114
command: |
@@ -176,11 +178,13 @@ jobs:
176178
steps:
177179
- checkout:
178180
path: ~/dash
181+
- run: sudo apt-get update
179182
- run: echo $PYVERSION > ver.txt
180183
- run: cat requires-*.txt > requires-all.txt
181184
- restore_cache:
182185
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
183186
- browser-tools/install-browser-tools:
187+
chrome-version: 116.0.5845.110
184188
install-firefox: false
185189
install-geckodriver: false
186190
- attach_workspace:
@@ -291,11 +295,13 @@ jobs:
291295
steps:
292296
- checkout:
293297
path: ~/dash
298+
- run: sudo apt-get update
294299
- run: echo $PYVERSION > ver.txt
295300
- run: cat requires-*.txt > requires-all.txt
296301
- restore_cache:
297302
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
298303
- browser-tools/install-browser-tools:
304+
chrome-version: 116.0.5845.110
299305
install-firefox: false
300306
install-geckodriver: false
301307
- attach_workspace:
@@ -358,13 +364,15 @@ jobs:
358364
steps:
359365
- checkout:
360366
path: ~/dash
367+
- run: sudo apt-get update
361368
- run: echo $PYVERSION > ver.txt
362369
- run: cat requires-*.txt > requires-all.txt
363370
- restore_cache:
364371
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
365372
- restore_cache:
366373
key: html-{{ checksum "components/dash-html-components/package.json" }}-{{ checksum "components/dash-html-components/package-lock.json" }}
367374
- browser-tools/install-browser-tools:
375+
chrome-version: 116.0.5845.110
368376
install-firefox: false
369377
install-geckodriver: false
370378
- attach_workspace:
@@ -432,11 +440,13 @@ jobs:
432440
steps:
433441
- checkout:
434442
path: ~/dash
443+
- run: sudo apt-get update
435444
- run: echo $PYVERSION > ver.txt
436445
- run: cat requires-*.txt > requires-all.txt
437446
- restore_cache:
438447
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
439448
- browser-tools/install-browser-tools:
449+
chrome-version: 116.0.5845.110
440450
install-firefox: false
441451
install-geckodriver: false
442452
- attach_workspace:
@@ -484,13 +494,15 @@ jobs:
484494
steps:
485495
- checkout:
486496
path: ~/dash
497+
- run: sudo apt-get update
487498
- run: echo $PYVERSION > ver.txt
488499
- run: cat requires-*.txt > requires-all.txt
489500
- restore_cache:
490501
key: dep-{{ checksum ".circleci/config.yml" }}-{{ checksum "ver.txt" }}-{{ checksum "requires-all.txt" }}
491502
- restore_cache:
492503
key: table-{{ checksum "components/dash-table/package.json" }}-{{ checksum "components/dash-table/package-lock.json" }}
493504
- browser-tools/install-browser-tools:
505+
chrome-version: 116.0.5845.110
494506
install-firefox: false
495507
install-geckodriver: false
496508
- attach_workspace:
@@ -524,9 +536,11 @@ jobs:
524536
steps:
525537
- checkout:
526538
path: ~/dash
539+
- run: sudo apt-get update
527540
- restore_cache:
528541
key: dep-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "package.json" }}
529542
- browser-tools/install-browser-tools:
543+
chrome-version: 116.0.5845.110
530544
install-firefox: false
531545
install-geckodriver: false
532546
- run:

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
88

99
- [#2634](https://github.com/plotly/dash/pull/2634) Fix deprecation warning on pkg_resources, fix [#2631](https://github.com/plotly/dash/issues/2631)
1010

11+
## Changed
12+
13+
- [#2635](https://github.com/plotly/dash/pull/2635) Get proper app module name, remove need to give `__name__` to Dash constructor.
14+
1115
## [2.13.0] 2023-08-28
1216
## Changed
1317

Diff for: components/dash-core-components/src/components/Input.react.js

+26-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {isNil, omit} from 'ramda';
1+
import {isNil, pick} from 'ramda';
22
import React, {PureComponent} from 'react';
33
import PropTypes from 'prop-types';
44
import isNumeric from 'fast-isnumeric';
@@ -9,6 +9,30 @@ const convert = val => (isNumeric(val) ? +val : NaN);
99

1010
const isEquivalent = (v1, v2) => v1 === v2 || (isNaN(v1) && isNaN(v2));
1111

12+
const inputProps = [
13+
'type',
14+
'placeholder',
15+
'inputMode',
16+
'autoComplete',
17+
'readOnly',
18+
'required',
19+
'autoFocus',
20+
'disabled',
21+
'list',
22+
'multiple',
23+
'spellCheck',
24+
'name',
25+
'min',
26+
'max',
27+
'step',
28+
'minLength',
29+
'maxLength',
30+
'pattern',
31+
'size',
32+
'style',
33+
'id',
34+
];
35+
1236
/**
1337
* A basic HTML input control for entering text, numbers, or passwords.
1438
*
@@ -84,23 +108,7 @@ export default class Input extends PureComponent {
84108
onChange={this.onChange}
85109
onKeyPress={this.onKeyPress}
86110
{...valprops}
87-
{...omit(
88-
[
89-
'className',
90-
'debounce',
91-
'value',
92-
'n_blur',
93-
'n_blur_timestamp',
94-
'n_submit',
95-
'n_submit_timestamp',
96-
'selectionDirection',
97-
'selectionEnd',
98-
'selectionStart',
99-
'setProps',
100-
'loading_state',
101-
],
102-
this.props
103-
)}
111+
{...pick(inputProps, this.props)}
104112
/>
105113
);
106114
}

Diff for: components/dash-core-components/src/components/Textarea.react.js

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
3-
import {omit} from 'ramda';
3+
import {pick} from 'ramda';
4+
5+
const textAreaProps = [
6+
'id',
7+
'autoFocus',
8+
'cols',
9+
'disabled',
10+
'form',
11+
'maxLength',
12+
'minLength',
13+
'name',
14+
'placeholder',
15+
'readOnly',
16+
'required',
17+
'rows',
18+
'wrap',
19+
'accessKey',
20+
'className',
21+
'contentEditable',
22+
'contextMenu',
23+
'dir',
24+
'draggable',
25+
'hidden',
26+
'lang',
27+
'spellCheck',
28+
'style',
29+
'tabIndex',
30+
'title',
31+
];
432

533
/**
634
* A basic HTML textarea for entering multiline text.
@@ -31,7 +59,7 @@ export default class Textarea extends Component {
3159
n_clicks_timestamp: Date.now(),
3260
});
3361
}}
34-
{...omit(['setProps', 'value'], this.props)}
62+
{...pick(textAreaProps, this.props)}
3563
/>
3664
);
3765
}

Diff for: components/dash-core-components/src/fragments/RangeSlider.react.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {Component} from 'react';
2-
import {assoc, omit, isNil} from 'ramda';
2+
import {assoc, pick, isNil} from 'ramda';
33
import {Range, createSliderWithTooltip} from 'rc-slider';
44
import computeSliderStyle from '../utils/computeSliderStyle';
55

@@ -12,6 +12,20 @@ import {
1212
} from '../utils/computeSliderMarkers';
1313
import {propTypes, defaultProps} from '../components/RangeSlider.react';
1414

15+
const sliderProps = [
16+
'min',
17+
'max',
18+
'allowCross',
19+
'pushable',
20+
'disabled',
21+
'count',
22+
'dots',
23+
'included',
24+
'tooltip',
25+
'vertical',
26+
'id',
27+
];
28+
1529
export default class RangeSlider extends Component {
1630
constructor(props) {
1731
super(props);
@@ -112,19 +126,7 @@ export default class RangeSlider extends Component {
112126
? null
113127
: calcStep(min, max, step)
114128
}
115-
{...omit(
116-
[
117-
'className',
118-
'value',
119-
'drag_value',
120-
'setProps',
121-
'marks',
122-
'updatemode',
123-
'verticalHeight',
124-
'step',
125-
],
126-
this.props
127-
)}
129+
{...pick(sliderProps, this.props)}
128130
/>
129131
</div>
130132
);

Diff for: components/dash-core-components/src/fragments/Slider.react.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
22
import ReactSlider, {createSliderWithTooltip} from 'rc-slider';
3-
import {assoc, isNil, omit} from 'ramda';
3+
import {assoc, isNil, pick} from 'ramda';
44
import computeSliderStyle from '../utils/computeSliderStyle';
55

66
import 'rc-slider/assets/index.css';
@@ -12,6 +12,17 @@ import {
1212
} from '../utils/computeSliderMarkers';
1313
import {propTypes, defaultProps} from '../components/Slider.react';
1414

15+
const sliderProps = [
16+
'min',
17+
'max',
18+
'disabled',
19+
'dots',
20+
'included',
21+
'tooltip',
22+
'vertical',
23+
'id',
24+
];
25+
1526
/**
1627
* A slider component with a single handle.
1728
*/
@@ -115,19 +126,7 @@ export default class Slider extends Component {
115126
? null
116127
: calcStep(min, max, step)
117128
}
118-
{...omit(
119-
[
120-
'className',
121-
'setProps',
122-
'updatemode',
123-
'value',
124-
'drag_value',
125-
'marks',
126-
'verticalHeight',
127-
'step',
128-
],
129-
this.props
130-
)}
129+
{...pick(sliderProps, this.props)}
131130
/>
132131
</div>
133132
);

Diff for: dash/_utils.py

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import json
1111
import secrets
1212
import string
13+
import inspect
1314
from html import escape
1415
from functools import wraps
1516
from typing import Union
@@ -281,3 +282,12 @@ def hooks_to_js_object(hooks: Union[RendererHooks, None]) -> str:
281282

282283
def parse_version(version):
283284
return tuple(int(s) for s in version.split("."))
285+
286+
287+
def get_caller_name(name: str):
288+
stack = inspect.stack()
289+
for s in stack:
290+
for code in s.code_context:
291+
if f"{name}(" in code:
292+
return s.frame.f_locals.get("__name__", "__main__")
293+
return "__main__"

0 commit comments

Comments
 (0)