Simplification drops essential parts of expressions

Open
#124 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
tooling

Research direction

Reproduce the two examples with license_expression, focusing first on the parse() and simplify() entry points named in the report. Trace why the OR sections disappear from the simplified expression, then add or update coverage for these cases so simplification preserves choices that have not been exercised.

Written by the indexing model from the issue text.

Description

I am using the license-expression library to feed it a large string of licenses from different package files to propose a derived package license. Unfortunately, this approach omits important licenses.

Let's consider the following example:

>>> from license_expression import get_spdx_licensing
>>> licensing = get_spdx_licensing()
>>> expression = "MIT AND BSD-3-Clause AND (MIT OR GPL-2.0-or-later OR (Apache-2.0 AND BSD-2-Clause)) AND MIT"
>>> parsed = licensing.parse(expression)
>>> str(parsed.simplify())
BSD-3-Clause AND MIT
>>> expression = "MIT AND BSD-3-Clause AND (MIT OR GPL-2.0-or-later OR Apache-2.0) AND MIT"
>>> parsed = licensing.parse(expression)
>>> str(parsed.simplify())
BSD-3-Clause AND MIT

As we can see, the whole OR sections have been removed, which would imply I already exercised a choice, which is not the case.

Dominant language
Python
Stars
74
Forks
38
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/license-expression

All issues in aboutcode-org/license-expression

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.