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

Allow linking to individual rules #4158

Merged
merged 3 commits into from
May 4, 2023

Conversation

calumy
Copy link
Contributor

@calumy calumy commented Apr 30, 2023

Adds an id to each rule to allow linking directly to the rule.

Closes #3420

@github-actions
Copy link
Contributor

github-actions bot commented Apr 30, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     13.9±0.04ms     2.9 MB/sec    1.00     13.9±0.03ms     2.9 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.4±0.00ms     5.0 MB/sec    1.00      3.4±0.01ms     4.9 MB/sec
linter/all-rules/numpy/globals.py          1.00    417.8±3.04µs     7.1 MB/sec    1.01    422.3±0.87µs     7.0 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.8±0.02ms     4.4 MB/sec    1.00      5.8±0.01ms     4.4 MB/sec
linter/default-rules/large/dataset.py      1.00      6.9±0.01ms     5.9 MB/sec    1.01      7.0±0.01ms     5.8 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1491.1±2.13µs    11.2 MB/sec    1.00   1498.2±3.45µs    11.1 MB/sec
linter/default-rules/numpy/globals.py      1.00    167.7±0.84µs    17.6 MB/sec    1.01    168.6±0.32µs    17.5 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.1±0.00ms     8.2 MB/sec    1.00      3.1±0.01ms     8.2 MB/sec
parser/large/dataset.py                    1.00      5.4±0.05ms     7.5 MB/sec    1.00      5.4±0.02ms     7.5 MB/sec
parser/numpy/ctypeslib.py                  1.00   1062.1±0.66µs    15.7 MB/sec    1.00   1063.1±0.62µs    15.7 MB/sec
parser/numpy/globals.py                    1.01    109.0±0.19µs    27.1 MB/sec    1.00    108.4±0.43µs    27.2 MB/sec
parser/pydantic/types.py                   1.00      2.3±0.00ms    11.0 MB/sec    1.00      2.3±0.00ms    11.0 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     21.5±0.56ms  1936.7 KB/sec    1.01     21.7±0.70ms  1919.7 KB/sec
linter/all-rules/numpy/ctypeslib.py        1.04      5.5±0.26ms     3.0 MB/sec    1.00      5.3±0.22ms     3.1 MB/sec
linter/all-rules/numpy/globals.py          1.02   624.4±33.61µs     4.7 MB/sec    1.00   611.6±21.71µs     4.8 MB/sec
linter/all-rules/pydantic/types.py         1.00      9.1±0.33ms     2.8 MB/sec    1.00      9.1±0.38ms     2.8 MB/sec
linter/default-rules/large/dataset.py      1.01     10.9±0.38ms     3.7 MB/sec    1.00     10.7±0.34ms     3.8 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.01      2.3±0.10ms     7.3 MB/sec    1.00      2.3±0.09ms     7.4 MB/sec
linter/default-rules/numpy/globals.py      1.00   252.8±14.94µs    11.7 MB/sec    1.04   262.3±20.06µs    11.3 MB/sec
linter/default-rules/pydantic/types.py     1.00      4.8±0.19ms     5.3 MB/sec    1.02      4.9±0.19ms     5.2 MB/sec
parser/large/dataset.py                    1.00      8.5±0.31ms     4.8 MB/sec    1.02      8.6±0.26ms     4.7 MB/sec
parser/numpy/ctypeslib.py                  1.00  1606.9±59.36µs    10.4 MB/sec    1.03  1654.2±70.76µs    10.1 MB/sec
parser/numpy/globals.py                    1.00    164.2±8.82µs    18.0 MB/sec    1.02   166.8±10.61µs    17.7 MB/sec
parser/pydantic/types.py                   1.00      3.5±0.10ms     7.2 MB/sec    1.05      3.7±0.30ms     6.9 MB/sec

@JonathanPlasse
Copy link
Contributor

You could also link the individual rules mentioned elsewhere to the links you created.
In task-tags setting, ERA and E501 are mentioned and could link back to the links you added in this PR.
They all seem to follow the regex \(`[A-Z]{1,3}[0-9]{0,4}`\).

@calumy
Copy link
Contributor Author

calumy commented Apr 30, 2023

You could also link the individual rules mentioned elsewhere to the links you created. In task-tags setting, ERA and E501 are mentioned and could link back to the links you added in this PR. They all seem to follow the regex \(`[A-Z]{1,3}[0-9]{0,4}`\).

Thanks for the suggestion @JonathanPlasse. I wonder if doing this automatically might lead to quite a few false positives and, therefore, if it might be better to do this manually in the specific documentation sections.

An example of a false positive could be if V101 in the external settings section was linked to https://beta.ruff.rs/docs/rules/#V101, which is currently not valid a valid rule section. Another example that matches your provided regex is "(key)" in the invalid-envvar-value (PLE1507) rules; this would direct users to https://beta.ruff.rs/docs/rules/#key, which is also not currently a valid rule section.

@JonathanPlasse
Copy link
Contributor

You could also link the individual rules mentioned elsewhere to the links you created. In task-tags setting, ERA and E501 are mentioned and could link back to the links you added in this PR. They all seem to follow the regex \(`[A-Z]{1,3}[0-9]{0,4}`\).

Thanks for the suggestion @JonathanPlasse. I wonder if doing this automatically might lead to quite a few false positives and, therefore, if it might be better to do this manually in the specific documentation sections.

An example of a false positive could be if V101 in the external settings section was linked to https://beta.ruff.rs/docs/rules/#V101, which is currently not valid a valid rule section. Another example that matches your provided regex is "(key)" in the invalid-envvar-value (PLE1507) rules; this would direct users to https://beta.ruff.rs/docs/rules/#key, which is also not currently a valid rule section.

To avoid false positives like V101 we could check if the rule exists.
(`key`) should not match the regex as it uses lower cases.

@calumy
Copy link
Contributor Author

calumy commented Apr 30, 2023

Checking the rule exists seems reasonable.

To be honest, this might be beyond my Rust skills. @JonathanPlasse, would you consider working on this, or should I open an issue as a feature request?

@JonathanPlasse
Copy link
Contributor

JonathanPlasse commented Apr 30, 2023

I will open an issue.
I may work on it if I have some time.

Co-authored-by: Micha Reiser <micha@reiser.io>
@calumy
Copy link
Contributor Author

calumy commented May 1, 2023

Tests are failing due to not being able to install "black[d]"'s dependencies. Would it be possible to rerun to check that this is not just a random error?

@MichaReiser
Copy link
Member

Tests are failing due to not being able to install "black[d]"'s dependencies. Would it be possible to rerun to check that this is not just a random error?

I triggered a re-run of the failing tests.

@charliermarsh
Copy link
Member

Should we include some kind of visual indicator, e.g., make it a link? (Is that even possible?) I'm also wondering if we should use the human-readable rule name for the URL, rather than the code, but then it becomes kind of duplicative with the standalone rule pages, like:

Screen Shot 2023-05-01 at 5 57 17 PM

@MichaReiser
Copy link
Member

I'm also wondering if we should use the human-readable rule name for the URL, rather than the code, but then it becomes kind of duplicative with the standalone rule pages, like:

I consider this a workaround for the time being until we have standalone rule pages for every rule.

@charliermarsh charliermarsh merged commit 890e630 into astral-sh:main May 4, 2023
14 checks passed
@charliermarsh charliermarsh added the documentation Improvements or additions to documentation label May 4, 2023
renovate bot added a commit to ixm-one/pytest-cmake-presets that referenced this pull request May 5, 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.264` ->
`^0.0.265` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/compatibility-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/confidence-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

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

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

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Breaking Changes

- Change `--fix-only` exit semantics to mirror `--fix` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4146

##### Rules

- \[flake8-pyi] PYI020 by [@&#8203;arya-k](https://togithub.com/arya-k)
in
[astral-sh/ruff#4211
- Update B027 to support autofixing by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[astral-sh/ruff#4178
- \[`flake8-pyi`] Implement `PYI042` and `PYI043` by
[@&#8203;arya-k](https://togithub.com/arya-k) in
[astral-sh/ruff#4214
- \[`pylint`] Implement import-self (`W0406`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#4154
- Warn on PEP 604 syntax not in an annotation, but don't autofix by
[@&#8203;wookie184](https://togithub.com/wookie184) in
[astral-sh/ruff#4170

##### Bug Fixes

- Fix panic in pydocstyle D214 when docstring indentation is empty by
[@&#8203;madkinsz](https://togithub.com/madkinsz) in
[astral-sh/ruff#4216
- Render tabs as 4 spaces in diagnostics by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[astral-sh/ruff#4132
- Fix era panic caused by out of bound edition by
[@&#8203;leiserfg](https://togithub.com/leiserfg) in
[astral-sh/ruff#4206
- End of statement insertion should occur after newline by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4215
- Ignore **debuggerskip** in unused variable checks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4229

##### CLI

- Show settings path in `--show-settings` output by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4199

##### Documentation

- Allow linking to individual rules by
[@&#8203;calumy](https://togithub.com/calumy) in
[astral-sh/ruff#4158

#### New Contributors

- [@&#8203;wookie184](https://togithub.com/wookie184) made their first
contribution in
[astral-sh/ruff#4170
- [@&#8203;arya-k](https://togithub.com/arya-k) made their first
contribution in
[astral-sh/ruff#4211

**Full Changelog**:
astral-sh/ruff@v0.0.264...v0.0.265

</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:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Signed-off-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot added a commit to allenporter/flux-local that referenced this pull request May 7, 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.264` ->
`==0.0.265` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/compatibility-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/confidence-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

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

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

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Breaking Changes

- Change `--fix-only` exit semantics to mirror `--fix` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4146

##### Rules

- \[flake8-pyi] PYI020 by [@&#8203;arya-k](https://togithub.com/arya-k)
in
[astral-sh/ruff#4211
- Update B027 to support autofixing by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[astral-sh/ruff#4178
- \[`flake8-pyi`] Implement `PYI042` and `PYI043` by
[@&#8203;arya-k](https://togithub.com/arya-k) in
[astral-sh/ruff#4214
- \[`pylint`] Implement import-self (`W0406`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#4154
- Warn on PEP 604 syntax not in an annotation, but don't autofix by
[@&#8203;wookie184](https://togithub.com/wookie184) in
[astral-sh/ruff#4170

##### Bug Fixes

- Fix panic in pydocstyle D214 when docstring indentation is empty by
[@&#8203;madkinsz](https://togithub.com/madkinsz) in
[astral-sh/ruff#4216
- Render tabs as 4 spaces in diagnostics by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[astral-sh/ruff#4132
- Fix era panic caused by out of bound edition by
[@&#8203;leiserfg](https://togithub.com/leiserfg) in
[astral-sh/ruff#4206
- End of statement insertion should occur after newline by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4215
- Ignore **debuggerskip** in unused variable checks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4229

##### CLI

- Show settings path in `--show-settings` output by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4199

##### Documentation

- Allow linking to individual rules by
[@&#8203;calumy](https://togithub.com/calumy) in
[astral-sh/ruff#4158

#### New Contributors

- [@&#8203;wookie184](https://togithub.com/wookie184) made their first
contribution in
[astral-sh/ruff#4170
- [@&#8203;arya-k](https://togithub.com/arya-k) made their first
contribution in
[astral-sh/ruff#4211

**Full Changelog**:
astral-sh/ruff@v0.0.264...v0.0.265

</details>

---

### Configuration

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

🚦 **Automerge**: Enabled.

♻ **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/allenporter/flux-local).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot added a commit to allenporter/pyrainbird that referenced this pull request May 7, 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.264` ->
`==0.0.265` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/compatibility-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.265/confidence-slim/0.0.264)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

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

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

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Breaking Changes

- Change `--fix-only` exit semantics to mirror `--fix` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4146

##### Rules

- \[flake8-pyi] PYI020 by [@&#8203;arya-k](https://togithub.com/arya-k)
in
[astral-sh/ruff#4211
- Update B027 to support autofixing by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[astral-sh/ruff#4178
- \[`flake8-pyi`] Implement `PYI042` and `PYI043` by
[@&#8203;arya-k](https://togithub.com/arya-k) in
[astral-sh/ruff#4214
- \[`pylint`] Implement import-self (`W0406`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#4154
- Warn on PEP 604 syntax not in an annotation, but don't autofix by
[@&#8203;wookie184](https://togithub.com/wookie184) in
[astral-sh/ruff#4170

##### Bug Fixes

- Fix panic in pydocstyle D214 when docstring indentation is empty by
[@&#8203;madkinsz](https://togithub.com/madkinsz) in
[astral-sh/ruff#4216
- Render tabs as 4 spaces in diagnostics by
[@&#8203;MichaReiser](https://togithub.com/MichaReiser) in
[astral-sh/ruff#4132
- Fix era panic caused by out of bound edition by
[@&#8203;leiserfg](https://togithub.com/leiserfg) in
[astral-sh/ruff#4206
- End of statement insertion should occur after newline by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4215
- Ignore **debuggerskip** in unused variable checks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#4229

##### CLI

- Show settings path in `--show-settings` output by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#4199

##### Documentation

- Allow linking to individual rules by
[@&#8203;calumy](https://togithub.com/calumy) in
[astral-sh/ruff#4158

#### New Contributors

- [@&#8203;wookie184](https://togithub.com/wookie184) made their first
contribution in
[astral-sh/ruff#4170
- [@&#8203;arya-k](https://togithub.com/arya-k) made their first
contribution in
[astral-sh/ruff#4211

**Full Changelog**:
astral-sh/ruff@v0.0.264...v0.0.265

</details>

---

### Configuration

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

🚦 **Automerge**: Enabled.

♻ **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/allenporter/pyrainbird).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@calumy calumy deleted the link-individual-rules branch May 10, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow linking to individual rules on https://beta.ruff.rs/docs/rules
4 participants