Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/license_expression/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,19 @@ def __init__(self, symbols=tuple(), quiet=True):

# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the solution could not be instead something about a better/different way to call super?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some tests if the plan is to fix this in boolean should be a good base.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It looks like the boolean.py code will need a good facelift to account for this.

tf_nao = {
"TRUE": self.TRUE,
"FALSE": self.FALSE,
"NOT": self.NOT,
"AND": self.AND,
"OR": self.OR,
"Symbol": self.Symbol,
}

for name, value in tf_nao.items():
setattr(LicenseWithExceptionSymbol, name, value)

symbols = symbols or tuple()

Expand Down