Fix LicenseWithExceptionSymbol missing Expression class variables#112
Fix LicenseWithExceptionSymbol missing Expression class variables#112pombredanne merged 2 commits intoaboutcode-org:mainfrom
Conversation
Signed-off-by: Aaron Bassett <abassett@qnx.com>
pombredanne
left a comment
There was a problem hiding this comment.
Good catch! Do you mind to add a simple test too? And check if using a better super() call may resolve the issue too?
| # FIXME: this should be instead a super class of all symbols | ||
| self.LicenseSymbol = self.Symbol | ||
| # LicenseWithExceptionSymbol does not get its internal Expressions mapped durring BooleanAlgebra init | ||
| # have to set it after the fact |
There was a problem hiding this comment.
I wonder if the solution could not be instead something about a better/different way to call super?
There was a problem hiding this comment.
Regarding the better super call. originally that's what i was trying to do, but unless boolean is changed i don't think there is a way from what i can tell license-expression is a outlier with 2 symbol classes
There was a problem hiding this comment.
ah... Note that I maintain boolean too, so I could do it there, but that's indeed a weird thing, though may be the check should be for any symbol subclass somehow?
There was a problem hiding this comment.
Ah sorry i didn't realize you were also the maintainer of boolean.
Yea in boolean if you could do the same thing for all sub classes of the passed in symbol class that should fix it.
Is this something you would prefer to do if not i can take a look at it myself when i get the chance.
right now i'm working around it by just patching the operators right after the import using the same code
tf_nao = {
"TRUE": spdx_licensing.TRUE,
"FALSE": spdx_licensing.FALSE,
"NOT": spdx_licensing.NOT,
"AND": spdx_licensing.AND,
"OR": spdx_licensing.OR,
"Symbol": spdx_licensing.Symbol,
}
for name, value in tf_nao.items():
setattr(LicenseWithExceptionSymbol, name, value)There was a problem hiding this comment.
I added some tests if the plan is to fix this in boolean should be a good base.
There was a problem hiding this comment.
Thanks. It looks like the boolean.py code will need a good facelift to account for this.
Yea no problem ill add a test. |
Signed-off-by: Aaron Bassett <abassett@qnx.com>
pombredanne
left a comment
There was a problem hiding this comment.
Thanks... just a tiny nit for your consideration.
| # FIXME: this should be instead a super class of all symbols | ||
| self.LicenseSymbol = self.Symbol | ||
| # LicenseWithExceptionSymbol does not get its internal Expressions mapped durring BooleanAlgebra init | ||
| # have to set it after the fact |
There was a problem hiding this comment.
Thanks. It looks like the boolean.py code will need a good facelift to account for this.
LicenseWithExceptionSymbol class AND,OR,Symbol variables coming from expression were not being set during init this causes issues when using python operators like and when the symbol is only LicenseWithExceptionSymbol
ex.
This will cause an exception as AND is NONE
The fix is a copy of BooleanAlgebra init which does the same but for all types