-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Props blacklist #753
Props blacklist #753
Conversation
|
||
c1 = Component(id='1') | ||
c2 = Component(id='2', children=[Component()]) | ||
self.assertTrue(c1 == c2) |
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.
Kind of a nice side effect, IMO, that components are now no longer always equal to each other - though I don't know why this would come up...
@@ -487,8 +489,7 @@ def test_iter(self): | |||
|
|||
class TestGenerateClassFile(unittest.TestCase): | |||
def setUp(self): | |||
json_path = os.path.join( | |||
'tests', 'unit', 'dash', 'development', 'metadata_test.json') | |||
json_path = os.path.join(_dir, 'metadata_test.json') |
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.
So that you can run the tests from any working directory, not just the repo root.
} | ||
else { | ||
writeOut(metadata); | ||
} |
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.
we don't write a response if the error was severe enough for us to set failed
- this causes generate_components
to fail as well.
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.
💃 looks great, thanks Alex
Fixes plotly/dash-core-components#440
Pares down the attributes of dash component classes on the Python side by doing two things:
MutableMapping
inheritance - we weren't using any of the mixins from that class anyway, except in tests. This stops setting attributes:clear
,get
,items
,keys
,pop
,popitem
,setdefault
,update
,values
- all of these are now allowable as prop names. We still set the magic methods of the mapping interface.traverse
andtraverse_with_paths
) with underscores, so these are allowable as well.Then what's left we blacklist: during
extract-meta
, if any prop has a leading underscore or matches one of the remaining disallowed names, we fail (not just print a warning) and refuse to generate the python file. The names we forbid are:UNDEFINED
REQUIRED
to_plotly_json
available_properties
available_wildcard_properties
These are all used within generated components, or (in the case of
to_plotly_json
) in other packages, so it would be difficult to allow these without forcing all packages to be rebuilt. Fortunately I don't see these as particularly valuable prop names (unlike, say,values
,items
, and some of the otherMutableMapping
methods)Error messages look like:
CHANGELOG.md