pyauth / pyotp

Python One-Time Password Library
https://pyauth.github.io/pyotp/
Other
2.91k stars 319 forks source link

Use mypy recommended conditional imports for compats #154

Closed adferrand closed 10 months ago

adferrand commented 10 months ago

Hello !

Concerning conditional imports based on the actual Python version at runtime, Mypy recommendation is to explicitly use sys.version_info to trigger the relevant import depending on the Python version.

Reference to the documentation: https://mypy.readthedocs.io/en/stable/common_issues.html#python-version-and-system-platform-checks

I apply this approach to the compat module.

As a consequence, Mypy does an educated guess on the imports, and #type: ignore inline comment is not needed anymore.

kislyuk commented 10 months ago

Thanks! Did not know that, will use from now on.