inspect should skip properties that begin with $
See original GitHub issueOpal (Ruby to JavaScript transpiler) adds special properties to all objects which introduce a circular graph. For example:
require('opal-runtime')
const a = []
console.log(a['$class']['$class']['$class']['$class']['$class']['$class'])
When inspect encounters one of these objects, it enters an infinite recursion and hangs.
inspect should skip properties on an object that begin with $
. If not the default, it should provide a configuration switch to activate this filtering.
You could debate that Opal should not be adding properties that are accessible via (for name in obj)
. The problem is, the Opal creators don’t agree, and that leaves us all that use it with test suites that hang on failures.
Here’s the proposed change to getEnumerableProperties.js.
module.exports = function getEnumerableProperties(object) {
var result = [];
for (var name in object) {
if (!name.startsWith('$')) result.push(name);
}
return result;
};
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
python inspect get methods decorated with @property
For now I am doing methods = inspect.getmembers(cls[1], lambda x: inspect.ismethod(x) or isinstance(x, property)) I am also curious if there ...
Read more >Auto-property can be made get-only (non-private accessibility)
You can suppress this inspection to ignore specific issues, change its severity level to make the issues less or more noticeable, or disable...
Read more >10 Reasons You Shouldn't Skip A Home Inspection
4. Protection. Home inspections are even more critical if you are buying an "as-is" foreclosed property or short sale. Dwellings that have been...
Read more >Properties in C# | Microsoft Learn
Learn about C# properties, which include features for validation, computed values, lazy evaluation, and property changed notifications.
Read more >Open Chrome DevTools
To inspect, right-click an element on a page and select Inspect. The Inspect option in a drop-down menu in Chrome. DevTools opens the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s fine. In fact, the discussion prompted a change in Opal itself. Opal is now going to define properties using the defineProperty mechanism (with enumerable set to false), which will exclude them from being picked up by for…in. See https://github.com/opal/opal/commit/34f89df1d700be5143b9dbcc9886202fd2bfd3ca
Yep. Absolutely. There’s two problems here. Firstly the inspection engine hangs. This will be fixed in the next few months as we introduce
loupe
as a new inspection engine, which fixes circular refs. The next problem is why the inspection engine is ever run for passing tests. This is addressed in #585 which is a much longer architectural change.This is a valid concern, but Opal is one library out of N. Making concessions for individual libraries is not something we’re interested in doing, as its a slippery slope. We could also block the
$$typeof$$
magic strings that some libraries like React have, but its not an interest we have. Again though, the new inspection engine will enable plugins to interface with these paths to allow for this kind of behavior.TL;DR. Sorry, it sucks that this is the case right now. We’re working hard to fix it. Rest assured it will be fixed - just not in the exact way that Opal declares it’s circular properties.