Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete W601 -> W604 warnings #1111

Merged
merged 1 commit into from Oct 18, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.rst
Expand Up @@ -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::
Expand Down Expand Up @@ -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
-----
Expand Down
12 changes: 0 additions & 12 deletions docs/intro.rst
Expand Up @@ -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::
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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()' |
Comment on lines -418 to -424
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it should still be mentioned in the documentation that these 4 codes have been in use before and should not be used again for future checks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just remove them as you've done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's unlikely anyone would think to bring them back, since they have to do with the py2 -> py3 transition!

+------------+----------------------------------------------------------------------+
| W605 | invalid escape sequence '\x' |
+------------+----------------------------------------------------------------------+
| W606 | 'async' and 'await' are reserved keywords starting with Python 3.7 |
Expand Down
53 changes: 0 additions & 53 deletions pycodestyle.py
Expand Up @@ -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.
Expand Down
15 changes: 0 additions & 15 deletions 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
Expand Down