Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add required phrase rules automatically #3254

Closed
wants to merge 15 commits into from

Conversation

AyanSinhaMahapatra
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra commented Feb 15, 2023

Reference: #2637 #2878

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁

Add a script which can add required phrases in already existing rules
automatically from license field names, and can do this one license
expression at a time.

Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
These were added automatically by the script added at
etc/scripts/licenses/add_required_phrases.py

Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
@AyanSinhaMahapatra AyanSinhaMahapatra changed the title Required phrase rules Add required phrase rules automatically Feb 17, 2023
@pombredanne pombredanne marked this pull request as draft April 24, 2023 15:45
@AyanSinhaMahapatra AyanSinhaMahapatra added this to the v32.1 milestone Jan 15, 2024
* moves the script to licensedcode
* adds a new console script `add-required-phrases`
* move the functions and tests to seperate files

Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Here are some comments for your consideration.

src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/tokenize.py Outdated Show resolved Hide resolved
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
This is done only on `mit` rules, by running:
add-required-phrases -ovr --license-expression "mit"

Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Some minor nits and a question on the is_required_phrase flag for your consideration!

src/licensedcode/tokenize.py Outdated Show resolved Hide resolved
src/licensedcode/tokenize.py Outdated Show resolved Hide resolved
src/licensedcode/tokenize.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
src/licensedcode/models.py Show resolved Hide resolved
src/licensedcode/models.py Outdated Show resolved Hide resolved
'but is an essential section of the rule text which must be '
'present in the case of partial matches, otherwise the match '
'will be a false positive and misleading.')
)
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 this would not be best computed an index time ... this is True if a rule text is entirely a required phrase, this would mean one less stored flag.

src/licensedcode/models.py Show resolved Hide resolved
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Looking fine!

@AyanSinhaMahapatra
Copy link
Member Author

Closing this as we now have #3924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants