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 Markdown documentation for existing lint rules #2646

Closed
55 tasks done
charliermarsh opened this issue Feb 7, 2023 · 15 comments · Fixed by #7750
Closed
55 tasks done

Add Markdown documentation for existing lint rules #2646

charliermarsh opened this issue Feb 7, 2023 · 15 comments · Fixed by #7750
Labels
documentation Improvements or additions to documentation

Comments

@charliermarsh
Copy link
Member

charliermarsh commented Feb 7, 2023

If we write documentation on the #[violation] macro:

/// ### What it does
/// Checks for `self.assertRaises(Exception)`.
///
/// ## Why is this bad?
/// `assertRaises(Exception)` can lead to your test passing even if the
/// code being tested is never executed due to a typo.
///
/// Either assert for a more specific exception (builtin or custom), use
/// `assertRaisesRegex` or the context manager form of `assertRaises`.
#[violation]
pub struct NoAssertRaisesException;

This explanation shows up with ruff rule B017, and in the docs:

We'll track progress here:

  • airflow
  • eradicate
  • flake8-2020
  • flake8-annotations
  • flake8-async
  • flake8-bandit
  • flake8-blind-except
  • flake8-boolean-trap
  • flake8-bugbear
  • flake8-builtins
  • flake8-commas
  • flake8-comprehensions
  • flake8-copyright
  • flake8-datetimez
  • flake8-debugger
  • flake8-django
  • flake8-errmsg
  • flake8-executable
  • flake8-fixme
  • flake8-future-annotations
  • flake8-gettext
  • flake8-implicit-str-concat
  • flake8-import-conventions
  • flake8-logging-format
  • flake8-no-pep420
  • flake8-pie
  • flake8-print
  • flake8-pyi
  • flake8-pytest-style
  • flake8-quotes
  • flake8-raise
  • flake8-return
  • flake8-self
  • flake8-simplify
  • flake8-slots
  • flake8-tidy-imports
  • flake8-todos
  • flake8-type-checking
  • flake8-unused-arguments
  • flake8-use-pathlib
  • flynt
  • isort
  • mccabe
  • numpy
  • pandas-vet
  • pep8-naming
  • perflint
  • pycodestyle
  • pydocstyle
  • pyflakes
  • pygrep-hooks
  • pylint
  • pyupgrade
  • ruff
  • tryceratops
@spaceone
Copy link
Contributor

spaceone commented Feb 8, 2023

That's very nice!
In the README the rule is linked twice. Once for the code and once fore the human-readable-name. Isn't one link at the humann-readable-name enough? This would enable to double-click/select the rule name into copy&paste buffer instead of opening the link.

@charliermarsh
Copy link
Member Author

We could link it once -- I don't feel strongly!

@charliermarsh
Copy link
Member Author

(Making a concerted effort to add these for all new rules.)

@thatlittleboy
Copy link
Contributor

Hi, I'm looking to do my part in contributing some docs~

Quick question: I noticed that in #2796 for example, there is a change to bare_except.rs and the OP added docs/rules/bare_except.md. Do I have to write the markdown file myself or is it a generated file (since it's largely replicated from the text in define_violation! macro)?

@charliermarsh
Copy link
Member Author

Thanks! Everything is generated from the rustdoc in the macro, so no need to touch any Markdown. (We actually don’t even check in the generated Markdown anymore, so it won’t appear as part of any PRs — only need to write the rustdoc part, and the rest is taken care of for you when we generate the docs :))

@JonathanPlasse
Copy link
Contributor

try.ceratops already has documented its rules in its documentation.

@charliermarsh
Copy link
Member Author

👍 I'd prefer not to copy over their documentation though, would prefer to write our own. But we can look to theirs for guidance.

charliermarsh pushed a commit that referenced this issue Aug 7, 2023
Changes:
- Fixes typo and repeated phrase in `DTZ002`
- Adds docs for `DTZ003`
- Adds docs for `DTZ004`
- Adds example for <=Python3.10 in `DTZ001`

Related to: #2646
durumu pushed a commit to durumu/ruff that referenced this issue Aug 12, 2023
Changes:
- Fixes typo and repeated phrase in `DTZ002`
- Adds docs for `DTZ003`
- Adds docs for `DTZ004`
- Adds example for <=Python3.10 in `DTZ001`

Related to: astral-sh#2646
charliermarsh pushed a commit that referenced this issue Aug 13, 2023
Changes:
- Adds docs for `DTZ005`
- Adds docs for `DTZ006`

Related to: #2646
@harupy
Copy link
Contributor

harupy commented Aug 15, 2023

flake8-pytest-style is complete!

@charliermarsh
Copy link
Member Author

charliermarsh commented Aug 15, 2023

It looks like we're down to 31 rules that lack documentation:

  • call-with-shell-equals-true
  • start-process-with-a-shell
  • start-process-with-no-shell
  • call-datetime-strptime-without-zone
  • call-date-today
  • call-date-fromtimestamp
  • pass-statement-stub-body
  • non-empty-stub-body
  • typed-argument-default-in-stub
  • pass-in-class-body
  • argument-default-in-stub
  • assignment-default-in-stub
  • duplicate-union-member
  • quoted-annotation-in-stub
  • docstring-in-stub
  • unassigned-special-variable-in-stub
  • snake-case-type-alias
  • t-suffixed-type-alias
  • future-annotations-in-stub
  • stub-body-multiple-statements
  • no-return-argument-annotation-in-stub
  • unannotated-assignment-in-stub
  • string-or-bytes-too-long
  • numeric-literal-too-long
  • pytest-incorrect-fixture-name-underscore
  • missing-whitespace
  • unexpected-spaces-around-keyword-parameter-equals
  • missing-whitespace-around-parameter-equals
  • missing-whitespace-after-keyword
  • io-error
  • syntax-error

@harupy harupy mentioned this issue Aug 15, 2023
konstin added a commit that referenced this issue Aug 22, 2023
`IOError` is special, it is not actually a lint but an error before
linting. I'm not entirely sure how to document it since it does not
match the general lint rule pattern (`Checks that the file can be read
in its entirety.` is imho worse).

I added the in my experience two most common reasons for io errors on
unix systems and linked two tutorials on how to fix them.

See #2646

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
charliermarsh pushed a commit that referenced this issue Sep 12, 2023
## Summary

Add documentation to `duplicate-union-member` (`PYI016`) rule. Related
to #2646.

## Test Plan

`python scripts/check_docs_formatted.py`
charliermarsh pushed a commit that referenced this issue Sep 18, 2023
## Summary

Add documentation to `pass-statement-stub-body` (`PYI009`) rule. Related
to #2646.

## Test Plan

`python scripts/check_docs_formatted.py`
charliermarsh pushed a commit that referenced this issue Sep 19, 2023
## Summary

Add documentation to `non-empty-stub-body` (`PYI010`) rule. Related to
#2646.

## Test Plan

`python scripts/check_docs_formatted.py`
charliermarsh pushed a commit that referenced this issue Sep 29, 2023
…0`] (#7708)

## Summary

The markdown documentation was present, but in the wrong place, so was
not displaying on the website. I moved it and added some references.

Related to #2646.

## Test Plan

`python scripts/check_docs_formatted.py`
@zanieb zanieb linked a pull request Oct 2, 2023 that will close this issue
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 a pull request may close this issue.

7 participants