File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ RST216 Multiple roles in interpreted text (both prefix and suffix present; only
109109RST217 Mismatch: both interpreted text role suffix and reference suffix.
110110RST218 Literal block expected; none found.
111111RST219 Inline substitution_reference start-string without end-string.
112+ RST220
112113RST299 Previously unseen warning, not yet assigned a unique code.
113114====== =======================================================================
114115
@@ -245,7 +246,8 @@ Version History
245246======= ========== ===========================================================
246247Version Released Changes
247248------- ---------- -----------------------------------------------------------
248- v0.3.1 *Pending * - Requires Python 3.8 or later (no code changes).
249+ v0.3.1 *Pending * - Adds ``RST220 `` for redefined anonymous links.
250+ - Requires Python 3.8 or later (no code changes).
249251v0.3.0 2022-11-16 - Replaced ``setup.py `` with ``pyproject.toml ``.
250252v0.2.7 2022-07-15 - Fix where function signature occurred in docstring body.
251253v0.2.6 2022-06-07 - Configuration option to define additional substitutions
Original file line number Diff line number Diff line change 6363 "Mismatch: both interpreted text role suffix and reference suffix." : 17 ,
6464 "Literal block expected; none found." : 18 ,
6565 "Inline substitution_reference start-string without end-string." : 19 ,
66+ 'Duplicate explicit target name: "*".' : 20 ,
6667}
6768
6869# Level 3 - error
@@ -224,11 +225,12 @@ def run(self):
224225 - ast .get_docstring (node , clean = False ).count ("\n " )
225226 - 1
226227 )
227- assert (
228- node .body [0 ].lineno >= 1 and start >= 0
229- ), "Bad start line, node line number %i for: %s\n " % (
230- node .body [0 ].lineno ,
231- docstring ,
228+ assert node .body [0 ].lineno >= 1 and start >= 0 , (
229+ "Bad start line, node line number %i for: %s\n "
230+ % (
231+ node .body [0 ].lineno ,
232+ docstring ,
233+ )
232234 )
233235 for rst_error in rst_errors :
234236 # TODO - make this a configuration option?
Original file line number Diff line number Diff line change 1+ """Print 'Hello world' to the terminal.
2+
3+ It is common in RST to use unnamed or anonymous links in text (like
4+ `here <https://example.com/t-and-c/>`__ and `here
5+ <https://example.org/co-op-rules.html>`__), but they should have two trailing
6+ underscores!
7+
8+ You *can* use a `single trailing underscore <https://example.com/links.html>`_
9+ but it is treated as an implicitly named link. You can use the exact same link
10+ text and URL again too (`single trailing underscore
11+ <https://example.com/links.html>`_).
12+
13+ However, the missing second underscore becomes a problem if the same link text
14+ is used again for another implicitly named link weth a different URL (e.g.
15+ missing `single trailing underscore <https://example.com/bad.html>`_ *again*).
16+
17+ What happens here?
18+
19+ $ flake8 --select RST RST220/dup_explicit_target.py
20+ RST220/dup_explicit_target.py:15:1: RST220 Duplicate explicit target name: "single trailing underscore".
21+
22+ This file triggers an error when the implicitly named link is redefined.
23+ """
24+
25+ print ("Hello world" )
You can’t perform that action at this time.
0 commit comments