It appears the ‘Instant reverse’ → ‘python source’ function can’t handle classes that are created with the metaclass parameter.
A message is shown that instant reverse has been ‘completed with errors’ and none of these classes are part of the generated model.
Classes that inherit from these classes are also completely excluded.
I have looked into the vp.log file for an error message, but none is shown.
To reproduce the bug a python module containing this code can be given to the instant reverse tool;
class Test(metaclass=type):
A = 1
class InheritedTest(Test):
B = 2
class NoMeta:
C = 3
We are actually using the sqlalchemy package in our project and using the declarative base mapping to map our python classes to the sqlalchemy orm.
This is done by inheriting classes that should be persisted from the sqlalchemy declarative base class.
Since the declarative base class is a metaclass, our complete orm model is missing when using this visual paradigm feature.
It would be wonderful if this piece of code could be successfully reversed:
I am glad to inform you that the problem has been fixed. Please update to the latest patch build to obtain the fix. The steps can be found in the article below:
Should you have any questions, please feel free to let me know.
During testing of the new update, I found that the metaclass import is currently working as intended, so thanks very much for the fix.
I did, however, stumble upon another item that prevented a class from being reversed.
After some testing, I think the problem is the use of list comprehension during dict instantiation.
The smallest example I have causing this error is the following;
attributes = ["a", "b", "c"]
test_dict = {attr: index for index, attr in enumerate(attributes)}
The error message found in the vp.log is the following; [message] java.lang.ClassCastException: class v.bdm.bm cannot be cast to class v.bdm.bj (v.bdm.bm and v.bdm.bj are in unnamed module of loader 'app')
And one example showcasing the class reversal not occurring when this error occurs;
from typing import Dict, Sequence
class Test(metaclass=type):
def attribute_dict(self, attributes: Sequence[str]) -> Dict:
return {attr_name: getattr(self, attr_name) for attr_name in attributes}
We are glad to know that the fix works. Thanks for your post. I have just asked our engineers to take a look at the new problem you described. Again, I will let you know when there is any news.
Unfortunately the fix doesn’t seem to have helped on my system.
Neither of the two examples I provided are currently functioning on my end.
Thanks again for being so responsive.