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

Expand C416 to dict comprehensions #490

Conversation

Skylion007
Copy link
Contributor

Closes #489 by expanding C416 to dict comprehensions.

@Skylion007 Skylion007 force-pushed the skylion007/expand-C416-to-dict-comprehension branch from 0d07ba9 to 7f1044f Compare March 17, 2023 19:54
Copy link
Owner

@adamchainz adamchainz left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Good work.

I made a few fixes:

  1. Changelog note - please always try to copy a project's conventions and add a note in your PR, to reduce maintainer work
  2. Fix the reStructuredText syntax in the README - underlines have to match the length of the title. The rstcheck pre-commit hook is meant to detect this but for some reason it didn't ¯\_(ツ)_/¯
  3. Improved the docs - they weren't so clear, unrelated to your change though really
  4. I added some failing test cases after trying to break the implementation. This lead to fix where I ensure the tuple of the comprehension is exactly the right length and only contains two Name elements that match the dict key/value.

Alright, time to merge and release :)

@adamchainz adamchainz merged commit 5016baf into adamchainz:main Mar 18, 2023
5 checks passed
@Skylion007 Skylion007 deleted the skylion007/expand-C416-to-dict-comprehension branch March 18, 2023 18:14
jankatins added a commit to jankatins/pr-workflow-example that referenced this pull request Mar 21, 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 |
|---|---|---|---|---|---|
|
[flake8-comprehensions](https://togithub.com/adamchainz/flake8-comprehensions)
([changelog](https://togithub.com/adamchainz/flake8-comprehensions/blob/main/CHANGELOG.rst))
| `3.10.1` -> `3.11.0` |
[![age](https://badges.renovateapi.com/packages/pypi/flake8-comprehensions/3.11.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/flake8-comprehensions/3.11.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/flake8-comprehensions/3.11.0/compatibility-slim/3.10.1)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/flake8-comprehensions/3.11.0/confidence-slim/3.10.1)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>adamchainz/flake8-comprehensions</summary>

###
[`v3.11.0`](https://togithub.com/adamchainz/flake8-comprehensions/blob/HEAD/CHANGELOG.rst#&#8203;3110-2023-03-18)

[Compare
Source](https://togithub.com/adamchainz/flake8-comprehensions/compare/3.10.1...3.11.0)

-   Expand C416 to `dict` comprehensions.

Thanks to Aaron Gokaslan in `PR #&#8203;490
<https://github.com/adamchainz/flake8-comprehensions/pull/490>`\__.

</details>

---

### Configuration

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

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, 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/jankatins/pr-workflow-example).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMC4yIiwidXBkYXRlZEluVmVyIjoiMzUuMTAuMiJ9-->
tugrulates pushed a commit to tugrulates/template-python that referenced this pull request May 10, 2023
Bumps
[flake8-comprehensions](https://github.com/adamchainz/flake8-comprehensions)
from 3.10.1 to 3.12.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/adamchainz/flake8-comprehensions/blob/main/CHANGELOG.rst">flake8-comprehensions's
changelog</a>.</em></p>
<blockquote>
<h2>3.12.0 (2023-04-13)</h2>
<ul>
<li>
<p>Add rule C418 to check for calls passing a dict literal or dict
comprehension to <code>dict()</code>.</p>
</li>
<li>
<p>Add rule C419 to check for calls passing a list comprehension to
<code>any()</code>/<code>all()</code>.</p>
</li>
</ul>
<h2>3.11.1 (2023-03-21)</h2>
<ul>
<li>
<p>Fix false positives in C406 “unnecessary dict literal”.</p>
<p>Fixes <code>Issue
[#260](adamchainz/flake8-comprehensions#260)
&lt;https://github.com/adamchainz/flake8-comprehensions/issues/260&gt;</code>__.</p>
</li>
</ul>
<h2>3.11.0 (2023-03-18)</h2>
<ul>
<li>
<p>Expand C416 to <code>dict</code> comprehensions.</p>
<p>Thanks to Aaron Gokaslan in <code>PR
[#490](adamchainz/flake8-comprehensions#490)
&lt;https://github.com/adamchainz/flake8-comprehensions/pull/490&gt;</code>__.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/d8d15cfd0846df1c611dfb1f214174bcb56a869d"><code>d8d15cf</code></a>
Version 3.12.0</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/867247f8f4c1bd521b8c482b4f375336f05aa639"><code>867247f</code></a>
Add rule for list comprehensions passed to any()/all() (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/427">#427</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/b6c2b95de32f474173b2f3c0be33aa6669105b05"><code>b6c2b95</code></a>
Add rule for unnecessary dict() calls (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/500">#500</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/c7e7ffbdebc6104ebb4508ca7c583612d3073942"><code>c7e7ffb</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/498">#498</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/59f6bc94679600b8439cfe05c2fd7c1b2f380049"><code>59f6bc9</code></a>
Upgrade requirements (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/497">#497</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/b5d223c13a62f62875c8c0db36a6794a562227b7"><code>b5d223c</code></a>
Add tox-ini-fmt pre-commit hook (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/496">#496</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/b4fdcc313b1e67559e48bff7e90c6236d7a72abf"><code>b4fdcc3</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/495">#495</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/1f34ce5edb018924dac18e59276390e09c003d24"><code>1f34ce5</code></a>
Upgrade requirements (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/494">#494</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/bdc1d00f0aee4c937d48af03b6d376149e2f8831"><code>bdc1d00</code></a>
Version 3.11.1</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/34ae012bce5885ed0d465b8567ded8bc4f086929"><code>34ae012</code></a>
Improve documentation (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/492">#492</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/adamchainz/flake8-comprehensions/compare/3.10.1...3.12.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=flake8-comprehensions&package-manager=pip&previous-version=3.10.1&new-version=3.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
tugrulates pushed a commit to tugrulates/notes that referenced this pull request May 10, 2023
Bumps
[flake8-comprehensions](https://github.com/adamchainz/flake8-comprehensions)
from 3.10.1 to 3.12.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/adamchainz/flake8-comprehensions/blob/main/CHANGELOG.rst">flake8-comprehensions's
changelog</a>.</em></p>
<blockquote>
<h2>3.12.0 (2023-04-13)</h2>
<ul>
<li>
<p>Add rule C418 to check for calls passing a dict literal or dict
comprehension to <code>dict()</code>.</p>
</li>
<li>
<p>Add rule C419 to check for calls passing a list comprehension to
<code>any()</code>/<code>all()</code>.</p>
</li>
</ul>
<h2>3.11.1 (2023-03-21)</h2>
<ul>
<li>
<p>Fix false positives in C406 “unnecessary dict literal”.</p>
<p>Fixes <code>Issue
[#260](adamchainz/flake8-comprehensions#260)
&lt;https://github.com/adamchainz/flake8-comprehensions/issues/260&gt;</code>__.</p>
</li>
</ul>
<h2>3.11.0 (2023-03-18)</h2>
<ul>
<li>
<p>Expand C416 to <code>dict</code> comprehensions.</p>
<p>Thanks to Aaron Gokaslan in <code>PR
[#490](adamchainz/flake8-comprehensions#490)
&lt;https://github.com/adamchainz/flake8-comprehensions/pull/490&gt;</code>__.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/d8d15cfd0846df1c611dfb1f214174bcb56a869d"><code>d8d15cf</code></a>
Version 3.12.0</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/867247f8f4c1bd521b8c482b4f375336f05aa639"><code>867247f</code></a>
Add rule for list comprehensions passed to any()/all() (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/427">#427</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/b6c2b95de32f474173b2f3c0be33aa6669105b05"><code>b6c2b95</code></a>
Add rule for unnecessary dict() calls (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/500">#500</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/c7e7ffbdebc6104ebb4508ca7c583612d3073942"><code>c7e7ffb</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/498">#498</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/59f6bc94679600b8439cfe05c2fd7c1b2f380049"><code>59f6bc9</code></a>
Upgrade requirements (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/497">#497</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/b5d223c13a62f62875c8c0db36a6794a562227b7"><code>b5d223c</code></a>
Add tox-ini-fmt pre-commit hook (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/496">#496</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/b4fdcc313b1e67559e48bff7e90c6236d7a72abf"><code>b4fdcc3</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/495">#495</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/1f34ce5edb018924dac18e59276390e09c003d24"><code>1f34ce5</code></a>
Upgrade requirements (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/494">#494</a>)</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/bdc1d00f0aee4c937d48af03b6d376149e2f8831"><code>bdc1d00</code></a>
Version 3.11.1</li>
<li><a
href="https://github.com/adamchainz/flake8-comprehensions/commit/34ae012bce5885ed0d465b8567ded8bc4f086929"><code>34ae012</code></a>
Improve documentation (<a
href="https://redirect.github.com/adamchainz/flake8-comprehensions/issues/492">#492</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/adamchainz/flake8-comprehensions/compare/3.10.1...3.12.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=flake8-comprehensions&package-manager=pip&previous-version=3.10.1&new-version=3.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[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.

Extend to C416 to dict comprehensions
2 participants