-
Notifications
You must be signed in to change notification settings - Fork 26
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
Vermin reports 3.6 instead of 3.8 on files with self-documenting f-strings #77
Comments
Thanks for reaching out. If you read the caveats section of the readme, it says:
The project uses the built-in lexer and parser that Python itself uses such that it is always in line with the features of the language - and how to parse them. Unfortunately, it optimizes away important information in the case of self-documenting fstrings, which is why the feature is marked as unstable because it cannot be precise enough without the information. It's unfortunate but it does not make sense, for the project, to change lexer and parser. That would also incur additional dependencies to the project that changes the minimum version of Python needed to run it. If you have the following code: a = 10
print(f"{a=}") And run Vermin with the feature enabled, you'll get: % ./vermin.py -vv --feature fstring-self-doc test.py
Detecting python files..
Analyzing using 8 processes..
!2, 3.8 test.py
f-strings requires !2, 3.6
print(expr) requires 2.0, 3.0
self-documenting fstrings requires !2, 3.8
Minimum required versions: 3.8
Incompatible versions: 2 I hope that is sufficient for your cases. |
Sorry, I totally missed the caveats. I will use |
Great. No worries! |
Describe the bug
Vermin fails to detect self-documenting f-string syntax, so its result may not accurately report the minimum Python version required to run a script. Specifically, these f-strings are a Python 3.8 feature, but Vermin reports 3.6.
To Reproduce
Run Vermin on a file containing a self-documenting f-string. This can be as easy as the following script:
Vermin reports Python 3.6 as the minimum required version, but running such code on Python 3.6 or 3.7 will fail with
SyntaxError: invalid syntax
.Expected behavior
Vermin should report 3.8 as the minimum required version to run the code.
Environment (please complete the following information):
Additional context
This is likely related to issue #39. From that discussion it seems
ast
is not the best way to detect such idioms, because it is essentially syntactic sugar forf"a={a}"
.The text was updated successfully, but these errors were encountered: