Bug description
We're looking to solve all the cases of possibly-used-before-assignment in our codebase. An example was caught by an LLM tool and I was surprised to find pylint didn't catch it.
If err in the below example has a type annotation then pylint will not complain about it possibly being used before assignment. If the type annotation is removed then it works.
result: str | None = None
err: CustomErrReportingClass
try:
result = fetch_result()
except SpecialException1:
err = CustomErrOne()
except SpecialException2:
err = CustomErrTwo()
if not result:
report_error(err) # expecting pylint to complain here
Configuration
I'm using pylint with pre-commit. with this config.
repo: https://github.com/pycqa/pylint
rev: v4.0.4
hooks:
- id: pylint
name: pylint
types: [python]
require_serial: true
args:
[
"-rn",
"-sn",
"--disable=all",
"--enable=E0601,E0606",
]
files: src/
Command used
`pre-commit run --all-files`
Though invoking pylint directly also gives the same result.
Pylint output
Nothing about this code is returned.
Expected behavior
Expecting this to be objected to as possibly-used-before-assignment
Pylint version
pylint 4.0.4
python 3.10.19
OS / Environment
Ubuntu in WSL2 or in a docker container also running ubuntu
Additional dependencies
Bug description
We're looking to solve all the cases of
possibly-used-before-assignmentin our codebase. An example was caught by an LLM tool and I was surprised to find pylint didn't catch it.If err in the below example has a type annotation then pylint will not complain about it possibly being used before assignment. If the type annotation is removed then it works.
Configuration
I'm using pylint with pre-commit. with this config.
repo: https://github.com/pycqa/pylint rev: v4.0.4 hooks: - id: pylint name: pylint types: [python] require_serial: true args: [ "-rn", "-sn", "--disable=all", "--enable=E0601,E0606", ] files: src/Command used
`pre-commit run --all-files`Though invoking pylint directly also gives the same result.
Pylint output
Nothing about this code is returned.
Expected behavior
Expecting this to be objected to as possibly-used-before-assignment
Pylint version
OS / Environment
Ubuntu in WSL2 or in a docker container also running ubuntu
Additional dependencies