Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,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))

Expand Down
5 changes: 5 additions & 0 deletions tests/b028.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading