flake8-bugbear 24.2.6__tar.gz → 24.4.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flake8-bugbear-24.2.6/flake8_bugbear.egg-info → flake8_bugbear-24.4.26}/PKG-INFO +12 -1
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/README.rst +11 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/bugbear.py +99 -20
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26/flake8_bugbear.egg-info}/PKG-INFO +12 -1
- flake8_bugbear-24.4.26/tests/b909.py +152 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b950.py +1 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/test_bugbear.py +35 -18
- flake8-bugbear-24.2.6/tests/b909.py +0 -75
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/LICENSE +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/MANIFEST.in +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/flake8_bugbear.egg-info/SOURCES.txt +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/flake8_bugbear.egg-info/dependency_links.txt +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/flake8_bugbear.egg-info/entry_points.txt +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/flake8_bugbear.egg-info/not-zip-safe +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/flake8_bugbear.egg-info/requires.txt +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/flake8_bugbear.egg-info/top_level.txt +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/pyproject.toml +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/setup.cfg +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/setup.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/__init__.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b001.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b002.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b003.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b004.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b005.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b006_b008.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b007.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b008_extended.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b009_b010.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b011.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b012.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b013.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b014.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b015.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b016.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b017.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b018_classes.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b018_functions.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b018_modules.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b018_nested.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b019.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b020.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b021.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b022.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b023.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b024.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b025.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b026.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b027.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b028.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b029.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b030.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b031.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b032.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b033.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b034.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b035.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b036.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b037.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b901.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b902.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b902_extended.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b902_py38.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b903.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b904.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b905_py310.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b906.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b907.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tests/b908.py +0 -0
- {flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flake8-bugbear
|
|
3
|
-
Version: 24.
|
|
3
|
+
Version: 24.4.26
|
|
4
4
|
Summary: A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
|
|
5
5
|
Author-email: Łukasz Langa <lukasz@langa.pl>
|
|
6
6
|
License: MIT
|
|
@@ -389,6 +389,17 @@ MIT
|
|
|
389
389
|
Change Log
|
|
390
390
|
----------
|
|
391
391
|
|
|
392
|
+
24.4.26
|
|
393
|
+
~~~~~~~
|
|
394
|
+
|
|
395
|
+
* B909: Fix false positive affecting containers of mutables (#469)
|
|
396
|
+
|
|
397
|
+
24.4.21
|
|
398
|
+
~~~~~~~
|
|
399
|
+
|
|
400
|
+
* B950: Add pragma comment to line length ignores (#463)
|
|
401
|
+
* B909: Add more cases to detect + more container mutating functions (#460)
|
|
402
|
+
|
|
392
403
|
24.2.6
|
|
393
404
|
~~~~~~
|
|
394
405
|
|
|
@@ -351,6 +351,17 @@ MIT
|
|
|
351
351
|
Change Log
|
|
352
352
|
----------
|
|
353
353
|
|
|
354
|
+
24.4.26
|
|
355
|
+
~~~~~~~
|
|
356
|
+
|
|
357
|
+
* B909: Fix false positive affecting containers of mutables (#469)
|
|
358
|
+
|
|
359
|
+
24.4.21
|
|
360
|
+
~~~~~~~
|
|
361
|
+
|
|
362
|
+
* B950: Add pragma comment to line length ignores (#463)
|
|
363
|
+
* B909: Add more cases to detect + more container mutating functions (#460)
|
|
364
|
+
|
|
354
365
|
24.2.6
|
|
355
366
|
~~~~~~
|
|
356
367
|
|
|
@@ -8,7 +8,7 @@ import math
|
|
|
8
8
|
import re
|
|
9
9
|
import sys
|
|
10
10
|
import warnings
|
|
11
|
-
from collections import namedtuple
|
|
11
|
+
from collections import defaultdict, namedtuple
|
|
12
12
|
from contextlib import suppress
|
|
13
13
|
from functools import lru_cache, partial
|
|
14
14
|
from keyword import iskeyword
|
|
@@ -17,7 +17,7 @@ from typing import Dict, List, Set, Union
|
|
|
17
17
|
import attr
|
|
18
18
|
import pycodestyle
|
|
19
19
|
|
|
20
|
-
__version__ = "24.
|
|
20
|
+
__version__ = "24.4.26"
|
|
21
21
|
|
|
22
22
|
LOG = logging.getLogger("flake8.bugbear")
|
|
23
23
|
CONTEXTFUL_NODES = (
|
|
@@ -87,7 +87,9 @@ class BugBearChecker:
|
|
|
87
87
|
|
|
88
88
|
The following simple checks are based on the raw lines, not the AST.
|
|
89
89
|
"""
|
|
90
|
-
noqa_type_ignore_regex = re.compile(
|
|
90
|
+
noqa_type_ignore_regex = re.compile(
|
|
91
|
+
r"#\s*(noqa|type:\s*ignore|pragma:)[^#\r\n]*$"
|
|
92
|
+
)
|
|
91
93
|
for lineno, line in enumerate(self.lines, start=1):
|
|
92
94
|
# Special case: ignore long shebang (following pycodestyle).
|
|
93
95
|
if lineno == 1 and line.startswith("#!"):
|
|
@@ -1495,15 +1497,17 @@ class BugBearVisitor(ast.NodeVisitor):
|
|
|
1495
1497
|
format_specifier = re.sub(r"\.\d*", "", format_specifier)
|
|
1496
1498
|
|
|
1497
1499
|
# skip if any invalid characters in format spec
|
|
1498
|
-
invalid_characters = "".join(
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1500
|
+
invalid_characters = "".join(
|
|
1501
|
+
(
|
|
1502
|
+
"=", # align character only valid for numerics
|
|
1503
|
+
"+- ", # sign
|
|
1504
|
+
"0123456789", # width digits
|
|
1505
|
+
"z", # coerce negative zero floating point to positive
|
|
1506
|
+
"#", # alternate form
|
|
1507
|
+
"_,", # thousands grouping
|
|
1508
|
+
"bcdeEfFgGnoxX%", # various number specifiers
|
|
1509
|
+
)
|
|
1510
|
+
)
|
|
1507
1511
|
if set(format_specifier).intersection(invalid_characters):
|
|
1508
1512
|
current_mark = variable = None
|
|
1509
1513
|
continue
|
|
@@ -1577,13 +1581,17 @@ class BugBearVisitor(ast.NodeVisitor):
|
|
|
1577
1581
|
def check_for_b909(self, node: ast.For):
|
|
1578
1582
|
if isinstance(node.iter, ast.Name):
|
|
1579
1583
|
name = _to_name_str(node.iter)
|
|
1584
|
+
key = _to_name_str(node.target)
|
|
1580
1585
|
elif isinstance(node.iter, ast.Attribute):
|
|
1581
1586
|
name = _to_name_str(node.iter)
|
|
1587
|
+
key = _to_name_str(node.target)
|
|
1582
1588
|
else:
|
|
1583
1589
|
return
|
|
1584
|
-
checker = B909Checker(name)
|
|
1590
|
+
checker = B909Checker(name, key)
|
|
1585
1591
|
checker.visit(node.body)
|
|
1586
|
-
for mutation in
|
|
1592
|
+
for mutation in itertools.chain.from_iterable(
|
|
1593
|
+
m for m in checker.mutations.values()
|
|
1594
|
+
):
|
|
1587
1595
|
self.errors.append(B909(mutation.lineno, mutation.col_offset))
|
|
1588
1596
|
|
|
1589
1597
|
|
|
@@ -1597,6 +1605,46 @@ def compose_call_path(node):
|
|
|
1597
1605
|
yield node.id
|
|
1598
1606
|
|
|
1599
1607
|
|
|
1608
|
+
def _tansform_slice_to_py39(slice: ast.Slice) -> ast.Slice | ast.Name:
|
|
1609
|
+
"""Transform a py38 style slice to a py39 style slice.
|
|
1610
|
+
|
|
1611
|
+
In py39 the slice was changed to have simple names directly assigned:
|
|
1612
|
+
```py
|
|
1613
|
+
# code:
|
|
1614
|
+
some_dict[key]
|
|
1615
|
+
# py38:
|
|
1616
|
+
slice=Index(
|
|
1617
|
+
value=Name(
|
|
1618
|
+
lineno=152,
|
|
1619
|
+
col_offset=14,
|
|
1620
|
+
end_lineno=152,
|
|
1621
|
+
end_col_offset=17,
|
|
1622
|
+
id='key',
|
|
1623
|
+
ctx=Load()
|
|
1624
|
+
),
|
|
1625
|
+
)
|
|
1626
|
+
# py39 onwards:
|
|
1627
|
+
slice=Name(
|
|
1628
|
+
lineno=152,
|
|
1629
|
+
col_offset=14,
|
|
1630
|
+
end_lineno=152,
|
|
1631
|
+
end_col_offset=17,
|
|
1632
|
+
id='key',
|
|
1633
|
+
ctx=Load()
|
|
1634
|
+
),
|
|
1635
|
+
```
|
|
1636
|
+
|
|
1637
|
+
> Changed in version 3.9: Simple indices are represented by their value,
|
|
1638
|
+
> extended slices are represented as tuples.
|
|
1639
|
+
from https://docs.python.org/3/library/ast.html#module-ast
|
|
1640
|
+
"""
|
|
1641
|
+
if sys.version_info >= (3, 9):
|
|
1642
|
+
return slice
|
|
1643
|
+
if isinstance(slice, ast.Index) and isinstance(slice.value, ast.Name):
|
|
1644
|
+
slice = slice.value
|
|
1645
|
+
return slice
|
|
1646
|
+
|
|
1647
|
+
|
|
1600
1648
|
class B909Checker(ast.NodeVisitor):
|
|
1601
1649
|
# https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types
|
|
1602
1650
|
MUTATING_FUNCTIONS = (
|
|
@@ -1609,24 +1657,48 @@ class B909Checker(ast.NodeVisitor):
|
|
|
1609
1657
|
"insert",
|
|
1610
1658
|
"pop",
|
|
1611
1659
|
"popitem",
|
|
1660
|
+
"setdefault",
|
|
1661
|
+
"update",
|
|
1662
|
+
"intersection_update",
|
|
1663
|
+
"difference_update",
|
|
1664
|
+
"symmetric_difference_update",
|
|
1665
|
+
"add",
|
|
1666
|
+
"discard",
|
|
1612
1667
|
)
|
|
1613
1668
|
|
|
1614
|
-
def __init__(self, name: str):
|
|
1669
|
+
def __init__(self, name: str, key: str):
|
|
1615
1670
|
self.name = name
|
|
1616
|
-
self.
|
|
1671
|
+
self.key = key
|
|
1672
|
+
self.mutations = defaultdict(list)
|
|
1673
|
+
self._conditional_block = 0
|
|
1674
|
+
|
|
1675
|
+
def visit_Assign(self, node: ast.Assign):
|
|
1676
|
+
for target in node.targets:
|
|
1677
|
+
if (
|
|
1678
|
+
isinstance(target, ast.Subscript)
|
|
1679
|
+
and _to_name_str(target.value) == self.name
|
|
1680
|
+
and _to_name_str(_tansform_slice_to_py39(target.slice)) != self.key
|
|
1681
|
+
):
|
|
1682
|
+
self.mutations[self._conditional_block].append(node)
|
|
1683
|
+
self.generic_visit(node)
|
|
1684
|
+
|
|
1685
|
+
def visit_AugAssign(self, node: ast.AugAssign):
|
|
1686
|
+
if _to_name_str(node.target) == self.name:
|
|
1687
|
+
self.mutations[self._conditional_block].append(node)
|
|
1688
|
+
self.generic_visit(node)
|
|
1617
1689
|
|
|
1618
1690
|
def visit_Delete(self, node: ast.Delete):
|
|
1619
1691
|
for target in node.targets:
|
|
1620
1692
|
if isinstance(target, ast.Subscript):
|
|
1621
1693
|
name = _to_name_str(target.value)
|
|
1622
1694
|
elif isinstance(target, (ast.Attribute, ast.Name)):
|
|
1623
|
-
name =
|
|
1695
|
+
name = "" # ignore "del foo"
|
|
1624
1696
|
else:
|
|
1625
1697
|
name = "" # fallback
|
|
1626
1698
|
self.generic_visit(target)
|
|
1627
1699
|
|
|
1628
1700
|
if name == self.name:
|
|
1629
|
-
self.mutations.append(node)
|
|
1701
|
+
self.mutations[self._conditional_block].append(node)
|
|
1630
1702
|
|
|
1631
1703
|
def visit_Call(self, node: ast.Call):
|
|
1632
1704
|
if isinstance(node.func, ast.Attribute):
|
|
@@ -1638,17 +1710,24 @@ class B909Checker(ast.NodeVisitor):
|
|
|
1638
1710
|
function_object == self.name
|
|
1639
1711
|
and function_name in self.MUTATING_FUNCTIONS
|
|
1640
1712
|
):
|
|
1641
|
-
self.mutations.append(node)
|
|
1713
|
+
self.mutations[self._conditional_block].append(node)
|
|
1642
1714
|
|
|
1643
1715
|
self.generic_visit(node)
|
|
1644
1716
|
|
|
1717
|
+
def visit_If(self, node: ast.If):
|
|
1718
|
+
self._conditional_block += 1
|
|
1719
|
+
self.visit(node.body)
|
|
1720
|
+
self._conditional_block += 1
|
|
1721
|
+
|
|
1645
1722
|
def visit(self, node):
|
|
1646
1723
|
"""Like super-visit but supports iteration over lists."""
|
|
1647
1724
|
if not isinstance(node, list):
|
|
1648
1725
|
return super().visit(node)
|
|
1649
1726
|
|
|
1650
1727
|
for elem in node:
|
|
1651
|
-
|
|
1728
|
+
if isinstance(elem, ast.Break):
|
|
1729
|
+
self.mutations[self._conditional_block].clear()
|
|
1730
|
+
self.visit(elem)
|
|
1652
1731
|
return node
|
|
1653
1732
|
|
|
1654
1733
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flake8-bugbear
|
|
3
|
-
Version: 24.
|
|
3
|
+
Version: 24.4.26
|
|
4
4
|
Summary: A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
|
|
5
5
|
Author-email: Łukasz Langa <lukasz@langa.pl>
|
|
6
6
|
License: MIT
|
|
@@ -389,6 +389,17 @@ MIT
|
|
|
389
389
|
Change Log
|
|
390
390
|
----------
|
|
391
391
|
|
|
392
|
+
24.4.26
|
|
393
|
+
~~~~~~~
|
|
394
|
+
|
|
395
|
+
* B909: Fix false positive affecting containers of mutables (#469)
|
|
396
|
+
|
|
397
|
+
24.4.21
|
|
398
|
+
~~~~~~~
|
|
399
|
+
|
|
400
|
+
* B950: Add pragma comment to line length ignores (#463)
|
|
401
|
+
* B909: Add more cases to detect + more container mutating functions (#460)
|
|
402
|
+
|
|
392
403
|
24.2.6
|
|
393
404
|
~~~~~~
|
|
394
405
|
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Should emit:
|
|
3
|
+
B999 - on lines 11, 25, 26, 40, 46
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# lists
|
|
7
|
+
|
|
8
|
+
some_list = [1, 2, 3]
|
|
9
|
+
some_other_list = [1, 2, 3]
|
|
10
|
+
for elem in some_list:
|
|
11
|
+
# errors
|
|
12
|
+
some_list.remove(elem)
|
|
13
|
+
del some_list[2]
|
|
14
|
+
some_list.append(elem)
|
|
15
|
+
some_list.sort()
|
|
16
|
+
some_list.reverse()
|
|
17
|
+
some_list.clear()
|
|
18
|
+
some_list.extend([1, 2])
|
|
19
|
+
some_list.insert(1, 1)
|
|
20
|
+
some_list.pop(1)
|
|
21
|
+
some_list.pop()
|
|
22
|
+
|
|
23
|
+
# conditional break should error
|
|
24
|
+
if elem == 2:
|
|
25
|
+
some_list.remove(elem)
|
|
26
|
+
if elem == 3:
|
|
27
|
+
break
|
|
28
|
+
|
|
29
|
+
# non-errors
|
|
30
|
+
some_other_list.remove(elem)
|
|
31
|
+
del some_list
|
|
32
|
+
del some_other_list
|
|
33
|
+
found_idx = some_list.index(elem)
|
|
34
|
+
some_list = 3
|
|
35
|
+
|
|
36
|
+
# unconditional break should not error
|
|
37
|
+
if elem == 2:
|
|
38
|
+
some_list.remove(elem)
|
|
39
|
+
break
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# dicts
|
|
43
|
+
mydicts = {'a': {'foo': 1, 'bar': 2}}
|
|
44
|
+
|
|
45
|
+
for elem in mydicts:
|
|
46
|
+
# errors
|
|
47
|
+
mydicts.popitem()
|
|
48
|
+
mydicts.setdefault('foo', 1)
|
|
49
|
+
mydicts.update({'foo': 'bar'})
|
|
50
|
+
|
|
51
|
+
# no errors
|
|
52
|
+
elem.popitem()
|
|
53
|
+
elem.setdefault('foo', 1)
|
|
54
|
+
elem.update({'foo': 'bar'})
|
|
55
|
+
|
|
56
|
+
# sets
|
|
57
|
+
|
|
58
|
+
myset = {1, 2, 3}
|
|
59
|
+
|
|
60
|
+
for _ in myset:
|
|
61
|
+
# errors
|
|
62
|
+
myset.update({4, 5})
|
|
63
|
+
myset.intersection_update({4, 5})
|
|
64
|
+
myset.difference_update({4, 5})
|
|
65
|
+
myset.symmetric_difference_update({4, 5})
|
|
66
|
+
myset.add(4)
|
|
67
|
+
myset.discard(3)
|
|
68
|
+
|
|
69
|
+
# no errors
|
|
70
|
+
del myset
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# members
|
|
74
|
+
class A:
|
|
75
|
+
some_list: list
|
|
76
|
+
|
|
77
|
+
def __init__(self, ls):
|
|
78
|
+
self.some_list = list(ls)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
a = A((1, 2, 3))
|
|
82
|
+
# ensure member accesses are handled
|
|
83
|
+
for elem in a.some_list:
|
|
84
|
+
a.some_list.remove(elem)
|
|
85
|
+
del a.some_list[2]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# Augassign
|
|
89
|
+
|
|
90
|
+
foo = [1, 2, 3]
|
|
91
|
+
bar = [4, 5, 6]
|
|
92
|
+
for _ in foo:
|
|
93
|
+
foo *= 2
|
|
94
|
+
foo += bar
|
|
95
|
+
foo[1] = 9 #todo
|
|
96
|
+
foo[1:2] = bar
|
|
97
|
+
foo[1:2:3] = bar
|
|
98
|
+
|
|
99
|
+
foo = {1,2,3}
|
|
100
|
+
bar = {4,5,6}
|
|
101
|
+
for _ in foo:
|
|
102
|
+
foo |= bar
|
|
103
|
+
foo &= bar
|
|
104
|
+
foo -= bar
|
|
105
|
+
foo ^= bar
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# more tests for unconditional breaks
|
|
109
|
+
for _ in foo:
|
|
110
|
+
foo.remove(1)
|
|
111
|
+
for _ in bar:
|
|
112
|
+
bar.remove(1)
|
|
113
|
+
break
|
|
114
|
+
break
|
|
115
|
+
|
|
116
|
+
# should not error
|
|
117
|
+
for _ in foo:
|
|
118
|
+
foo.remove(1)
|
|
119
|
+
for _ in bar:
|
|
120
|
+
...
|
|
121
|
+
break
|
|
122
|
+
|
|
123
|
+
# should error (?)
|
|
124
|
+
for _ in foo:
|
|
125
|
+
foo.remove(1)
|
|
126
|
+
if bar:
|
|
127
|
+
bar.remove(1)
|
|
128
|
+
break
|
|
129
|
+
break
|
|
130
|
+
|
|
131
|
+
lst: list[dict] = [{}, {}, {}]
|
|
132
|
+
for dic in lst:
|
|
133
|
+
dic["key"] = False # no error
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
for grammar in grammars:
|
|
138
|
+
errors[grammar.version] = InvalidInput() # no error
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
for key in self.hpo_params:
|
|
143
|
+
if key in nni_config:
|
|
144
|
+
nni_config[key] = self.hpo_params[key] # no error
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
some_dict = {"foo": "bar"}
|
|
148
|
+
for key in some_dict:
|
|
149
|
+
some_dict[key] = 3 # no error
|
|
150
|
+
|
|
151
|
+
for key in some_dict.keys():
|
|
152
|
+
some_dict[key] = 3 # no error
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # noqa"
|
|
28
28
|
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore"
|
|
29
29
|
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # noqa: F401"
|
|
30
|
+
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # pragma: no cover"
|
|
30
31
|
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com#noqa:F401, B950"
|
|
31
32
|
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore[some-code]"
|
|
32
33
|
"https://foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.com # type: ignore[some-code]"
|
|
@@ -894,8 +894,8 @@ class BugbearTestCase(unittest.TestCase):
|
|
|
894
894
|
B950(12, 103, vars=(103, 79)),
|
|
895
895
|
B950(14, 103, vars=(103, 79)),
|
|
896
896
|
B950(21, 97, vars=(97, 79)),
|
|
897
|
-
B950(35, 104, vars=(104, 79)),
|
|
898
897
|
B950(36, 104, vars=(104, 79)),
|
|
898
|
+
B950(37, 104, vars=(104, 79)),
|
|
899
899
|
),
|
|
900
900
|
)
|
|
901
901
|
|
|
@@ -912,8 +912,8 @@ class BugbearTestCase(unittest.TestCase):
|
|
|
912
912
|
B950(12, 103, vars=(103, 79)),
|
|
913
913
|
B950(14, 103, vars=(103, 79)),
|
|
914
914
|
B950(21, 97, vars=(97, 79)),
|
|
915
|
-
B950(35, 104, vars=(104, 79)),
|
|
916
915
|
B950(36, 104, vars=(104, 79)),
|
|
916
|
+
B950(37, 104, vars=(104, 79)),
|
|
917
917
|
),
|
|
918
918
|
)
|
|
919
919
|
|
|
@@ -932,8 +932,8 @@ class BugbearTestCase(unittest.TestCase):
|
|
|
932
932
|
B950(12, 103, vars=(103, 79)),
|
|
933
933
|
B950(14, 103, vars=(103, 79)),
|
|
934
934
|
B950(21, 97, vars=(97, 79)),
|
|
935
|
-
B950(35, 104, vars=(104, 79)),
|
|
936
935
|
B950(36, 104, vars=(104, 79)),
|
|
936
|
+
B950(37, 104, vars=(104, 79)),
|
|
937
937
|
),
|
|
938
938
|
)
|
|
939
939
|
|
|
@@ -974,22 +974,39 @@ class BugbearTestCase(unittest.TestCase):
|
|
|
974
974
|
mock_options = Namespace(select=[], extend_select=["B909"])
|
|
975
975
|
bbc = BugBearChecker(filename=str(filename), options=mock_options)
|
|
976
976
|
errors = list(bbc.run())
|
|
977
|
-
print(errors)
|
|
978
977
|
expected = [
|
|
979
|
-
B909(
|
|
980
|
-
B909(
|
|
981
|
-
B909(
|
|
982
|
-
B909(
|
|
983
|
-
B909(
|
|
984
|
-
B909(
|
|
985
|
-
B909(
|
|
986
|
-
B909(
|
|
987
|
-
B909(
|
|
988
|
-
B909(
|
|
989
|
-
B909(
|
|
990
|
-
B909(
|
|
991
|
-
B909(
|
|
992
|
-
B909(
|
|
978
|
+
B909(12, 4),
|
|
979
|
+
B909(13, 4),
|
|
980
|
+
B909(14, 4),
|
|
981
|
+
B909(15, 4),
|
|
982
|
+
B909(16, 4),
|
|
983
|
+
B909(17, 4),
|
|
984
|
+
B909(18, 4),
|
|
985
|
+
B909(19, 4),
|
|
986
|
+
B909(20, 4),
|
|
987
|
+
B909(21, 4),
|
|
988
|
+
B909(25, 8),
|
|
989
|
+
B909(47, 4),
|
|
990
|
+
B909(48, 4),
|
|
991
|
+
B909(49, 4),
|
|
992
|
+
B909(62, 4),
|
|
993
|
+
B909(63, 4),
|
|
994
|
+
B909(64, 4),
|
|
995
|
+
B909(65, 4),
|
|
996
|
+
B909(66, 4),
|
|
997
|
+
B909(67, 4),
|
|
998
|
+
B909(84, 4),
|
|
999
|
+
B909(85, 4),
|
|
1000
|
+
B909(93, 4),
|
|
1001
|
+
B909(94, 4),
|
|
1002
|
+
B909(95, 4),
|
|
1003
|
+
B909(96, 4),
|
|
1004
|
+
B909(97, 4),
|
|
1005
|
+
B909(102, 4),
|
|
1006
|
+
B909(103, 4),
|
|
1007
|
+
B909(104, 4),
|
|
1008
|
+
B909(105, 4),
|
|
1009
|
+
B909(125, 4),
|
|
993
1010
|
]
|
|
994
1011
|
self.assertEqual(errors, self.errors(*expected))
|
|
995
1012
|
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Should emit:
|
|
3
|
-
B999 - on lines 11, 25, 26, 40, 46
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
some_list = [1, 2, 3]
|
|
8
|
-
for elem in some_list:
|
|
9
|
-
print(elem)
|
|
10
|
-
if elem % 2 == 0:
|
|
11
|
-
some_list.remove(elem) # should error
|
|
12
|
-
|
|
13
|
-
some_list = [1, 2, 3]
|
|
14
|
-
some_other_list = [1, 2, 3]
|
|
15
|
-
for elem in some_list:
|
|
16
|
-
print(elem)
|
|
17
|
-
if elem % 2 == 0:
|
|
18
|
-
some_other_list.remove(elem) # should not error
|
|
19
|
-
del some_other_list
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
some_list = [1, 2, 3]
|
|
23
|
-
for elem in some_list:
|
|
24
|
-
print(elem)
|
|
25
|
-
if elem % 2 == 0:
|
|
26
|
-
del some_list[2] # should error
|
|
27
|
-
del some_list
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class A:
|
|
31
|
-
some_list: list
|
|
32
|
-
|
|
33
|
-
def __init__(self, ls):
|
|
34
|
-
self.some_list = list(ls)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
a = A((1, 2, 3))
|
|
38
|
-
for elem in a.some_list:
|
|
39
|
-
print(elem)
|
|
40
|
-
if elem % 2 == 0:
|
|
41
|
-
a.some_list.remove(elem) # should error
|
|
42
|
-
|
|
43
|
-
a = A((1, 2, 3))
|
|
44
|
-
for elem in a.some_list:
|
|
45
|
-
print(elem)
|
|
46
|
-
if elem % 2 == 0:
|
|
47
|
-
del a.some_list[2] # should error
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
some_list = [1, 2, 3]
|
|
52
|
-
for elem in some_list:
|
|
53
|
-
print(elem)
|
|
54
|
-
if elem == 2:
|
|
55
|
-
found_idx = some_list.index(elem) # should not error
|
|
56
|
-
some_list.append(elem) # should error
|
|
57
|
-
some_list.sort() # should error
|
|
58
|
-
some_list.reverse() # should error
|
|
59
|
-
some_list.clear() # should error
|
|
60
|
-
some_list.extend([1,2]) # should error
|
|
61
|
-
some_list.insert(1, 1) # should error
|
|
62
|
-
some_list.pop(1) # should error
|
|
63
|
-
some_list.pop() # should error
|
|
64
|
-
some_list = 3 # should error
|
|
65
|
-
break
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
mydicts = {'a': {'foo': 1, 'bar': 2}}
|
|
70
|
-
|
|
71
|
-
for mydict in mydicts:
|
|
72
|
-
if mydicts.get('a', ''):
|
|
73
|
-
print(mydict['foo']) # should not error
|
|
74
|
-
mydicts.popitem() # should error
|
|
75
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flake8-bugbear-24.2.6 → flake8_bugbear-24.4.26}/flake8_bugbear.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|