Skip to content

Commit f601775

Browse files
authored
Merge branch 'dev' into desired-capabilities-deprecation
2 parents 174ed71 + b59ac20 commit f601775

File tree

9 files changed

+78
-9
lines changed

9 files changed

+78
-9
lines changed

@plotly/dash-generator-test-component-typescript/generator.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ function getMetadata() {
1212
'""', // reserved keywords
1313
path.join(__dirname, 'src', 'components')
1414
],
15-
// To debug `meta-ts.js` using pycharm debugger:
16-
// comment `env` and add `MODULES_PATH=./node_modules`
17-
// in the run config environment variables.
1815
{
19-
env: {MODULES_PATH: path.resolve(__dirname, './node_modules')},
16+
env: {MODULES_PATH: path.resolve(__dirname, './node_modules'), ...process.env},
2017
cwd: __dirname
2118
}
2219
);
@@ -245,4 +242,9 @@ describe('Test Typescript component metadata generation', () => {
245242
expect(R.path(['StandardComponent'], metadata)).toBeDefined();
246243
});
247244
});
245+
describe('Test namespace props', () => {
246+
test('Component with picked boolean prop', () => {
247+
expect(R.path(['WrappedHTML', "props", "autoFocus", "type", "name"], metadata)).toBe("bool");
248+
})
249+
})
248250
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import {WrappedHTMLProps} from '../props';
3+
4+
/**
5+
* Component docstring
6+
*/
7+
const WrappedHTML = (props: WrappedHTMLProps) => {
8+
return null;
9+
};
10+
11+
export default WrappedHTML;

@plotly/dash-generator-test-component-typescript/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import TypeScriptComponent from './components/TypeScriptComponent';
22
import TypeScriptClassComponent from './components/TypeScriptClassComponent';
33
import MemoTypeScriptComponent from './components/MemoTypeScriptComponent';
44
import StandardComponent from './components/StandardComponent.react';
5+
import WrappedHTML from './components/WrappedHTML';
56

67
export {
78
TypeScriptComponent,
89
TypeScriptClassComponent,
910
MemoTypeScriptComponent,
10-
StandardComponent
11+
StandardComponent,
12+
WrappedHTML,
1113
};

@plotly/dash-generator-test-component-typescript/src/props.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ export type TypescriptComponentProps = {
3636
className?: string;
3737
style?: any;
3838
};
39+
40+
export type WrappedHTMLProps = {
41+
children?: React.ReactNode;
42+
id?: string;
43+
} & Pick<React.ButtonHTMLAttributes<any>, 'autoFocus'>

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
99
- [#2043](https://github.com/plotly/dash/pull/2043) Fix bug
1010
[#2003](https://github.com/plotly/dash/issues/2003) in which
1111
`dangerously_allow_html=True` + `mathjax=True` works in some cases, and in some cases not.
12+
- [#2047](https://github.com/plotly/dash/pull/2047) Fix bug [#1979](https://github.com/plotly/dash/issues/1979) in which `DASH_DEBUG` as enviroment variable gets ignored.
1213

1314
### Changed
1415

dash/_callback_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def args_grouping(self):
127127
args_grouping is a dict of the inputs used with flexible callback signatures. The keys are the variable names
128128
and the values are dictionaries containing:
129129
- “id”: (string or dict) the component id. If it’s a pattern matching id, it will be a dict.
130-
- “id_str”: (str) for pattern matching ids, it’s the strigified dict id with no white spaces.
130+
- “id_str”: (str) for pattern matching ids, it’s the stringified dict id with no white spaces.
131131
- “property”: (str) The component property used in the callback.
132132
- “value”: the value of the component property at the time the callback was fired.
133133
- “triggered”: (bool)Whether this input triggered the callback.

dash/dash.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ def run(
18961896
host=os.getenv("HOST", "127.0.0.1"),
18971897
port=os.getenv("PORT", "8050"),
18981898
proxy=os.getenv("DASH_PROXY", None),
1899-
debug=False,
1899+
debug=None,
19001900
dev_tools_ui=None,
19011901
dev_tools_props_check=None,
19021902
dev_tools_serve_dev_bundles=None,
@@ -1987,6 +1987,9 @@ def run(
19871987
19881988
:return:
19891989
"""
1990+
if debug is None:
1991+
debug = get_combined_config("debug", None, False)
1992+
19901993
debug = self.enable_dev_tools(
19911994
debug,
19921995
dev_tools_ui,

dash/extract-meta.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (!src.length) {
3737
}
3838

3939
if (fs.existsSync('tsconfig.json')) {
40-
tsconfig = JSON.parse(fs.readFileSync('tsconfig.json'));
40+
tsconfig = JSON.parse(fs.readFileSync('tsconfig.json')).compilerOptions;
4141
}
4242

4343
let failedBuild = false;
@@ -180,7 +180,7 @@ function gatherComponents(sources, components = {}) {
180180
return components;
181181
}
182182

183-
const program = ts.createProgram(filepaths, tsconfig);
183+
const program = ts.createProgram(filepaths, {...tsconfig, esModuleInterop: true});
184184
const checker = program.getTypeChecker();
185185

186186
const coerceValue = t => {

tests/unit/test_configs.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,48 @@ def test_app_invalid_delayed_config():
437437
app = Dash(server=False)
438438
with pytest.raises(AttributeError):
439439
app.init_app(app=Flask("test"), name="too late 2 update")
440+
441+
442+
@pytest.mark.parametrize(
443+
"debug_env, debug, expected",
444+
[
445+
(None, None, False),
446+
(None, True, True),
447+
(None, False, False),
448+
('True', None, True),
449+
('True', True, True),
450+
('True', False, False),
451+
('False', None, False),
452+
('False', True, True),
453+
('False', False, False),
454+
],
455+
)
456+
def test_debug_mode_run(empty_environ, debug_env, debug, expected):
457+
if debug_env:
458+
os.environ['DASH_DEBUG'] = debug_env
459+
app = Dash()
460+
with pytest.raises(AssertionError):
461+
app.run(debug=debug, port=-1)
462+
assert app._dev_tools.ui == expected
463+
464+
465+
@pytest.mark.parametrize(
466+
"debug_env, debug, expected",
467+
[
468+
(None, None, True),
469+
(None, True, True),
470+
(None, False, False),
471+
('True', None, True),
472+
('True', True, True),
473+
('True', False, False),
474+
('False', None, False),
475+
('False', True, True),
476+
('False', False, False),
477+
],
478+
)
479+
def test_debug_mode_enable_dev_tools(empty_environ, debug_env, debug, expected):
480+
if debug_env:
481+
os.environ['DASH_DEBUG'] = debug_env
482+
app = Dash()
483+
app.enable_dev_tools(debug=debug)
484+
assert app._dev_tools.ui == expected

0 commit comments

Comments
 (0)