diff --git a/bugbear.py b/bugbear.py index 04cd1ae..53abddc 100644 --- a/bugbear.py +++ b/bugbear.py @@ -1683,6 +1683,8 @@ def check_for_b028(self, node) -> None: and node.func.value.id == "warnings" and not any(kw.arg == "stacklevel" for kw in node.keywords) and len(node.args) < 3 + and not any(isinstance(a, ast.Starred) for a in node.args) + and not any(kw.arg is None for kw in node.keywords) ): self.errors.append(B028(node.lineno, node.col_offset)) diff --git a/tests/b028.py b/tests/b028.py index 2c56306..62e761b 100644 --- a/tests/b028.py +++ b/tests/b028.py @@ -11,3 +11,8 @@ warnings.warn("test", DeprecationWarning, stacklevel=1) warnings.warn("test", DeprecationWarning, 1) warnings.warn("test", category=DeprecationWarning, stacklevel=1) +args = ("test", DeprecationWarning, 1) +warnings.warn(*args) +kwargs = {"message": "test", "category": DeprecationWarning, "stacklevel": 1} +warnings.warn(**kwargs) +warnings.warn(*args, **kwargs)