From 80c5a50ccfb2fba29594901c02b5a9c4689f7f92 Mon Sep 17 00:00:00 2001 From: Danny Sepler Date: Tue, 18 Oct 2022 00:21:49 -0400 Subject: Delete W601 -> W604 warnings --- README.rst | 4 ---- docs/intro.rst | 12 ------------ pycodestyle.py | 53 ----------------------------------------------------- testsuite/W60.py | 15 --------------- 4 files changed, 84 deletions(-) diff --git a/README.rst b/README.rst index c71b933..2f6ddb8 100644 --- a/README.rst +++ b/README.rst @@ -65,11 +65,9 @@ Example usage and output optparse.py:69:11: E401 multiple imports on one line optparse.py:77:1: E302 expected 2 blank lines, found 1 optparse.py:88:5: E301 expected 1 blank line, found 0 - optparse.py:222:34: W602 deprecated form of raising exception optparse.py:347:31: E211 whitespace before '(' optparse.py:357:17: E201 whitespace after '{' optparse.py:472:29: E221 multiple spaces before operator - optparse.py:544:21: W601 .has_key() is deprecated, use 'in' You can also make ``pycodestyle.py`` show the source code for each error, and even the relevant text from PEP 8:: @@ -97,8 +95,6 @@ Or you can display how often each error was found:: 165 E303 too many blank lines (4) 325 E401 multiple imports on one line 3615 E501 line too long (82 characters) - 612 W601 .has_key() is deprecated, use 'in' - 1188 W602 deprecated form of raising exception Links ----- diff --git a/docs/intro.rst b/docs/intro.rst index 3be9d8e..aba8a15 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -71,11 +71,9 @@ Example usage and output optparse.py:69:11: E401 multiple imports on one line optparse.py:77:1: E302 expected 2 blank lines, found 1 optparse.py:88:5: E301 expected 1 blank line, found 0 - optparse.py:222:34: W602 deprecated form of raising exception optparse.py:347:31: E211 whitespace before '(' optparse.py:357:17: E201 whitespace after '{' optparse.py:472:29: E221 multiple spaces before operator - optparse.py:544:21: W601 .has_key() is deprecated, use 'in' You can also make ``pycodestyle.py`` show the source code for each error, and even the relevant text from PEP 8:: @@ -103,8 +101,6 @@ Or you can display how often each error was found:: 165 E303 too many blank lines (4) 325 E401 multiple imports on one line 3615 E501 line too long (82 characters) - 612 W601 .has_key() is deprecated, use 'in' - 1188 W602 deprecated form of raising exception You can also make ``pycodestyle.py`` show the error text in different formats by using ``--format`` having options default/pylint/custom:: @@ -415,14 +411,6 @@ This is the current list of error and warning codes: +------------+----------------------------------------------------------------------+ | **W6** | *Deprecation warning* | +------------+----------------------------------------------------------------------+ -| W601 | .has_key() is deprecated, use 'in' | -+------------+----------------------------------------------------------------------+ -| W602 | deprecated form of raising exception | -+------------+----------------------------------------------------------------------+ -| W603 | '<>' is deprecated, use '!=' | -+------------+----------------------------------------------------------------------+ -| W604 | backticks are deprecated, use 'repr()' | -+------------+----------------------------------------------------------------------+ | W605 | invalid escape sequence '\x' | +------------+----------------------------------------------------------------------+ | W606 | 'async' and 'await' are reserved keywords starting with Python 3.7 | diff --git a/pycodestyle.py b/pycodestyle.py index 2119d06..4a02ff2 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1563,59 +1563,6 @@ def ambiguous_identifier(logical_line, tokens): prev_start = start -@register_check -def python_3000_has_key(logical_line, noqa): - r"""The {}.has_key() method is removed in Python 3: use the 'in' - operator. - - Okay: if "alph" in d:\n print d["alph"] - W601: assert d.has_key('alph') - """ - pos = logical_line.find('.has_key(') - if pos > -1 and not noqa: - yield pos, "W601 .has_key() is deprecated, use 'in'" - - -@register_check -def python_3000_raise_comma(logical_line): - r"""When raising an exception, use "raise ValueError('message')". - - The older form is removed in Python 3. - - Okay: raise DummyError("Message") - W602: raise DummyError, "Message" - """ - match = RAISE_COMMA_REGEX.match(logical_line) - if match and not RERAISE_COMMA_REGEX.match(logical_line): - yield match.end() - 1, "W602 deprecated form of raising exception" - - -@register_check -def python_3000_not_equal(logical_line): - r"""New code should always use != instead of <>. - - The older syntax is removed in Python 3. - - Okay: if a != 'no': - W603: if a <> 'no': - """ - pos = logical_line.find('<>') - if pos > -1: - yield pos, "W603 '<>' is deprecated, use '!='" - - -@register_check -def python_3000_backticks(logical_line): - r"""Use repr() instead of backticks in Python 3. - - Okay: val = repr(1 + 2) - W604: val = `1 + 2` - """ - pos = logical_line.find('`') - if pos > -1: - yield pos, "W604 backticks are deprecated, use 'repr()'" - - @register_check def python_3000_invalid_escape_sequence(logical_line, tokens, noqa): r"""Invalid escape sequences are deprecated in Python 3.6. diff --git a/testsuite/W60.py b/testsuite/W60.py index 5003677..f44552d 100644 --- a/testsuite/W60.py +++ b/testsuite/W60.py @@ -1,18 +1,3 @@ -#: W601 -if a.has_key("b"): - print a -#: W602 -raise DummyError, "Message" -#: W602 -raise ValueError, "hello %s %s" % (1, 2) -#: Okay -raise type_, val, tb -raise Exception, Exception("f"), t -#: W603 -if x <> 0: - x = 0 -#: W604 -val = `1 + 2` #: W605:1:10 regex = '\.png$' #: W605:2:1 -- cgit v1.2.1