Closed
Description
Bug description
# pylint: disable=missing-module-docstring, missing-function-docstring
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing_extensions import assert_type
else:
def assert_type(val, _):
return val
ANSWER = 42
assert_type(ANSWER, int)
Configuration
No response
Command used
pylint a.py
Pylint output
************* Module a
a.py:13:0: E0601: Using variable 'assert_type' before assignment (used-before-assignment)
------------------------------------------------------------------
Your code has been rated at 2.86/10 (previous run: 2.86/10, +0.00)
Expected behavior
This is a false positive, as assert_type
is defined in both branches of the if
.
Pylint version
pylint 2.15.0
astroid 2.12.4
Python 3.10.6 (main, Aug 3 2022, 17:39:45) [GCC 12.1.1 20220730]
OS / Environment
Archlinux
Additional dependencies
astroid==2.12.4
dill==0.3.5.1
isort==5.10.1
lazy-object-proxy==1.7.1
mccabe==0.7.0
platformdirs==2.5.2
pylint==2.15.0
tomli==2.0.1
tomlkit==0.11.4
wrapt==1.14.1