(Might be relevant because there might be a simpler way to achieve what I want.)
I want to build a declarative way to define "aspects" that can be analyzed by a static code analysis tool. The whole concept is written down here
. Every aspect (say
) may have sub aspects recursively (say
) and every aspect shall have documentation and arbitrary other properties. The user shall be able to choose which aspects to analyze and I have to programmatically find out for the internal representation of an aspect if it's the one choosen by the user (i.e. for a given class
I want to validate that it belongs to a given string
I decided to use classes like this:
This meta aspect describes any kind of redundancy in your source code.
# Can't inherit from Redundancy here because of the recursion
This redundancy describes a code clone. Code clones are different pieces of
code in your codebase that are very similar.
For a given
class I want to get the describing string (
). For that I have to get the name of the surrounding module/class/whatever it is, check if it's a class (trivial) and construct a string out of it.
Possible Solutions and How They Failed
I did try looking at the
of my classes to see if there's anything useful in the dunder methods I could use but found nothing except the
which in the above case is
when living in the
module. This shows that it should be possible but I have no idea on how
gets this information and I would like to avoid using
and stripping off the unneeded stuff as that's kind of a hack.
I am not able to inherit the nested class from the outer one as it is not completely defined yet. I want them nested for the usability, being able to
from ... import Redundancy
and in my source code write
is a huge plus.
Any suggestions, including changing my approach, would be appreciated.