LGTM.com - false positive `unhashable` alert indexing list with slice
Offen
false-positive
Python
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.1k
- Forks
- 2.1k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 141
Beschreibung
Consider the following example (reduced version of the actual alert):
```python
def access_one_or_all(one=False):
if one:
accessor = 0
else:
accessor = slice(None)
mylist = [1,2,3]
return mylist[accessor]
```
This is valid python code, but LGTM gives me the following alert:
`This instance of slice is unhashable.`
**URL to the alert on the project page on LGTM.com**
https://lgtm.com/projects/g/ntjess/s3a/snapshot/8565aa0f07a734d5b92e29b61cd3e6169e67f704/files/s3a/compio/helpers.py#L61
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.