question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrectly marks python version when code has if statement/hasattr check

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
netromdkcommented, Sep 7, 2019

Okay, one more way to exclude, @vikahl 😛 As mentioned in the Analysis Exclusions section:

import ssl
tls_version = ssl.PROTOCOL_TLSv1
if hasattr(ssl, "PROTOCOL_TLS"):  # novermin
  tls_version = ssl.PROTOCOL_TLS
1reaction
vikahlcommented, Sep 5, 2019

That’s actually perfect, great work with the new flags!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found