Commit 1de3e36d authored by Jason Madden's avatar Jason Madden Committed by GitHub

Switch off prospector, go back to plain pylint (#1230)

* Switch off prospector, go back to plain pylint.

prospector wasn't working on CI for some reason.

Fix the outstanding pylint errors.

* Explicitly request pylint 2 on Python 3

* Also need to update astroid.

* pylint warning generated on Travis (case-sensitive filesystem.)
parent 40959196
......@@ -37,6 +37,10 @@ extension-pkg-whitelist=gevent.libuv._corecffi,gevent.libev._corecffi,gevent.loc
# def foo():
# if baz:
# return 1
# In Pylint 2dev1, needed for Python 3.7, we get spurious 'useless return' errors:
# @property
# def foo(self):
# return None # generates useless-return
disable=wrong-import-position,
wrong-import-order,
missing-docstring,
......@@ -55,7 +59,8 @@ disable=wrong-import-position,
useless-suppression,
duplicate-code,
undefined-all-variable,
inconsistent-return-statements
inconsistent-return-statements,
useless-return
[FORMAT]
......
......@@ -37,8 +37,8 @@ whitespace:
! find . -not -path "*.pem" -not -path "./.eggs/*" -not -path "./src/greentest/htmlcov/*" -not -path "./src/greentest/.coverage.*" -not -path "./.tox/*" -not -path "*/__pycache__/*" -not -path "*.so" -not -path "*.pyc" -not -path "./.git/*" -not -path "./build/*" -not -path "./src/gevent/libev/*" -not -path "./src/gevent.egg-info/*" -not -path "./dist/*" -not -path "./.DS_Store" -not -path "./deps/*" -not -path "./src/gevent/libev/corecext.*.[ch]" -not -path "./src/gevent/resolver/cares.*" -not -path "./doc/_build/*" -not -path "./doc/mytheme/static/*" -type f | xargs egrep -l " $$"
prospector:
which prospector
which pylint
pylint --rcfile=.pylintrc gevent
# debugging
# pylint --rcfile=.pylintrc --init-hook="import sys, code; sys.excepthook = lambda exc, exc_type, tb: print(tb.tb_next.tb_next.tb_next.tb_next.tb_next.tb_next.tb_next.tb_next.tb_next.tb_next.tb_frame.f_locals['self'])" gevent src/greentest/* || true
# XXX: prospector is failing right now. I can't reproduce locally:
......@@ -185,7 +185,7 @@ develop:
@${PYTHON} scripts/travis.py fold_end install
test-py27: $(PY27)
PYTHON=python2.7.14 PATH=$(BUILD_RUNTIMES)/versions/python2.7.14/bin:$(PATH) make develop lint leaktest cffibackendtest coverage_combine
PYTHON=python2.7.14 PATH=$(BUILD_RUNTIMES)/versions/python2.7.14/bin:$(PATH) make develop leaktest cffibackendtest coverage_combine
test-py34: $(PY34)
PYTHON=python3.4.7 PATH=$(BUILD_RUNTIMES)/versions/python3.4.7/bin:$(PATH) make develop basictest
......@@ -194,7 +194,7 @@ test-py35: $(PY35)
PYTHON=python3.5.5 PATH=$(BUILD_RUNTIMES)/versions/python3.5.5/bin:$(PATH) make develop basictest
test-py36: $(PY36)
PYTHON=python3.6.4 PATH=$(BUILD_RUNTIMES)/versions/python3.6.4/bin:$(PATH) make develop allbackendtest
PYTHON=python3.6.4 PATH=$(BUILD_RUNTIMES)/versions/python3.6.4/bin:$(PATH) make develop lint allbackendtest
test-py37: $(PY37)
LD_LIBRARY_PATH=$(BUILD_RUNTIMES)/versions/python3.7.0b4/openssl/lib PYTHON=python3.7.0b4 PATH=$(BUILD_RUNTIMES)/versions/python3.7.0b4/bin:$(PATH) make develop leaktest cffibackendtest coverage_combine
......
......@@ -9,9 +9,11 @@ Cython >= 0.28.1
# Python 3.7b1 requires this.
greenlet>=0.4.13 ; platform_python_implementation == "CPython"
pylint>=1.8.0
# pyyaml is included here and doesn't install on travis with 3.7a3
prospector[with_pyroma] ; python_version < '3.7'
pylint>=1.8.0 ; python_version < "3.4"
pylint >= 2.0.0.dev1 ; python_version >= "3.4"
# pylint 2 needs astroid 2; unfortunately, it uses `typed_ast`
# which has a C extension that doesn't build on PyPy
astroid >= 2.0.0.dev1 ; python_version >= "3.4" and platform_python_implementation == "CPython"
# See version requirements in setup.py
cffi >= 1.11.5 ; platform_python_implementation == "CPython"
......
......@@ -77,7 +77,7 @@ else:
iteritems = dict.iteritems # python 3: pylint:disable=no-member
itervalues = dict.itervalues # python 3: pylint:disable=no-member
xrange = __builtin__.xrange
from itertools import izip # python 3: pylint:disable=no-member
from itertools import izip # python 3: pylint:disable=no-member,no-name-in-module
izip = izip
# fspath from 3.6 os.py, but modified to raise the same exceptions as the
......
......@@ -206,11 +206,11 @@ class AbstractCallbacks(object):
if watcher is not None:
watcher.loop.handle_error(None, t, v, tb)
return 1
else:
# Raising it causes a lot of noise from CFFI
print("WARNING: gevent: Unhandled error with no watcher",
file=sys.stderr)
traceback.print_exception(t, v, tb)
# Raising it causes a lot of noise from CFFI
print("WARNING: gevent: Unhandled error with no watcher",
file=sys.stderr)
traceback.print_exception(t, v, tb)
def python_stop(self, handle):
if not handle: # pragma: no cover
......@@ -270,8 +270,7 @@ class AbstractCallbacks(object):
# in the main greenlet.
loop.handle_error(None, t, v, tb)
return None
else:
raise v # Let CFFI print
raise v # Let CFFI print
def _find_loop_from_c_watcher(self, watcher_ptr):
raise NotImplementedError()
......
......@@ -10,6 +10,7 @@ from __future__ import absolute_import
from gevent import _socketcommon
from gevent._util import copy_globals
from gevent._compat import PYPY
from gevent.timeout import Timeout
copy_globals(_socketcommon, globals(),
names_to_ignore=_socketcommon.__py3_imports__ + _socketcommon.__extensions__,
......@@ -255,8 +256,7 @@ class socket(object):
except error as ex:
if type(ex) is error: # pylint:disable=unidiomatic-typecheck
return ex.args[0]
else:
raise # gaierror is not silenced by connect_ex
raise # gaierror is not silenced by connect_ex
def dup(self):
"""dup() -> socket object
......
......@@ -14,6 +14,7 @@ import sys
from gevent import _socketcommon
from gevent._util import copy_globals
from gevent._compat import PYPY
from gevent.timeout import Timeout
import _socket
from os import dup
......@@ -361,7 +362,7 @@ class socket(object):
return self.connect(address) or 0
except timeout:
return EAGAIN
except gaierror:
except gaierror: # pylint:disable=try-except-raise
# gaierror/overflowerror/typerror is not silenced by connect_ex;
# gaierror extends OSError (aka error) so catch it first
raise
......
......@@ -71,11 +71,8 @@ __imports__.extend(__py3_imports__)
import time
import sys
from gevent._hub_local import get_hub_noargs as get_hub
from gevent.exceptions import ConcurrentObjectUseError
from gevent.timeout import Timeout
from gevent._compat import string_types, integer_types, PY3
from gevent._util import copy_globals
from gevent._util import _NONE
is_windows = sys.platform == 'win32'
is_macos = sys.platform == 'darwin'
......
......@@ -109,7 +109,7 @@ class SSLSocket(socket):
except SSLError as ex:
if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
return ''
elif ex.args[0] == SSL_ERROR_WANT_READ:
if ex.args[0] == SSL_ERROR_WANT_READ:
if self.timeout == 0.0:
raise
sys.exc_clear()
......@@ -211,8 +211,7 @@ class SSLSocket(socket):
self.__class__)
# QQQ Shouldn't we wrap the SSL_WANT_READ errors as socket.timeout errors to match socket.recv's behavior?
return self.read(buflen)
else:
return socket.recv(self, buflen, flags)
return socket.recv(self, buflen, flags)
def recv_into(self, buffer, nbytes=None, flags=0):
if buffer and (nbytes is None):
......@@ -268,7 +267,7 @@ class SSLSocket(socket):
except SSLError as ex:
if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
return ''
elif ex.args[0] == SSL_ERROR_WANT_READ:
if ex.args[0] == SSL_ERROR_WANT_READ:
if self.timeout == 0.0:
raise
sys.exc_clear()
......@@ -282,12 +281,11 @@ class SSLSocket(socket):
raise
def unwrap(self):
if self._sslobj:
s = self._sslobj_shutdown()
self._sslobj = None
return socket(_sock=s)
else:
if not self._sslobj:
raise ValueError("No SSL wrapper around " + str(self))
s = self._sslobj_shutdown()
self._sslobj = None
return socket(_sock=s)
def shutdown(self, how):
self._sslobj = None
......
......@@ -8,11 +8,12 @@ This module implements cooperative SSL socket wrappers.
"""
# Our import magic sadly makes this warning useless
# pylint: disable=undefined-variable
# pylint:disable=no-member
from __future__ import absolute_import
import ssl as __ssl__
_ssl = __ssl__._ssl # pylint:disable=no-member
_ssl = __ssl__._ssl
import errno
from gevent.socket import socket, timeout_default
......@@ -252,7 +253,7 @@ class SSLSocket(socket):
self._sslobj = self._context._wrap_socket(self._sock, server_side,
server_hostname)
if _session is not None: # 3.6+
self._sslobj = _SSLObject_factory(self._sslobj, owner=self,
self._sslobj = _SSLObject_factory(self._sslobj, owner=self,
session=self._session)
if do_handshake_on_connect:
timeout = self.gettimeout()
......@@ -339,8 +340,7 @@ class SSLSocket(socket):
if buffer is None:
return b''
return 0
else:
raise
raise
def write(self, data):
"""Write DATA to the underlying SSL channel. Returns
......@@ -489,8 +489,7 @@ class SSLSocket(socket):
# Python #23804
return b''
return self.read(buflen)
else:
return socket.recv(self, buflen, flags)
return socket.recv(self, buflen, flags)
def recv_into(self, buffer, nbytes=None, flags=0):
self._checkClosed()
......@@ -502,8 +501,7 @@ class SSLSocket(socket):
if flags != 0:
raise ValueError("non-zero flags not allowed in calls to recv_into() on %s" % self.__class__)
return self.read(nbytes, buffer)
else:
return socket.recv_into(self, buffer, nbytes, flags)
return socket.recv_into(self, buffer, nbytes, flags)
def recvfrom(self, buflen=1024, flags=0):
self._checkClosed()
......@@ -541,40 +539,40 @@ class SSLSocket(socket):
socket.shutdown(self, how)
def unwrap(self):
if self._sslobj:
while True:
try:
s = self._sslobj.shutdown()
break
except SSLWantReadError:
# Callers of this method expect to get a socket
# back, so we can't simply return 0, we have
# to let these be raised
if self.timeout == 0.0:
raise
self._wait(self._read_event)
except SSLWantWriteError:
if self.timeout == 0.0:
raise
self._wait(self._write_event)
if not self._sslobj:
raise ValueError("No SSL wrapper around " + str(self))
self._sslobj = None
while True:
try:
s = self._sslobj.shutdown()
break
except SSLWantReadError:
# Callers of this method expect to get a socket
# back, so we can't simply return 0, we have
# to let these be raised
if self.timeout == 0.0:
raise
self._wait(self._read_event)
except SSLWantWriteError:
if self.timeout == 0.0:
raise
self._wait(self._write_event)
# The return value of shutting down the SSLObject is the
# original wrapped socket passed to _wrap_socket, i.e.,
# _contextawaresock. But that object doesn't have the
# gevent wrapper around it so it can't be used. We have to
# wrap it back up with a gevent wrapper.
assert s is self._sock
# In the stdlib, SSLSocket subclasses socket.socket and passes itself
# to _wrap_socket, so it gets itself back. We can't do that, we have to
# pass our subclass of _socket.socket, _contextawaresock.
# So ultimately we should return ourself.
# See test_ftplib.py:TestTLS_FTPClass.test_ccc
return self
else:
raise ValueError("No SSL wrapper around " + str(self))
self._sslobj = None
# The return value of shutting down the SSLObject is the
# original wrapped socket passed to _wrap_socket, i.e.,
# _contextawaresock. But that object doesn't have the
# gevent wrapper around it so it can't be used. We have to
# wrap it back up with a gevent wrapper.
assert s is self._sock
# In the stdlib, SSLSocket subclasses socket.socket and passes itself
# to _wrap_socket, so it gets itself back. We can't do that, we have to
# pass our subclass of _socket.socket, _contextawaresock.
# So ultimately we should return ourself.
# See test_ftplib.py:TestTLS_FTPClass.test_ccc
return self
def _real_close(self):
self._sslobj = None
......
......@@ -326,8 +326,7 @@ class SSLSocket(socket):
if buffer is not None:
return 0
return b''
else:
raise
raise
def write(self, data):
"""Write DATA to the underlying SSL channel. Returns
......@@ -456,8 +455,7 @@ class SSLSocket(socket):
if buflen == 0:
return b''
return self.read(buflen)
else:
return socket.recv(self, buflen, flags)
return socket.recv(self, buflen, flags)
def recv_into(self, buffer, nbytes=None, flags=0):
self._checkClosed()
......@@ -473,16 +471,14 @@ class SSLSocket(socket):
"non-zero flags not allowed in calls to recv_into() on %s" %
self.__class__)
return self.read(nbytes, buffer)
else:
return socket.recv_into(self, buffer, nbytes, flags)
return socket.recv_into(self, buffer, nbytes, flags)
def recvfrom(self, buflen=1024, flags=0):
self._checkClosed()
if self._sslobj:
raise ValueError("recvfrom not allowed on instances of %s" %
self.__class__)
else:
return socket.recvfrom(self, buflen, flags)
return socket.recvfrom(self, buflen, flags)
def recvfrom_into(self, buffer, nbytes=None, flags=0):
self._checkClosed()
......@@ -536,7 +532,7 @@ class SSLSocket(socket):
except SSLError as ex:
if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
return ''
elif ex.args[0] == SSL_ERROR_WANT_READ:
if ex.args[0] == SSL_ERROR_WANT_READ:
if self.timeout == 0.0:
raise
sys.exc_clear()
......@@ -550,16 +546,16 @@ class SSLSocket(socket):
raise
def unwrap(self):
if self._sslobj:
s = self._sslobj_shutdown()
self._sslobj = None
# match _ssl2; critical to drop/reuse here on PyPy
# XXX: _ssl3 returns an SSLSocket. Is that what the standard lib does on
# Python 2? Should we do that?
return socket(_sock=s)
else:
if not self._sslobj:
raise ValueError("No SSL wrapper around " + str(self))
s = self._sslobj_shutdown()
self._sslobj = None
# match _ssl2; critical to drop/reuse here on PyPy
# XXX: _ssl3 returns an SSLSocket. Is that what the standard lib does on
# Python 2? Should we do that?
return socket(_sock=s)
def _real_close(self):
self._sslobj = None
socket._real_close(self) # pylint: disable=no-member
......
# this produces syntax error on Python3
import sys
__all__ = ['reraise']
def reraise(type, value, tb):
raise type, value, tb
def exec_(_code_, _globs_=None, _locs_=None):
"""Execute code in a namespace."""
if _globs_ is None:
frame = sys._getframe(1)
_globs_ = frame.f_globals
if _locs_ is None:
_locs_ = frame.f_locals
del frame
elif _locs_ is None:
_locs_ = _globs_
exec("""exec _code_ in _globs_, _locs_""")
exec_("""def reraise(tp, value, tb=None):
try:
raise tp, value, tb
finally:
tb = None
""")
......@@ -142,8 +142,7 @@ class Waiter(object):
if self._exception is not _NONE:
if self._exception is None:
return self.value
else:
getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
getcurrent().throw(*self._exception) # pylint:disable=undefined-variable
else:
if self.greenlet is not None:
raise ConcurrentObjectUseError('This Waiter is already used by %r' % (self.greenlet, ))
......
......@@ -4,7 +4,7 @@
Use :mod:`gevent.resolver.cares`
"""
from gevent.resolver.cares import * # pylint:disable=wildcard-import,unused-wildcard-import
from gevent.resolver.cares import * # pylint:disable=wildcard-import,unused-wildcard-import,
import gevent.resolver.cares as _cares
__all__ = _cares.__all__
__all__ = _cares.__all__ # pylint:disable=c-extension-no-member
del _cares
......@@ -400,5 +400,5 @@ def _parse_address(address):
def parse_address(address):
try:
return _parse_address(address)
except ValueError as ex:
except ValueError as ex: # pylint:disable=try-except-raise
raise ValueError('Failed to parse address %r: %s' % (address, ex))
......@@ -17,7 +17,7 @@ __all__ = [
from gevent._util import implementer
from gevent._interfaces import ILoop
import gevent.libev._corecffi as _corecffi # pylint:disable=no-name-in-module,import-error
from gevent.libev import _corecffi # pylint:disable=no-name-in-module,import-error
ffi = _corecffi.ffi # pylint:disable=no-member
libev = _corecffi.lib # pylint:disable=no-member
......
......@@ -3,7 +3,7 @@
from __future__ import absolute_import, print_function
import sys
import gevent.libev._corecffi as _corecffi # pylint:disable=no-name-in-module,import-error
from gevent.libev import _corecffi # pylint:disable=no-name-in-module,import-error
ffi = _corecffi.ffi # pylint:disable=no-member
libev = _corecffi.lib # pylint:disable=no-member
......
......@@ -5,7 +5,7 @@ from __future__ import absolute_import, print_function
import functools
import sys
import gevent.libuv._corecffi as _corecffi # pylint:disable=no-name-in-module,import-error
from gevent.libuv import _corecffi # pylint:disable=no-name-in-module,import-error
ffi = _corecffi.ffi
libuv = _corecffi.lib
......
......@@ -436,7 +436,8 @@ class local(object):
return type(type_attr).__get__(type_attr, self, self._local_type)
# Last case is a non-data descriptor. Instance wins.
return dct[name]
elif name in self._local_type_vars:
if name in self._local_type_vars:
type_attr = getattr(self._local_type, name)
# It's not in the dict at all. Is it in the type?
......
......@@ -512,7 +512,7 @@ def patch_thread(threading=True, _threading_local=True, Event=True, logging=True
``Event`` defaults to True.
"""
# XXX: Simplify
# pylint:disable=too-many-branches,too-many-locals
# pylint:disable=too-many-branches,too-many-locals,too-many-statements
# Description of the hang:
# There is an incompatibility with patching 'thread' and the 'multiprocessing' module:
......
......@@ -355,25 +355,25 @@ if hasattr(os, 'fork'):
return result[:2]
# it's not finished
return (0, 0)
else:
# Ok, we need to "block". Do so via a watcher so that we're
# cooperative. We know it's our child, etc, so this should work.
watcher = _watched_children[pid]
# We can't start a watcher that's already started,
# so we can't reuse the existing watcher. Notice that the
# old watcher must not have fired already, or during this time, but
# only after we successfully `start()` the watcher. So this must
# not yield to the event loop.
with watcher.loop.child(pid, False) as new_watcher:
get_hub().wait(new_watcher)
# Ok, so now the new watcher is done. That means
# the old watcher's callback (_on_child) should
# have fired, potentially taking this child out of
# _watched_children (but that could depend on how
# many callbacks there were to run, so use the
# watcher object directly; libev sets all the
# watchers at the same time).
return watcher.rpid, watcher.rstatus
# Ok, we need to "block". Do so via a watcher so that we're
# cooperative. We know it's our child, etc, so this should work.
watcher = _watched_children[pid]
# We can't start a watcher that's already started,
# so we can't reuse the existing watcher. Notice that the
# old watcher must not have fired already, or during this time, but
# only after we successfully `start()` the watcher. So this must
# not yield to the event loop.
with watcher.loop.child(pid, False) as new_watcher:
get_hub().wait(new_watcher)
# Ok, so now the new watcher is done. That means
# the old watcher's callback (_on_child) should
# have fired, potentially taking this child out of
# _watched_children (but that could depend on how
# many callbacks there were to run, so use the
# watcher object directly; libev sets all the
# watchers at the same time).
return watcher.rpid, watcher.rstatus
# we're not watching it and it may not even be our child,
# so we must go to the OS to be sure to get the right semantics (exception)
......
......@@ -35,7 +35,7 @@ from heapq import heapify as _heapify
import collections
if sys.version_info[0] == 2:
import Queue as __queue__
import Queue as __queue__ # python 3: pylint:disable=import-error
else:
import queue as __queue__ # python 2: pylint:disable=import-error
Full = __queue__.Full
......@@ -52,7 +52,7 @@ __extensions__ = ['JoinableQueue', 'Channel']
__imports__ = ['Empty', 'Full']
if hasattr(__queue__, 'SimpleQueue'):
__imports__.append('SimpleQueue') # New in 3.7
SimpleQueue = __queue__.SimpleQueue
SimpleQueue = __queue__.SimpleQueue # pylint:disable=no-member
__all__ = __implements__ + __extensions__ + __imports__
......
......@@ -353,6 +353,5 @@ class Values(object):
self.waiter.get()
if self.values:
return self.values
else:
assert error is not None
raise self.error # pylint:disable=raising-bad-type
assert error is not None
raise self.error # pylint:disable=raising-bad-type
......@@ -130,6 +130,7 @@ def _getaddrinfo(host=None, service=None, family=AF_UNSPEC, socktype=0,
# pylint:disable=too-many-locals,broad-except,too-many-statements
# pylint:disable=too-many-branches
# pylint:disable=redefined-argument-from-local
# pylint:disable=consider-using-in
if flags & (socket.AI_ADDRCONFIG | socket.AI_V4MAPPED) != 0:
raise NotImplementedError
if host is None and service is None:
......
......@@ -95,7 +95,7 @@ def signal(signalnum, handler):
old_handler = getsignal(signalnum)
global _child_handler
_child_handler = handler
if handler == _signal.SIG_IGN or handler == _signal.SIG_DFL:
if handler in (_signal.SIG_IGN, _signal.SIG_DFL):
# Allow resetting/ignoring this signal at the process level.
# Note that this conflicts with gevent.subprocess and other users
# of child watchers, until the next time gevent.subprocess/loop.install_sigchld()
......
......@@ -1296,7 +1296,7 @@ class Popen(object):
# is possible that it is overwritten (#12607).
if c2pwrite == 0:
c2pwrite = os.dup(c2pwrite)
while errwrite == 0 or errwrite == 1:
while errwrite in (0, 1):
errwrite = os.dup(errwrite)
# Dup fds for child
......
......@@ -98,9 +98,8 @@ if hasattr(__thread__, 'stack_size'):
return _original_stack_size()
if size > _original_stack_size():
return _original_stack_size(size)
else:
pass
# not going to decrease stack_size, because otherwise other greenlets in this thread will suffer
# not going to decrease stack_size, because otherwise other
# greenlets in this thread will suffer
else:
__implements__.remove('stack_size')
......
......@@ -105,8 +105,8 @@ class _DummyThread(_DummyThread_):
_Thread__started.set()
_tstate_lock = None
def __init__(self):
#_DummyThread_.__init__(self) # pylint:disable=super-init-not-called
def __init__(self): # pylint:disable=super-init-not-called
#_DummyThread_.__init__(self)
# It'd be nice to use a pattern like "greenlet-%d", but maybe somebody out
# there is checking thread names...
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment