pyauth / pyotp

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

Use mypy recommended conditional imports for compats #154

Closed adferrand closed 1 year ago

adferrand commented 1 year 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 1 year ago

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