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

fix(templates): Include package license metadata conditionally in templates #2862

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

ReubenFrankel
Copy link
Contributor

@ReubenFrankel ReubenFrankel commented Jan 31, 2025

When I choose not to include a license, I expect there not to be any metadata pertaining to a particular license type in the pyproject.toml.

Unsure how tests work for templates, so haven't included any for now - I am happy to try with some direction.

Summary by Sourcery

Chores:

  • Remove unnecessary license information when a license is not specified.

📚 Documentation preview 📚: https://meltano-sdk--2862.org.readthedocs.build/en/2862/

@ReubenFrankel ReubenFrankel requested a review from a team as a code owner January 31, 2025 17:15
Copy link
Contributor

sourcery-ai bot commented Jan 31, 2025

Reviewer's Guide by Sourcery

This pull request modifies the pyproject.toml files in the tap, mapper, and target templates to conditionally include license metadata based on the user's choice during template creation. Specifically, it ensures that if no license is selected, no license-related metadata is included in the generated pyproject.toml.

Flow diagram for conditional license metadata inclusion

graph TD
    A[Start Template Generation] --> B{License Selected?}
    B -->|Yes| C[Include License Metadata]
    B -->|No License| D[Skip License Metadata]
    C --> E[Add License Field]
    C --> F[Add License Files]
    C --> G[Add Apache License Classifier]
    D --> H[Generate pyproject.toml without License Info]
    E --> I[Complete pyproject.toml]
    F --> I
    G --> I
    H --> I
Loading

File-Level Changes

Change Details Files
Conditional inclusion of license classifiers.
  • Added a conditional Jinja statement to include the 'License :: OSI Approved :: Apache Software License' classifier only when the selected license is 'Apache-2.0'.
cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml
cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml
cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml
Conditional inclusion of license and license-files fields.
  • Added a conditional Jinja statement to include the 'license' and 'license-files' fields only when the selected license is not 'None'.
cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml
cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml
cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We have skipped reviewing this pull request. We don't review packaging changes - Let us know if you'd like us to change this.

@ReubenFrankel
Copy link
Contributor Author

This AI review of the PR is crazy 😮

@ReubenFrankel
Copy link
Contributor Author

Let me know how you feel about 7b67928.

@edgarrmondragon
Copy link
Collaborator

This AI review of the PR is crazy 😮

Crazy as "ok, this is actually somewhat useful" or "what? that is nonsense!"? 😅

@ReubenFrankel
Copy link
Contributor Author

This AI review of the PR is crazy 😮

Crazy as "ok, this is actually somewhat useful" or "what? that is nonsense!"? 😅

Crazy as in I am impressed at how it summarised the changes and generated a whole flowchart too! Undecided on whether it is beneficial for the author or not, by can see it being useful to maintainers. I wonder how it would perform with bigger PRs...

@edgarrmondragon edgarrmondragon self-assigned this Jan 31, 2025
@edgarrmondragon edgarrmondragon changed the title fix: Include package license metadata conditionally fix(templates): Include package license metadata conditionally in templates Jan 31, 2025
@edgarrmondragon
Copy link
Collaborator

Crazy as in I am impressed at how it summarised the changes and generated a whole flowchart too! Undecided on whether it is beneficial for the author or not, by can see it being useful to maintainers. I wonder how it would perform with bigger PRs...

The summary has helped me a bit to catch things in a PR that shouldn't have been included, though I've yet to try it in larger PR.

@edgarrmondragon
Copy link
Collaborator

@ReubenFrankel what do you think adding a replay file in e2e-tests/cookiecutters to generate a project with license None. We can download the files and inspect them manually.

@edgarrmondragon
Copy link
Collaborator

@ReubenFrankel what do you think adding a replay file in e2e-tests/cookiecutters to generate a project with license None. We can download the files and inspect them manually.

4179f39

@edgarrmondragon
Copy link
Collaborator

@ReubenFrankel what do you think adding a replay file in e2e-tests/cookiecutters to generate a project with license None. We can download the files and inspect them manually.

4179f39

And here's how it looks

pyproject.toml
[project]
name = "tap-no-license"
version = "0.0.1"
description = "Singer tap for AutomaticTestTap, built with the Meltano Singer SDK."
readme = "README.md"
authors = [{ name = "Automatic Tester", email = "[email protected]" }]
keywords = [
    "ELT",
    "AutomaticTestTap",
]
classifiers = [
    "Intended Audience :: Developers",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
    "Programming Language :: Python :: 3.13",
]
license-files = [ "LICENSE" ]
requires-python = ">=3.9"
dependencies = [
    "singer-sdk~=0.44.1",
    "requests~=2.32.3",
]

[project.optional-dependencies]
s3 = [
    "fs-s3fs~=1.1.1",
]

[project.scripts]
# CLI declaration
tap-no-license = 'tap_no_license.tap:TapAutomaticTestTap.cli'

[dependency-groups]
dev = [
    "pytest>=8",
    "singer-sdk[testing]~=0.44.1",
]

[tool.pytest.ini_options]
addopts = [
    "--durations=10",
]

[tool.mypy]
python_version = "3.12"
warn_unused_configs = true

[tool.ruff]
target-version = "py39"

[tool.ruff.lint]
ignore = [
    "COM812",  # missing-trailing-comma
]
select = ["ALL"]

[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true

[tool.ruff.lint.pydocstyle]
convention = "google"

[build-system]
requires = [
    "hatchling>=1,<2",
]
build-backend = "hatchling.build"

And it is valid according to https://github.com/abravalheri/validate-pyproject.

Copy link
Collaborator

@edgarrmondragon edgarrmondragon left a comment

Choose a reason for hiding this comment

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

Thanks @ReubenFrankel!

@edgarrmondragon edgarrmondragon added this pull request to the merge queue Jan 31, 2025
Merged via the queue into meltano:main with commit 3c80245 Jan 31, 2025
5 checks passed
@edgarrmondragon edgarrmondragon added the Cookiecutter Tap, target and mapper templates label Jan 31, 2025
@ReubenFrankel
Copy link
Contributor Author

@edgarrmondragon Sorry - meant to say I did test this locally. Wasn't sure how the template tests worked so thanks for sorting. 👍

@ReubenFrankel ReubenFrankel deleted the patch-1 branch January 31, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community-Contributed PR Cookiecutter Tap, target and mapper templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants