Incorrectly marks python version when code has if statement/hasattr check
See original GitHub issueDescribe the bug Vermin incorrectly marks code as requiring >= 3.6 when conditionals handles earlier python versions as well.
From Paho MQTT (client.py), the if hasattr( allows for prior versions to 3.6 as well.
# Create SSLContext object
if tls_version is None:
tls_version = ssl.PROTOCOL_TLSv1
# If the python version supports it, use highest TLS version automatically
if hasattr(ssl, "PROTOCOL_TLS"):
tls_version = ssl.PROTOCOL_TLS
context = ssl.SSLContext(tls_version)
To Reproduce Run vermin on the code example, or clone paho mqtt and run it on the master branch.
Expected behavior Minimum version 3.4.
Environment (please complete the following information):
- Vermin 0.6.1
- Python 3.7.4
Other comments Excellent tool, thank you for creating it and keep up the good work! 👏
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Python's hasattr sometimes returns incorrect results
The Python 2 implementation of hasattr is fairly naive, it just tries to access that attribute and see whether it raises an exception...
Read more >D43165 [lit] Fix problem in how Python versions open files ...
I checked the code and this happens indirectly inside of a call to compareDirectoryTrees. So indeed, it would be hard to explicitly request...
Read more >unittest — Unit testing framework — Python 3.11.1 ...
New in version 3.1. Unittest supports skipping individual test methods and even whole classes of tests. In addition, it supports marking a test...
Read more >PythonTA Checks
PythonTA Checks . This page describes in greater detail the errors that PythonTA checks for. If anything is unclear, incorrect, or missing, please...
Read more >Robot Framework User Guide
If running these commands fails with a message saying that the command is not found or recognized, a good first step is double-checking...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Okay, one more way to exclude, @vikahl 😛 As mentioned in the Analysis Exclusions section:
That’s actually perfect, great work with the new flags!