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

Read strategy from pyproject toml #32

Merged
merged 11 commits into from
Feb 25, 2020

Conversation

larsrinn
Copy link
Contributor

@larsrinn larsrinn commented Jun 20, 2019

closes #31

As proposed in #31 I added a capability to read the strategy from a pyproject.toml file. By default it looks for a tool.liccheck section in such a file. If this is not there, it falls back to the file passed in via the -s parameter. If this is not there either, an error message is shown.

A valid section in pyproject.toml would be

[tool.liccheck]
authorized_licenses = [
  "bsd",
  "new bsd",
  "bsd license"
]
unauthorized_licenses = [
  "gpl v3"
]

[tool.liccheck.authorized_packages]
uuid = "<=1.30"

What do you think about this approach? Should the Strategy parameter also be configurable by that way?

Todo before merge

  • Integration tests with pyproject.toml
  • Documentation -> My proposal would be to make this the default way of configure this tool (and maybe deprecating reading from the config file)

But I wanted to get some feedback before doing this...

unauthorized_licenses = [
"gpl v3"
]
[tool.liccheck.authorized_packages]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not incuding authorized_packages in the tool.liccheck section above? Also, does this syntax supports all version requirements operators, i.e. can we specify for example uuid >= 1.30, < 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

authorized_packages must be a dictionary to map the package name to the allowed versions. And afaik there is no other way to define a dictionary within a dictionary in toml than this (e.g. indendation seems to be ignored entirely). See https://github.com/toml-lang/toml

Also, does this syntax supports all version requirements operators, i.e. can we specify for example uuid >= 1.30, < 2?

Yes, see the example in the PR description

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! Before merging, could you add a paragraph in the readme regarding this new feature? Thanks a lot.

@abompard
Copy link
Contributor

I use pyproject.toml too and this would be a pretty cool feature. Are you still on it @larsrinn?

@ochedru
Copy link
Collaborator

ochedru commented Feb 25, 2020

Merging. Readme and tests still to be updated, though.

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.

Read configuration from pyproject.toml
3 participants