Skip to content

Commit

Permalink
Use version-dependent import mypy idiom @ _actions
Browse files Browse the repository at this point in the history
This approach is preferred over the try/except one to help MyPy deal
with the compatibility quirks according to:
* ansible/ansible-lint#915 (comment)
* python/typeshed#3500 (comment)
  • Loading branch information
webknjaz committed Jan 27, 2022
1 parent 4849ddf commit d66e998
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ansible_navigator/actions/_actions.py
Expand Up @@ -5,6 +5,7 @@
import importlib
import logging
import re
import sys

from collections import namedtuple
from typing import Any
Expand All @@ -15,10 +16,12 @@
from typing import Tuple


try:
# mypy/pylint idiom for py36 compatibility
# https://github.com/python/typeshed/issues/3500#issuecomment-560958608
if sys.version_info >= (3, 7):
from importlib import resources
except ImportError:
import importlib_resources as resources # type: ignore[import, no-redef]
else:
import importlib_resources as resources


logger = logging.getLogger(__name__)
Expand Down

0 comments on commit d66e998

Please sign in to comment.