diff --git a/hacking/core.py b/hacking/core.py index 3e80ab3..9155e6c 100755 --- a/hacking/core.py +++ b/hacking/core.py @@ -687,6 +687,22 @@ def hacking_no_assert_equals(logical_line, tokens): "H602: assertEquals is deprecated, use assertEqual") +@flake8ext +def hacking_no_assert_underscore(logical_line, tokens): + r"""assert_() is deprecated, use assertTrue instead. + + Okay: self.assertTrue(foo) + H603: self.assert_(foo) + """ + + for token_type, text, start_index, _, _ in tokens: + + if token_type == tokenize.NAME and text == "assert_": + yield ( + start_index[1], + "H603: assert_ is deprecated, use assertTrue") + + FORMAT_RE = re.compile("%(?:" "%|" # Ignore plain percents "(\(\w+\))?" # mapping key diff --git a/setup.cfg b/setup.cfg index 7fa6974..5bcd26c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,6 +40,7 @@ flake8.extension = H501 = hacking.core:hacking_no_locals H601 = hacking.core:hacking_no_cr H602 = hacking.core:hacking_no_assert_equals + H603 = hacking.core:hacking_no_assert_underscore H700 = hacking.core:hacking_localization_strings H801 = hacking.core:OnceGitCheckCommitTitleBug H802 = hacking.core:OnceGitCheckCommitTitleLength