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 scripts to generate plugin and check boilerplate #1579

Merged
merged 1 commit into from
Jan 3, 2023

Conversation

charliermarsh
Copy link
Member

These are pretty hacky, but they work, and they'll save us a ton of time. Since they're dev-only, they can be pretty scrappy, so let's just iterate on them as we go.

To generate a plugin:

python scripts/add_plugin.py flake8-pie --url https://pypi.org/project/flake8-pie/0.16.0/

To generate a check code:

python scripts/add_check.py --name PreferListBuiltin --code PIE807 --plugin flake8-pie

Resolves #1531 and #1532.

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Generate boilerplate for a new check.",
epilog=("python scripts/add_check.py --name PreferListBuiltin --code PIE807 --plugin flake8-pie"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these arguments are required, I think I'd rather make them positional e.g.

python scripts/add_check.py flake8-pie PIE807 PreferListBuiltin

Copy link
Member Author

Choose a reason for hiding this comment

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

My gripe with that is that you then have to remember the order.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I think that could be mitigated by doing some input validation and providing nice error messages e.g:

  • providing a nice error message if the first argument isn't an existing plugin
  • providing a nice error message if the second argument doesn't have the prefix of the plugin

@charliermarsh charliermarsh merged commit ca7fe68 into main Jan 3, 2023
@charliermarsh charliermarsh deleted the charlie/scripts branch January 3, 2023 03:10
renovate bot referenced this pull request in ixm-one/pytest-cmake-presets Jan 3, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.207` ->
`^0.0.208` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.208/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.208/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.208/compatibility-slim/0.0.207)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.208/confidence-slim/0.0.207)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.208`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.208)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.207...v0.0.208)

#### What's Changed

- Adds a codespell linter by
[@&#8203;colin99d](https://togithub.com/colin99d) in
[https://github.com/charliermarsh/ruff/pull/1553](https://togithub.com/charliermarsh/ruff/pull/1553)
- Avoid merging import from statements with inline comments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1562](https://togithub.com/charliermarsh/ruff/pull/1562)
- Avoid PEP 604 rewrites for runtime annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1563](https://togithub.com/charliermarsh/ruff/pull/1563)
- Implement `flake8-pytest-style` by
[@&#8203;edgarrmondragon](https://togithub.com/edgarrmondragon) in
[https://github.com/charliermarsh/ruff/pull/1506](https://togithub.com/charliermarsh/ruff/pull/1506)
- Always check directly-passed-in files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1564](https://togithub.com/charliermarsh/ruff/pull/1564)
- Remove common-path dependency by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1565](https://togithub.com/charliermarsh/ruff/pull/1565)
- Rename checks.rs to registry.rs by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1566](https://togithub.com/charliermarsh/ruff/pull/1566)
- Remove extend- from docstring configuration examples by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1571](https://togithub.com/charliermarsh/ruff/pull/1571)
- Avoid invalid trailing comma fixes for mock rewrites by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1570](https://togithub.com/charliermarsh/ruff/pull/1570)
- Automatically set baseline D codes based on convention by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1574](https://togithub.com/charliermarsh/ruff/pull/1574)
- Remove need for vendored format/cformat code by
[@&#8203;olliemath](https://togithub.com/olliemath) in
[https://github.com/charliermarsh/ruff/pull/1573](https://togithub.com/charliermarsh/ruff/pull/1573)
- Warn user when D203 and D211 are enabled by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1576](https://togithub.com/charliermarsh/ruff/pull/1576)
- Add `flake8-pie` plugin with `prefer_list_builtin` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1578](https://togithub.com/charliermarsh/ruff/pull/1578)
- Add scripts to generate plugin and check boilerplate by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1579](https://togithub.com/charliermarsh/ruff/pull/1579)
- Implement unnecessary-pass-statement by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1580](https://togithub.com/charliermarsh/ruff/pull/1580)
- Implement dupe-class-field-definitions by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1581](https://togithub.com/charliermarsh/ruff/pull/1581)
- Implement autofix for F541 by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1577](https://togithub.com/charliermarsh/ruff/pull/1577)
- Add a link to GitHub from the playground by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1583](https://togithub.com/charliermarsh/ruff/pull/1583)
- Mark `FStringMissingPlaceholders` as fixable by
[@&#8203;harupy](https://togithub.com/harupy) in
[https://github.com/charliermarsh/ruff/pull/1582](https://togithub.com/charliermarsh/ruff/pull/1582)
- Swap accent color for playground by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1584](https://togithub.com/charliermarsh/ruff/pull/1584)
- Prefer GitHub icon on mobile by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1585](https://togithub.com/charliermarsh/ruff/pull/1585)
- Implement and-false and or-true rules by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/1586](https://togithub.com/charliermarsh/ruff/pull/1586)

**Full Changelog**:
astral-sh/ruff@v0.0.207...v0.0.208

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC43NC4yIiwidXBkYXRlZEluVmVyIjoiMzQuNzQuMiJ9-->

Signed-off-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

Add a script to generate all boilerplate needed for a new plugin
2 participants