if T.TYPE_CHECKING:
from ...compilers.compilers import Compiler
else:
# This is a bit clever, for mypy we pretend that these mixins descend from
# Compiler, so we get all of the methods and attributes defined for us, but
# for runtime we make them descend from object (which all classes normally
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
...
# this is a mixin
class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
mesonbuild/compilers/mixins/gnu.py:33:1: TC004 Move import 'Compiler' out of type-checking block. Import is used for more than type hinting.
But weirdly enough, this type-checking only import is shadowed at runtime and thus not actually used. Not sure if there's a good way to detect it -- even the code comments imply it's a bit too clever.
See the following code: https://github.com/mesonbuild/meson/blob/d4733984e9e3970c23a9436dce8919f8a25194e8/mesonbuild/compilers/mixins/gnu.py#L30-L39
This reports:
But weirdly enough, this type-checking only import is shadowed at runtime and thus not actually used. Not sure if there's a good way to detect it -- even the code comments imply it's a bit too clever.