From 1ef9c337cad36ac6c80eab86622f8ae9fc8d1075 Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Wed, 19 Jun 2024 23:57:40 +0500 Subject: [PATCH] flake8-docstrings --- .flake8 | 33 +++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 1 + tests/test_dupefilters.py | 2 +- tests/test_linkextractors.py | 2 +- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index b6048c9ee..222ba7179 100644 --- a/.flake8 +++ b/.flake8 @@ -2,11 +2,44 @@ max-line-length = 119 ignore = + # black disagrees with flake8 about these E203, E501, E701, E704, W503 # docstring does contain unindexed parameters P102 # other string does contain unindexed parameters P103 + # Missing docstring in public module + D100 + # Missing docstring in public class + D101 + # Missing docstring in public method + D102 + # Missing docstring in public function + D103 + # Missing docstring in public package + D104 + # Missing docstring in magic method + D105 + # Missing docstring in public nested class + D106 + # Missing docstring in __init__ + D107 + # One-line docstring should fit on one line with quotes + D200 + # No blank lines allowed after function docstring + D202 + # 1 blank line required between summary line and description + D205 + # Multi-line docstring closing quotes should be on a separate line + D209 + # First line should end with a period + D400 + # First line should be in imperative mood; try rephrasing + D401 + # First line should not be the function's "signature" + D402 + # First word of the first line should be properly capitalized + D403 exclude = docs/conf.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 974d397c8..6b60eff68 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,7 @@ repos: additional_dependencies: - flake8-comprehensions - flake8-debugger + - flake8-docstrings - flake8-string-format - repo: https://github.com/psf/black.git rev: 24.2.0 diff --git a/tests/test_dupefilters.py b/tests/test_dupefilters.py index aa0975555..f617fc027 100644 --- a/tests/test_dupefilters.py +++ b/tests/test_dupefilters.py @@ -146,7 +146,7 @@ class RFPDupeFilterTest(unittest.TestCase): case_insensitive_dupefilter.close("finished") def test_seenreq_newlines(self): - """Checks against adding duplicate \r to + r"""Checks against adding duplicate \r to line endings on Windows platforms.""" r1 = Request("http://scrapytest.org/1") diff --git a/tests/test_linkextractors.py b/tests/test_linkextractors.py index d9c09a16a..b1043c111 100644 --- a/tests/test_linkextractors.py +++ b/tests/test_linkextractors.py @@ -186,7 +186,7 @@ class Base: ) def test_nofollow(self): - '''Test the extractor's behaviour for links with rel="nofollow"''' + """Test the extractor's behaviour for links with rel='nofollow'""" html = b"""Page title<title> <body>