github / github/codeql

assignment is unnessary under suppress()

Open
#7,638 1 comment 0 reactions 0 assignees View on GitHub
false-positive not security Python
Dominant language
CodeQL
Stars
10.1k
Forks
2.1k
Avg merge
2d 15h
Merged PRs (30d)
141

Description

Maybe a bit of an edge case, but this code gives warning of unnessary assignments:
```
t = "<>"
with suppress(AttributeError):
# Set to type arg.
t = cls = get_args(self.__orig_class__)[0]
# If a class, set to the qualname.
t = cls.__qualname__
```

It should probably recognise that any code in a `suppress()` block may not actually run to completion.

https://lgtm.com/projects/g/aio-libs/aiohttp/snapshot/d6d827d7b26f2a54999f8a150ef230fe627aa435/files/aiohttp/helpers.py?sort=name&dir=ASC&mode=heatmap#x6cb8804f71fae0f2:1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.