flake8-type-checking
flake8-type-checking copied to clipboard
Flake8 plugin for managing type-checking imports & forward references.
See the following code: https://github.com/mesonbuild/meson/blob/d4733984e9e3970c23a9436dce8919f8a25194e8/mesonbuild/compilers/mixins/gnu.py#L30-L39 ``` 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,...
flake8-pyi has started reporting the following warning if `from __future__ import annotations` is in a stub file: `Y044 "from __future__ import annotations" has no effect in stub files.` This is...
Fixes #121
Given the following code: ```python from __future__ import annotations from collections.abc import Callable from typing import Any, cast from pendulum.datetime import DateTime from .foo import Foo a = cast('Callable[..., Any]',...
As mentioned in #52 According to this test, `CustomType` should be moved to a `TYPE_CHECKING` block. ```python @pytest.mark.parametrize('fdef', ['def', 'async def']) def test_api_router_decorated_function_return_type(fdef): """ We don't care about return types....
https://github.com/snok/flake8-type-checking/blob/7aa077e3a34d966c3810c2d2ee6f5b098dcb2e00/flake8_type_checking/checker.py#L201C2-L201C2 ``` def visit_FunctionDef(self, node: FunctionDef) -> None: """Remove and map function arguments and returns.""" if self._function_is_wrapped_by_validate_arguments(node): for path in [node.args.args, node.args.kwonlyargs, node.args.posonlyargs]: for argument in path: if hasattr(argument, 'annotation')...
I noticed some really strange behavior. Given the following example: ```python from __future__ import annotations import datetime import pathlib import uuid from enum import Enum from typing import TYPE_CHECKING from...
This example in https://github.com/snok/drf-openapi-tester isn't flagged with a TC100 when it should be. The `Response` annotation will otherwise lead to a runtime error. ```python from typing import TYPE_CHECKING from django.urls...
Hi, It would be great if there was an option to move an import into a type checking block automatically if it detects an issue.
injector library requires all annotation of function available in the runtime, not only dependencies under "Inject" annotation.