Skip to content

Commit 44bd571

Browse files
committed
Update README wrt. self-doc and PEP 701 f-strings
1 parent 0adb589 commit 44bd571

1 file changed

Lines changed: 30 additions & 25 deletions

File tree

README.rst

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,38 +136,43 @@ on how to get hooks set up on your project.
136136
Features
137137
========
138138

139-
Features detected include v2/v3 ``print expr`` and ``print(expr)``, ``long``, f-strings, coroutines
140-
(``async`` and ``await``), asynchronous generators (``await`` and ``yield`` in same function),
141-
asynchronous comprehensions, ``await`` in comprehensions, asynchronous ``for``-loops, boolean
142-
constants, named expressions, keyword-only parameters, positional-only parameters, ``nonlocal``,
143-
``yield from``, exception context cause (``raise .. from ..``), ``except*``, ``set`` literals,
144-
``set`` comprehensions, ``dict`` comprehensions, infix matrix multiplication, ``"..".format(..)``,
145-
imports (``import X``, ``from X import Y``, ``from X import *``), function calls wrt. name and
146-
kwargs, ``strftime`` + ``strptime`` directives used, function and variable annotations (also
147-
``Final`` and ``Literal``), ``continue`` in ``finally`` block, modular inverse ``pow()``, array
148-
typecodes, codecs error handler names, encodings, ``%`` formatting and directives for bytes and
149-
bytearray, ``with`` statement, asynchronous ``with`` statement, multiple context expressions in a
150-
``with`` statement, multiple context expressions in a ``with`` statement grouped with parenthesis,
151-
unpacking assignment, generalized unpacking, ellipsis literal (``...``) out of slices, dictionary
152-
union (``{..} | {..}``), dictionary union merge (``a = {..}; a |= {..}``), builtin generic type
153-
annotations (``list[str]``), function decorators, class decorators, relaxed decorators,
154-
``metaclass`` class keyword, pattern matching with ``match``, union types written as ``X | Y``, type
155-
alias statements (``type X = SomeType``), type alias statements with lambdas/comprehensions in class
156-
scopes, generic classes (``class C[T]: ...``), and template string literals (``t'{var}'``). It tries
157-
to detect and ignore user-defined functions, classes, arguments, and variables with names that clash
158-
with library-defined symbols.
139+
Features detected include v2/v3 ``print expr`` and ``print(expr)``, ``long``, f-strings,
140+
self-documenting f-strings (``f'{a=}'``), PEP 701 f-strings (same-quote nesting, multi-line
141+
expressions, comments/backslashes in expressions, 3.12+), coroutines (``async`` and ``await``),
142+
asynchronous generators (``await`` and ``yield`` in same function), asynchronous comprehensions,
143+
``await`` in comprehensions, asynchronous ``for``-loops, boolean constants, named expressions,
144+
keyword-only parameters, positional-only parameters, ``nonlocal``, ``yield from``, exception context
145+
cause (``raise .. from ..``), ``except*``, ``set`` literals, ``set`` comprehensions, ``dict``
146+
comprehensions, infix matrix multiplication, ``"..".format(..)``, imports (``import X``, ``from X
147+
import Y``, ``from X import *``), function calls wrt. name and kwargs, ``strftime`` + ``strptime``
148+
directives used, function and variable annotations (also ``Final`` and ``Literal``), ``continue`` in
149+
``finally`` block, modular inverse ``pow()``, array typecodes, codecs error handler names,
150+
encodings, ``%`` formatting and directives for bytes and bytearray, ``with`` statement, asynchronous
151+
``with`` statement, multiple context expressions in a ``with`` statement, multiple context
152+
expressions in a ``with`` statement grouped with parenthesis, unpacking assignment, generalized
153+
unpacking, ellipsis literal (``...``) out of slices, dictionary union (``{..} | {..}``), dictionary
154+
union merge (``a = {..}; a |= {..}``), builtin generic type annotations (``list[str]``), function
155+
decorators, class decorators, relaxed decorators, ``metaclass`` class keyword, pattern matching with
156+
``match``, union types written as ``X | Y``, type alias statements (``type X = SomeType``), type
157+
alias statements with lambdas/comprehensions in class scopes, generic classes (``class C[T]: ...``),
158+
and template string literals (``t'{var}'``). It tries to detect and ignore user-defined functions,
159+
classes, arguments, and variables with names that clash with library-defined symbols.
159160

160161
Caveats
161162
=======
162163

163164
For frequently asked questions, check out the `FAQ discussions
164165
<https://github.com/netromdk/vermin/discussions/categories/faq>`__.
165166

166-
Self-documenting fstrings detection has been disabled by default because the built-in AST cannot
167-
distinguish ``f'{a=}'`` from ``f'a={a}'``, for instance, since it optimizes some information away
168-
(`#39 <https://github.com/netromdk/vermin/issues/39>`__). And this incorrectly marks some source
169-
code as using fstring self-doc when only using general fstring. To enable (unstable) fstring
170-
self-doc detection, use ``--feature fstring-self-doc``.
167+
Self-documenting f-strings (``f'{a=}'``) cannot be distinguished from plain f-strings such as
168+
``f'a={a}'`` by the AST alone, because the parser optimizes some information away (`#39
169+
<https://github.com/netromdk/vermin/issues/39>`__). Vermin therefore also verifies against the
170+
source code, and this detection is gated behind ``--feature fstring-self-doc`` since it relies on
171+
heuristics that may not cover all edge cases.
172+
173+
PEP 701 f-string features require Python 3.12+. Vermin detects these using AST analysis combined
174+
with source code heuristics, gated behind ``--feature fstring-pep701``, which requires Vermin to run
175+
on Python 3.12+ to parse the syntax (`#264 <https://github.com/netromdk/vermin/issues/264>`__).
171176

172177
Detecting union types (``X | Y`` `PEP 604 <https://www.python.org/dev/peps/pep-0604/>`__) can be
173178
tricky because Vermin doesn't know all underlying details of constants and types since it parses and

0 commit comments

Comments
 (0)