'VS Code & pylance: Avoid squiggly line when import for python2/python3

I am working on code that supports python2 and python3 using the latest VS Code (v1.64.2) and pylance. My 'issue' is rather cosmetic, but still, I wonder if there is an option to get rid of the yellow squiggly line generated by pylance.

enter image description here

Is there a cleverer way to do the import or a way to tell pylance not to add the squiggly line? Thx!

For easier reproducibility, here to dummy code:

try:
    # python2
    import xmlrpclib as xmlrpcclient
except ImportError:
    # python3
    import xmlrpc.client as xmlrpcclient


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source