Skip to content

Commit

Permalink
Merge branch 'dev' into desired-capabilities-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson authored May 21, 2022
2 parents 174ed71 + b59ac20 commit f601775
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ function getMetadata() {
'""', // reserved keywords
path.join(__dirname, 'src', 'components')
],
// To debug `meta-ts.js` using pycharm debugger:
// comment `env` and add `MODULES_PATH=./node_modules`
// in the run config environment variables.
{
env: {MODULES_PATH: path.resolve(__dirname, './node_modules')},
env: {MODULES_PATH: path.resolve(__dirname, './node_modules'), ...process.env},
cwd: __dirname
}
);
Expand Down Expand Up @@ -245,4 +242,9 @@ describe('Test Typescript component metadata generation', () => {
expect(R.path(['StandardComponent'], metadata)).toBeDefined();
});
});
describe('Test namespace props', () => {
test('Component with picked boolean prop', () => {
expect(R.path(['WrappedHTML', "props", "autoFocus", "type", "name"], metadata)).toBe("bool");
})
})
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import {WrappedHTMLProps} from '../props';

/**
* Component docstring
*/
const WrappedHTML = (props: WrappedHTMLProps) => {
return null;
};

export default WrappedHTML;
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import TypeScriptComponent from './components/TypeScriptComponent';
import TypeScriptClassComponent from './components/TypeScriptClassComponent';
import MemoTypeScriptComponent from './components/MemoTypeScriptComponent';
import StandardComponent from './components/StandardComponent.react';
import WrappedHTML from './components/WrappedHTML';

export {
TypeScriptComponent,
TypeScriptClassComponent,
MemoTypeScriptComponent,
StandardComponent
StandardComponent,
WrappedHTML,
};
5 changes: 5 additions & 0 deletions @plotly/dash-generator-test-component-typescript/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ export type TypescriptComponentProps = {
className?: string;
style?: any;
};

export type WrappedHTMLProps = {
children?: React.ReactNode;
id?: string;
} & Pick<React.ButtonHTMLAttributes<any>, 'autoFocus'>
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#2043](https://github.com/plotly/dash/pull/2043) Fix bug
[#2003](https://github.com/plotly/dash/issues/2003) in which
`dangerously_allow_html=True` + `mathjax=True` works in some cases, and in some cases not.
- [#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.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion dash/_callback_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def args_grouping(self):
args_grouping is a dict of the inputs used with flexible callback signatures. The keys are the variable names
and the values are dictionaries containing:
- “id”: (string or dict) the component id. If it’s a pattern matching id, it will be a dict.
- “id_str”: (str) for pattern matching ids, it’s the strigified dict id with no white spaces.
- “id_str”: (str) for pattern matching ids, it’s the stringified dict id with no white spaces.
- “property”: (str) The component property used in the callback.
- “value”: the value of the component property at the time the callback was fired.
- “triggered”: (bool)Whether this input triggered the callback.
Expand Down
5 changes: 4 additions & 1 deletion dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ def run(
host=os.getenv("HOST", "127.0.0.1"),
port=os.getenv("PORT", "8050"),
proxy=os.getenv("DASH_PROXY", None),
debug=False,
debug=None,
dev_tools_ui=None,
dev_tools_props_check=None,
dev_tools_serve_dev_bundles=None,
Expand Down Expand Up @@ -1987,6 +1987,9 @@ def run(
:return:
"""
if debug is None:
debug = get_combined_config("debug", None, False)

debug = self.enable_dev_tools(
debug,
dev_tools_ui,
Expand Down
4 changes: 2 additions & 2 deletions dash/extract-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (!src.length) {
}

if (fs.existsSync('tsconfig.json')) {
tsconfig = JSON.parse(fs.readFileSync('tsconfig.json'));
tsconfig = JSON.parse(fs.readFileSync('tsconfig.json')).compilerOptions;
}

let failedBuild = false;
Expand Down Expand Up @@ -180,7 +180,7 @@ function gatherComponents(sources, components = {}) {
return components;
}

const program = ts.createProgram(filepaths, tsconfig);
const program = ts.createProgram(filepaths, {...tsconfig, esModuleInterop: true});
const checker = program.getTypeChecker();

const coerceValue = t => {
Expand Down
45 changes: 45 additions & 0 deletions tests/unit/test_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,48 @@ def test_app_invalid_delayed_config():
app = Dash(server=False)
with pytest.raises(AttributeError):
app.init_app(app=Flask("test"), name="too late 2 update")


@pytest.mark.parametrize(
"debug_env, debug, expected",
[
(None, None, False),
(None, True, True),
(None, False, False),
('True', None, True),
('True', True, True),
('True', False, False),
('False', None, False),
('False', True, True),
('False', False, False),
],
)
def test_debug_mode_run(empty_environ, debug_env, debug, expected):
if debug_env:
os.environ['DASH_DEBUG'] = debug_env
app = Dash()
with pytest.raises(AssertionError):
app.run(debug=debug, port=-1)
assert app._dev_tools.ui == expected


@pytest.mark.parametrize(
"debug_env, debug, expected",
[
(None, None, True),
(None, True, True),
(None, False, False),
('True', None, True),
('True', True, True),
('True', False, False),
('False', None, False),
('False', True, True),
('False', False, False),
],
)
def test_debug_mode_enable_dev_tools(empty_environ, debug_env, debug, expected):
if debug_env:
os.environ['DASH_DEBUG'] = debug_env
app = Dash()
app.enable_dev_tools(debug=debug)
assert app._dev_tools.ui == expected

0 comments on commit f601775

Please sign in to comment.