Commit 4f267154 authored by Jason Madden's avatar Jason Madden

Compatibility with pylint 1.7

parent 52f5022a
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
# see https://github.com/PyCQA/pylint/issues/846 # see https://github.com/PyCQA/pylint/issues/846
# useless-suppression: the only way to avoid repeating it for specific statements everywhere that we # useless-suppression: the only way to avoid repeating it for specific statements everywhere that we
# do Py2/Py3 stuff is to put it here. Sadly this means that we might get better but not realize it. # do Py2/Py3 stuff is to put it here. Sadly this means that we might get better but not realize it.
# duplicate-code: Yeah, the compatibility ssl modules are much the same
disable=wrong-import-position, disable=wrong-import-position,
wrong-import-order, wrong-import-order,
missing-docstring, missing-docstring,
...@@ -44,12 +45,14 @@ disable=wrong-import-position, ...@@ -44,12 +45,14 @@ disable=wrong-import-position,
too-many-arguments, too-many-arguments,
redefined-builtin, redefined-builtin,
useless-suppression, useless-suppression,
# undefined-all-variable duplicate-code,
undefined-all-variable
[FORMAT] [FORMAT]
# duplicated from setup.cfg # duplicated from setup.cfg
max-line-length=160 max-line-length=160
max-module-lines=1070
[MISCELLANEOUS] [MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma. # List of note tags to take in consideration, separated by a comma.
...@@ -80,7 +83,7 @@ ignored-classes=SSLContext, SSLSocket, greenlet, Greenlet, parent, dead ...@@ -80,7 +83,7 @@ ignored-classes=SSLContext, SSLSocket, greenlet, Greenlet, parent, dead
# (useful for modules/projects where namespaces are manipulated during runtime # (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It # and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching. # supports qualified module names, as well as Unix pattern matching.
ignored-modules=gevent._corecffi ignored-modules=gevent._corecffi,gevent.os,os,greenlet,threading,gevent.libev.corecffi
[DESIGN] [DESIGN]
max-attributes=12 max-attributes=12
......
...@@ -2,6 +2,7 @@ setuptools ...@@ -2,6 +2,7 @@ setuptools
wheel wheel
cython>=0.25.1 cython>=0.25.1
greenlet>=0.4.10 greenlet>=0.4.10
pylint>=1.7.1
prospector[with_pyroma] prospector[with_pyroma]
coverage>=4.0 coverage>=4.0
coveralls>=1.0 coveralls>=1.0
......
...@@ -117,9 +117,18 @@ del sys ...@@ -117,9 +117,18 @@ del sys
# the following makes hidden imports visible to freezing tools like # the following makes hidden imports visible to freezing tools like
# py2exe. see https://github.com/gevent/gevent/issues/181 # py2exe. see https://github.com/gevent/gevent/issues/181
def __dependencies_for_freezing(): def __dependencies_for_freezing():
from gevent import core, resolver_thread, resolver_ares, socket as _socket,\ # pylint:disable=unused-variable
threadpool, thread, threading, select, subprocess from gevent import core
from gevent import resolver_thread
from gevent import resolver_ares
from gevent import socket as _socket
from gevent import threadpool
from gevent import thread
from gevent import threading
from gevent import select
from gevent import subprocess
import pprint import pprint
import traceback import traceback
import signal as _signal import signal as _signal
......
...@@ -15,8 +15,8 @@ PYPY = hasattr(sys, 'pypy_version_info') ...@@ -15,8 +15,8 @@ PYPY = hasattr(sys, 'pypy_version_info')
## Types ## Types
if PY3: if PY3:
string_types = str, string_types = (str,)
integer_types = int, integer_types = (int,)
text_type = str text_type = str
else: else:
...@@ -42,8 +42,7 @@ if PY3: ...@@ -42,8 +42,7 @@ if PY3:
iteritems = dict.items iteritems = dict.items
itervalues = dict.values itervalues = dict.values
xrange = range xrange = range
else: else:
iteritems = dict.iteritems # python 3: pylint:disable=no-member iteritems = dict.iteritems # python 3: pylint:disable=no-member
itervalues = dict.itervalues # python 3: pylint:disable=no-member itervalues = dict.itervalues # python 3: pylint:disable=no-member
xrange = __builtin__.xrange # python 2: pylint:disable=redefined-variable-type xrange = __builtin__.xrange
...@@ -113,7 +113,7 @@ class FileObjectBase(object): ...@@ -113,7 +113,7 @@ class FileObjectBase(object):
self._io = None self._io = None
self._do_close(io, self._close) self._do_close(io, self._close)
def _do_close(self, io, closefd): def _do_close(self, fobj, closefd):
raise NotImplementedError() raise NotImplementedError()
def __getattr__(self, name): def __getattr__(self, name):
......
...@@ -269,16 +269,11 @@ class FileObjectPosix(FileObjectBase): ...@@ -269,16 +269,11 @@ class FileObjectPosix(FileObjectBase):
# attribute. # attribute.
IOFamily = FlushingBufferedWriter IOFamily = FlushingBufferedWriter
io = IOFamily(self.fileio, bufsize) super(FileObjectPosix, self).__init__(IOFamily(self.fileio, bufsize), close)
#else: # QQQ: not used, not reachable
#
# self.io = BufferedRandom(self.fileio, bufsize)
super(FileObjectPosix, self).__init__(io, close) def _do_close(self, fobj, closefd):
def _do_close(self, io, closefd):
try: try:
io.close() fobj.close()
# self.fileio already knows whether or not to close the # self.fileio already knows whether or not to close the
# file descriptor # file descriptor
self.fileio.close() self.fileio.close()
......
...@@ -99,7 +99,6 @@ class socket(object): ...@@ -99,7 +99,6 @@ class socket(object):
# See https://github.com/gevent/gevent/pull/399 # See https://github.com/gevent/gevent/pull/399
if self.timeout != 0.0: if self.timeout != 0.0:
return self._sock.type & ~_socket.SOCK_NONBLOCK # pylint:disable=no-member return self._sock.type & ~_socket.SOCK_NONBLOCK # pylint:disable=no-member
else:
return self._sock.type return self._sock.type
def __enter__(self): def __enter__(self):
...@@ -227,7 +226,7 @@ class socket(object): ...@@ -227,7 +226,7 @@ class socket(object):
if reading and writing: if reading and writing:
buffer = io.BufferedRWPair(raw, raw, buffering) buffer = io.BufferedRWPair(raw, raw, buffering)
elif reading: elif reading:
buffer = io.BufferedReader(raw, buffering) # pylint:disable=redefined-variable-type buffer = io.BufferedReader(raw, buffering)
else: else:
assert writing assert writing
buffer = io.BufferedWriter(raw, buffering) buffer = io.BufferedWriter(raw, buffering)
......
...@@ -113,7 +113,7 @@ __imports__ = copy_globals(__socket__, globals(), ...@@ -113,7 +113,7 @@ __imports__ = copy_globals(__socket__, globals(),
for _name in __socket__.__all__: for _name in __socket__.__all__:
_value = getattr(__socket__, _name) _value = getattr(__socket__, _name)
if isinstance(_value, integer_types) or isinstance(_value, string_types): if isinstance(_value, (integer_types, string_types)):
globals()[_name] = _value globals()[_name] = _value
__imports__.append(_name) __imports__.append(_name)
...@@ -332,7 +332,7 @@ def getfqdn(name=''): ...@@ -332,7 +332,7 @@ def getfqdn(name=''):
pass pass
else: else:
aliases.insert(0, hostname) aliases.insert(0, hostname)
for name in aliases: for name in aliases: # EWW! pylint:disable=redefined-argument-from-local
if isinstance(name, bytes): if isinstance(name, bytes):
if b'.' in name: if b'.' in name:
break break
......
...@@ -146,7 +146,6 @@ class SSLSocket(socket): ...@@ -146,7 +146,6 @@ class SSLSocket(socket):
def cipher(self): def cipher(self):
if not self._sslobj: if not self._sslobj:
return None return None
else:
return self._sslobj.cipher() return self._sslobj.cipher()
def send(self, data, flags=0, timeout=timeout_default): def send(self, data, flags=0, timeout=timeout_default):
...@@ -253,7 +252,6 @@ class SSLSocket(socket): ...@@ -253,7 +252,6 @@ class SSLSocket(socket):
def pending(self): def pending(self):
if self._sslobj: if self._sslobj:
return self._sslobj.pending() return self._sslobj.pending()
else:
return 0 return 0
def _sslobj_shutdown(self): def _sslobj_shutdown(self):
......
...@@ -48,7 +48,9 @@ class SSLContext(orig_SSLContext): ...@@ -48,7 +48,9 @@ class SSLContext(orig_SSLContext):
do_handshake_on_connect=True, do_handshake_on_connect=True,
suppress_ragged_eofs=True, suppress_ragged_eofs=True,
server_hostname=None, server_hostname=None,
session=None): # 3.6 session=None):
# pylint:disable=arguments-differ
# (3.6 adds session)
# Sadly, using *args and **kwargs doesn't work # Sadly, using *args and **kwargs doesn't work
return SSLSocket(sock=sock, server_side=server_side, return SSLSocket(sock=sock, server_side=server_side,
do_handshake_on_connect=do_handshake_on_connect, do_handshake_on_connect=do_handshake_on_connect,
...@@ -67,6 +69,7 @@ class SSLContext(orig_SSLContext): ...@@ -67,6 +69,7 @@ class SSLContext(orig_SSLContext):
# super(SSLContext, SSLContext). But we rebind SSLContext when we monkey # super(SSLContext, SSLContext). But we rebind SSLContext when we monkey
# patch, which causes infinite recursion. # patch, which causes infinite recursion.
# https://github.com/python/cpython/commit/328067c468f82e4ec1b5c510a4e84509e010f296 # https://github.com/python/cpython/commit/328067c468f82e4ec1b5c510a4e84509e010f296
# pylint:disable=no-member
@orig_SSLContext.options.setter @orig_SSLContext.options.setter
def options(self, value): def options(self, value):
super(orig_SSLContext, orig_SSLContext).options.__set__(self, value) super(orig_SSLContext, orig_SSLContext).options.__set__(self, value)
...@@ -287,7 +290,6 @@ class SSLSocket(socket): ...@@ -287,7 +290,6 @@ class SSLSocket(socket):
try: try:
if buffer is not None: if buffer is not None:
return self._sslobj.read(len, buffer) return self._sslobj.read(len, buffer)
else:
return self._sslobj.read(len or 1024) return self._sslobj.read(len or 1024)
except SSLWantReadError: except SSLWantReadError:
if self.timeout == 0.0: if self.timeout == 0.0:
...@@ -302,7 +304,6 @@ class SSLSocket(socket): ...@@ -302,7 +304,6 @@ class SSLSocket(socket):
if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
if buffer is None: if buffer is None:
return b'' return b''
else:
return 0 return 0
else: else:
raise raise
...@@ -350,7 +351,6 @@ class SSLSocket(socket): ...@@ -350,7 +351,6 @@ class SSLSocket(socket):
self._checkClosed() self._checkClosed()
if not self._sslobj or not _ssl.HAS_NPN: if not self._sslobj or not _ssl.HAS_NPN:
return None return None
else:
return self._sslobj.selected_npn_protocol() return self._sslobj.selected_npn_protocol()
if hasattr(_ssl, 'HAS_ALPN'): if hasattr(_ssl, 'HAS_ALPN'):
...@@ -359,7 +359,6 @@ class SSLSocket(socket): ...@@ -359,7 +359,6 @@ class SSLSocket(socket):
self._checkClosed() self._checkClosed()
if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member
return None return None
else:
return self._sslobj.selected_alpn_protocol() return self._sslobj.selected_alpn_protocol()
def shared_ciphers(self): def shared_ciphers(self):
...@@ -381,14 +380,12 @@ class SSLSocket(socket): ...@@ -381,14 +380,12 @@ class SSLSocket(socket):
self._checkClosed() self._checkClosed()
if not self._sslobj: if not self._sslobj:
return None return None
else:
return self._sslobj.cipher() return self._sslobj.cipher()
def compression(self): def compression(self):
self._checkClosed() self._checkClosed()
if not self._sslobj: if not self._sslobj:
return None return None
else:
return self._sslobj.compression() return self._sslobj.compression()
def send(self, data, flags=0, timeout=timeout_default): def send(self, data, flags=0, timeout=timeout_default):
...@@ -502,7 +499,6 @@ class SSLSocket(socket): ...@@ -502,7 +499,6 @@ class SSLSocket(socket):
self._checkClosed() self._checkClosed()
if self._sslobj: if self._sslobj:
return self._sslobj.pending() return self._sslobj.pending()
else:
return 0 return 0
def shutdown(self, how): def shutdown(self, how):
......
...@@ -311,7 +311,6 @@ class SSLSocket(socket): ...@@ -311,7 +311,6 @@ class SSLSocket(socket):
try: try:
if buffer is not None: if buffer is not None:
return self._sslobj.read(len, buffer) return self._sslobj.read(len, buffer)
else:
return self._sslobj.read(len or 1024) return self._sslobj.read(len or 1024)
except SSLWantReadError: except SSLWantReadError:
if self.timeout == 0.0: if self.timeout == 0.0:
...@@ -326,7 +325,6 @@ class SSLSocket(socket): ...@@ -326,7 +325,6 @@ class SSLSocket(socket):
if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
if buffer is not None: if buffer is not None:
return 0 return 0
else:
return b'' return b''
else: else:
raise raise
...@@ -368,7 +366,6 @@ class SSLSocket(socket): ...@@ -368,7 +366,6 @@ class SSLSocket(socket):
self._checkClosed() self._checkClosed()
if not self._sslobj or not _ssl.HAS_NPN: if not self._sslobj or not _ssl.HAS_NPN:
return None return None
else:
return self._sslobj.selected_npn_protocol() return self._sslobj.selected_npn_protocol()
if hasattr(_ssl, 'HAS_ALPN'): if hasattr(_ssl, 'HAS_ALPN'):
...@@ -377,21 +374,18 @@ class SSLSocket(socket): ...@@ -377,21 +374,18 @@ class SSLSocket(socket):
self._checkClosed() self._checkClosed()
if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member if not self._sslobj or not _ssl.HAS_ALPN: # pylint:disable=no-member
return None return None
else:
return self._sslobj.selected_alpn_protocol() return self._sslobj.selected_alpn_protocol()
def cipher(self): def cipher(self):
self._checkClosed() self._checkClosed()
if not self._sslobj: if not self._sslobj:
return None return None
else:
return self._sslobj.cipher() return self._sslobj.cipher()
def compression(self): def compression(self):
self._checkClosed() self._checkClosed()
if not self._sslobj: if not self._sslobj:
return None return None
else:
return self._sslobj.compression() return self._sslobj.compression()
def __check_flags(self, meth, flags): def __check_flags(self, meth, flags):
...@@ -510,7 +504,6 @@ class SSLSocket(socket): ...@@ -510,7 +504,6 @@ class SSLSocket(socket):
self._checkClosed() self._checkClosed()
if self._sslobj: if self._sslobj:
return self._sslobj.pending() return self._sslobj.pending()
else:
return 0 return 0
def shutdown(self, how): def shutdown(self, how):
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# A vendored version of part of https://github.com/ionelmc/python-tblib # A vendored version of part of https://github.com/ionelmc/python-tblib
# pylint:disable=redefined-outer-name,reimported,function-redefined,bare-except,no-else-return,broad-except
#### ####
# Copyright (c) 2013-2016, Ionel Cristian Mărieș # Copyright (c) 2013-2016, Ionel Cristian Mărieș
# All rights reserved. # All rights reserved.
...@@ -116,7 +117,7 @@ except ImportError: ...@@ -116,7 +117,7 @@ except ImportError:
tproxy = None tproxy = None
__version__ = '1.3.0' __version__ = '1.3.0'
__all__ = 'Traceback', __all__ = ('Traceback',)
PY3 = sys.version_info[0] == 3 PY3 = sys.version_info[0] == 3
FRAME_RE = re.compile(r'^\s*File "(?P<co_filename>.+)", line (?P<tb_lineno>\d+)(, in (?P<co_name>.+))?$') FRAME_RE = re.compile(r'^\s*File "(?P<co_filename>.+)", line (?P<tb_lineno>\d+)(, in (?P<co_name>.+))?$')
......
...@@ -138,7 +138,6 @@ class Condition(object): ...@@ -138,7 +138,6 @@ class Condition(object):
if self.__lock.acquire(0): if self.__lock.acquire(0):
self.__lock.release() self.__lock.release()
return False return False
else:
return True return True
def wait(self, timeout=None): def wait(self, timeout=None):
......
# this produces syntax error on Python3 # this produces syntax error on Python3
__all__ = ['reraise'] __all__ = ['reraise']
......
...@@ -48,6 +48,7 @@ class _Greenlet_stdreplace(Greenlet): ...@@ -48,6 +48,7 @@ class _Greenlet_stdreplace(Greenlet):
self.saved = None self.saved = None
def throw(self, *args, **kwargs): def throw(self, *args, **kwargs):
# pylint:disable=arguments-differ
if self.saved is None and self._fileobj is not None: if self.saved is None and self._fileobj is not None:
self.switch_in() self.switch_in()
Greenlet.throw(self, *args, **kwargs) Greenlet.throw(self, *args, **kwargs)
...@@ -147,7 +148,7 @@ class BackdoorServer(StreamServer): ...@@ -147,7 +148,7 @@ class BackdoorServer(StreamServer):
if sys.version_info[:3] >= (3, 6, 0): if sys.version_info[:3] >= (3, 6, 0):
# Beginning in 3.6, the console likes to print "now exiting <class>" # Beginning in 3.6, the console likes to print "now exiting <class>"
# but probably our socket is already closed, so this just causes problems. # but probably our socket is already closed, so this just causes problems.
console.interact(banner=self.banner, exitmsg='') console.interact(banner=self.banner, exitmsg='') # pylint:disable=unexpected-keyword-arg
else: else:
console.interact(banner=self.banner) console.interact(banner=self.banner)
except SystemExit: # raised by quit() except SystemExit: # raised by quit()
......
...@@ -75,7 +75,7 @@ def __import__(*args, **kwargs): ...@@ -75,7 +75,7 @@ def __import__(*args, **kwargs):
wraps the normal __import__ functionality in a recursive lock, ensuring that wraps the normal __import__ functionality in a recursive lock, ensuring that
we're protected against greenlet import concurrency as well. we're protected against greenlet import concurrency as well.
""" """
if len(args) > 0 and not issubclass(type(args[0]), _allowed_module_name_types): if args and not issubclass(type(args[0]), _allowed_module_name_types):
# if a builtin has been acquired as a bound instance method, # if a builtin has been acquired as a bound instance method,
# python knows not to pass 'self' when the method is called. # python knows not to pass 'self' when the method is called.
# No such protection exists for monkey-patched builtins, # No such protection exists for monkey-patched builtins,
......
...@@ -19,4 +19,4 @@ except ImportError: ...@@ -19,4 +19,4 @@ except ImportError:
copy_globals(_core, globals()) copy_globals(_core, globals())
__all__ = _core.__all__ __all__ = _core.__all__ # pylint:disable=no-member
...@@ -179,7 +179,7 @@ class Event(_AbstractLinkable): ...@@ -179,7 +179,7 @@ class Event(_AbstractLinkable):
""" """
self._flag = False self._flag = False
def _wait_return_value(self, waited, gotit): def _wait_return_value(self, waited, wait_success):
# To avoid the race condition outlined in http://bugs.python.org/issue13502, # To avoid the race condition outlined in http://bugs.python.org/issue13502,
# if we had to wait, then we need to return whether or not # if we had to wait, then we need to return whether or not
# the condition got changed. Otherwise we simply echo # the condition got changed. Otherwise we simply echo
...@@ -189,7 +189,7 @@ class Event(_AbstractLinkable): ...@@ -189,7 +189,7 @@ class Event(_AbstractLinkable):
assert flag, "if we didn't wait we should already be set" assert flag, "if we didn't wait we should already be set"
return flag return flag
return gotit return wait_success
def wait(self, timeout=None): def wait(self, timeout=None):
""" """
...@@ -393,7 +393,7 @@ class AsyncResult(_AbstractLinkable): ...@@ -393,7 +393,7 @@ class AsyncResult(_AbstractLinkable):
""" """
return self.get(block=False) return self.get(block=False)
def _wait_return_value(self, waited, gotit): def _wait_return_value(self, waited, wait_success):
# pylint:disable=unused-argument # pylint:disable=unused-argument
# Always return the value. Since this is a one-shot event, # Always return the value. Since this is a one-shot event,
# no race condition should reset it. # no race condition should reset it.
......
...@@ -57,9 +57,11 @@ else: ...@@ -57,9 +57,11 @@ else:
return return
__all__ = ['FileObjectPosix', __all__ = [
'FileObjectPosix',
'FileObjectThread', 'FileObjectThread',
'FileObject'] 'FileObject',
]
try: try:
from fcntl import fcntl from fcntl import fcntl
...@@ -104,7 +106,7 @@ class FileObjectThread(FileObjectBase): ...@@ -104,7 +106,7 @@ class FileObjectThread(FileObjectBase):
if self.lock is True: if self.lock is True:
self.lock = Semaphore() self.lock = Semaphore()
elif not self.lock: elif not self.lock:
self.lock = DummySemaphore() # pylint:disable=redefined-variable-type self.lock = DummySemaphore()
if not hasattr(self.lock, '__enter__'): if not hasattr(self.lock, '__enter__'):
raise TypeError('Expected a Semaphore or boolean, got %r' % type(self.lock)) raise TypeError('Expected a Semaphore or boolean, got %r' % type(self.lock))
if isinstance(fobj, integer_types): if isinstance(fobj, integer_types):
...@@ -201,6 +203,9 @@ class FileObjectBlock(FileObjectBase): ...@@ -201,6 +203,9 @@ class FileObjectBlock(FileObjectBase):
fobj = os.fdopen(fobj, *args) fobj = os.fdopen(fobj, *args)
super(FileObjectBlock, self).__init__(fobj, closefd) super(FileObjectBlock, self).__init__(fobj, closefd)
def _do_close(self, fobj, closefd):
fobj.close()
config = os.environ.get('GEVENT_FILE') config = os.environ.get('GEVENT_FILE')
if config: if config:
klass = {'thread': 'gevent.fileobject.FileObjectThread', klass = {'thread': 'gevent.fileobject.FileObjectThread',
......
...@@ -835,9 +835,8 @@ class Waiter(object): ...@@ -835,9 +835,8 @@ class Waiter(object):
def __str__(self): def __str__(self):
if self._exception is _NONE: if self._exception is _NONE:
return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet) return '<%s greenlet=%s>' % (type(self).__name__, self.greenlet)
elif self._exception is None: if self._exception is None:
return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value) return '<%s greenlet=%s value=%r>' % (type(self).__name__, self.greenlet, self.value)
else:
return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info) return '<%s greenlet=%s exc_info=%r>' % (type(self).__name__, self.greenlet, self.exc_info)
def ready(self): def ready(self):
......
# pylint: disable=too-many-lines, protected-access, redefined-outer-name, not-callable # pylint:disable=too-many-lines, protected-access, redefined-outer-name, not-callable,
from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function
import sys import sys
import os import os
import traceback import traceback
import signal as signalmodule import signal as signalmodule
# pylint:disable=undefined-all-variable
__all__ = [ __all__ = [
'get_version', 'get_version',
'get_header_version', 'get_header_version',
...@@ -108,7 +108,7 @@ def _python_callback(handle, revents): ...@@ -108,7 +108,7 @@ def _python_callback(handle, revents):
# Legacy behaviour from corecext: convert None into () # Legacy behaviour from corecext: convert None into ()
# See test__core_watcher.py # See test__core_watcher.py
args = _NOARGS args = _NOARGS
if len(args) > 0 and args[0] == GEVENT_CORE_EVENTS: if args and args[0] == GEVENT_CORE_EVENTS:
args = (revents, ) + args[1:] args = (revents, ) + args[1:]
the_watcher.callback(*args) the_watcher.callback(*args)
except: # pylint:disable=bare-except except: # pylint:disable=bare-except
...@@ -247,7 +247,7 @@ def _flags_to_list(flags): ...@@ -247,7 +247,7 @@ def _flags_to_list(flags):
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
basestring = (bytes, str) basestring = (bytes, str)
integer_types = int, integer_types = (int,)
else: else:
import __builtin__ # pylint:disable=import-error import __builtin__ # pylint:disable=import-error
basestring = __builtin__.basestring, basestring = __builtin__.basestring,
...@@ -892,6 +892,7 @@ class io(watcher): ...@@ -892,6 +892,7 @@ class io(watcher):
watcher.__init__(self, loop, ref=ref, priority=priority, args=(fd, events)) watcher.__init__(self, loop, ref=ref, priority=priority, args=(fd, events))
def start(self, callback, *args, **kwargs): def start(self, callback, *args, **kwargs):
# pylint:disable=arguments-differ
args = args or _NOARGS args = args or _NOARGS
if kwargs.get('pass_events'): if kwargs.get('pass_events'):
args = (GEVENT_CORE_EVENTS, ) + args args = (GEVENT_CORE_EVENTS, ) + args
...@@ -936,6 +937,7 @@ class timer(watcher): ...@@ -936,6 +937,7 @@ class timer(watcher):
watcher.__init__(self, loop, ref=ref, priority=priority, args=(after, repeat)) watcher.__init__(self, loop, ref=ref, priority=priority, args=(after, repeat))
def start(self, callback, *args, **kw): def start(self, callback, *args, **kw):
# pylint:disable=arguments-differ
update = kw.get("update", True) update = kw.get("update", True)
if update: if update:
# Quoth the libev doc: "This is a costly operation and is # Quoth the libev doc: "This is a costly operation and is
......
...@@ -78,11 +78,11 @@ __all__ = [ ...@@ -78,11 +78,11 @@ __all__ = [
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3:
string_types = str, string_types = (str,)
PY3 = True PY3 = True
else: else:
import __builtin__ # pylint:disable=import-error import __builtin__ # pylint:disable=import-error
string_types = __builtin__.basestring, string_types = (__builtin__.basestring,)
PY3 = False PY3 = False
WIN = sys.platform.startswith("win") WIN = sys.platform.startswith("win")
...@@ -128,7 +128,6 @@ def get_original(mod_name, item_name): ...@@ -128,7 +128,6 @@ def get_original(mod_name, item_name):
""" """
if isinstance(item_name, string_types): if isinstance(item_name, string_types):
return _get_original(mod_name, [item_name])[0] return _get_original(mod_name, [item_name])[0]
else:
return _get_original(mod_name, item_name) return _get_original(mod_name, item_name)
_NONE = object() _NONE = object()
...@@ -407,8 +406,6 @@ def patch_thread(threading=True, _threading_local=True, Event=False, logging=Tru ...@@ -407,8 +406,6 @@ def patch_thread(threading=True, _threading_local=True, Event=False, logging=Tru
if orig_current_thread == threading_mod.main_thread(): if orig_current_thread == threading_mod.main_thread():
main_thread = threading_mod.main_thread() main_thread = threading_mod.main_thread()
_greenlet = main_thread._greenlet = greenlet.getcurrent() _greenlet = main_thread._greenlet = greenlet.getcurrent()
from gevent.hub import sleep
main_thread.join = make_join_func(main_thread, _greenlet) main_thread.join = make_join_func(main_thread, _greenlet)
......
...@@ -322,7 +322,6 @@ class GroupMappingMixin(object): ...@@ -322,7 +322,6 @@ class GroupMappingMixin(object):
kwds = {} kwds = {}
if self._apply_immediately(): if self._apply_immediately():
return func(*args, **kwds) return func(*args, **kwds)
else:
return self.spawn(func, *args, **kwds).get() return self.spawn(func, *args, **kwds).get()
def map(self, func, iterable): def map(self, func, iterable):
......
...@@ -317,7 +317,6 @@ class Input(object): ...@@ -317,7 +317,6 @@ class Input(object):
def readline(self, size=None): def readline(self, size=None):
if self.chunked_input: if self.chunked_input:
return self._chunked_read(size, True) return self._chunked_read(size, True)
else:
return self._do_read(size, use_readline=True) return self._do_read(size, use_readline=True)
def readlines(self, hint=None): def readlines(self, hint=None):
...@@ -1465,7 +1464,7 @@ class WSGIServer(StreamServer): ...@@ -1465,7 +1464,7 @@ class WSGIServer(StreamServer):
except socket.error: except socket.error:
name = str(address[0]) name = str(address[0])
if PY3 and not isinstance(name, str): if PY3 and not isinstance(name, str):
name = name.decode('ascii') # python 2 pylint:disable=redefined-variable-type name = name.decode('ascii')
self.environ['SERVER_NAME'] = name self.environ['SERVER_NAME'] = name
self.environ.setdefault('SERVER_PORT', str(address[1])) self.environ.setdefault('SERVER_PORT', str(address[1]))
else: else:
......
...@@ -139,7 +139,6 @@ class Queue(object): ...@@ -139,7 +139,6 @@ class Queue(object):
result.append('putters[%s]' % len(self.putters)) result.append('putters[%s]' % len(self.putters))
if result: if result:
return ' ' + ' '.join(result) return ' ' + ' '.join(result)
else:
return '' return ''
def qsize(self): def qsize(self):
......
...@@ -221,8 +221,8 @@ class Resolver(object): ...@@ -221,8 +221,8 @@ class Resolver(object):
if addrs.family == AF_INET: if addrs.family == AF_INET:
for addr in addrs[-1]: for addr in addrs[-1]:
sockaddr = (addr, port) sockaddr = (addr, port)
for socktype, proto in socktype_proto: for socktype4, proto4 in socktype_proto:
result4.append((AF_INET, socktype, proto, '', sockaddr)) result4.append((AF_INET, socktype4, proto4, '', sockaddr))
elif addrs.family == AF_INET6: elif addrs.family == AF_INET6:
for addr in addrs[-1]: for addr in addrs[-1]:
if addr == '::1': if addr == '::1':
...@@ -230,8 +230,8 @@ class Resolver(object): ...@@ -230,8 +230,8 @@ class Resolver(object):
else: else:
dest = result6 dest = result6
sockaddr = (addr, port, 0, 0) sockaddr = (addr, port, 0, 0)
for socktype, proto in socktype_proto: for socktype6, proto6 in socktype_proto:
dest.append((AF_INET6, socktype, proto, '', sockaddr)) dest.append((AF_INET6, socktype6, proto6, '', sockaddr))
# As of 2016, some platforms return IPV6 first and some do IPV4 first, # As of 2016, some platforms return IPV6 first and some do IPV4 first,
# and some might even allow configuration of which is which. For backwards # and some might even allow configuration of which is which. For backwards
......
...@@ -166,6 +166,7 @@ class StreamServer(BaseServer): ...@@ -166,6 +166,7 @@ class StreamServer(BaseServer):
return sockobj, address return sockobj, address
def do_close(self, sock, *args): def do_close(self, sock, *args):
# pylint:disable=arguments-differ
sock.close() sock.close()
def wrap_socket_and_handle(self, client_socket, address): def wrap_socket_and_handle(self, client_socket, address):
......
...@@ -5,7 +5,8 @@ from gevent._compat import PY2 ...@@ -5,7 +5,8 @@ from gevent._compat import PY2
from gevent._util import copy_globals from gevent._util import copy_globals
# things we expect to override, here for static analysis # things we expect to override, here for static analysis
def wrap_socket(sock, **kwargs): # pylint:disable=unused-argument def wrap_socket(_sock, **_kwargs):
# pylint:disable=unused-argument
raise NotImplementedError() raise NotImplementedError()
if PY2: if PY2:
......
...@@ -29,13 +29,12 @@ from __future__ import absolute_import, print_function ...@@ -29,13 +29,12 @@ from __future__ import absolute_import, print_function
# Import magic # Import magic
# pylint: disable=undefined-all-variable,undefined-variable # pylint: disable=undefined-all-variable,undefined-variable
# Most of this we inherit from the standard lib # Most of this we inherit from the standard lib
# pylint: disable=bare-except,too-many-locals,too-many-statements,bad-builtin,attribute-defined-outside-init # pylint: disable=bare-except,too-many-locals,too-many-statements,attribute-defined-outside-init
# pylint: disable=too-many-branches,too-many-instance-attributes # pylint: disable=too-many-branches,too-many-instance-attributes
# Most of this is cross-platform # Most of this is cross-platform
# pylint: disable=no-member,expression-not-assigned,unused-argument,unused-variable # pylint: disable=no-member,expression-not-assigned,unused-argument,unused-variable
import errno import errno
import gc import gc
import io
import os import os
import signal import signal
import sys import sys
......
...@@ -43,8 +43,7 @@ from gevent.local import local as _local ...@@ -43,8 +43,7 @@ from gevent.local import local as _local
def get_ident(gr=None): def get_ident(gr=None):
if gr is None: if gr is None:
return id(getcurrent()) gr = getcurrent()
else:
return id(gr) return id(gr)
......
...@@ -119,6 +119,7 @@ class _DummyThread(_DummyThread_): ...@@ -119,6 +119,7 @@ class _DummyThread(_DummyThread_):
_stop = _Thread__stop # py3 _stop = _Thread__stop # py3
def _wait_for_tstate_lock(self, *args, **kwargs): def _wait_for_tstate_lock(self, *args, **kwargs):
# pylint:disable=arguments-differ
pass pass
if hasattr(__threading__, 'main_thread'): # py 3.4+ if hasattr(__threading__, 'main_thread'): # py 3.4+
...@@ -202,6 +203,7 @@ if sys.version_info[:2] >= (3, 4): ...@@ -202,6 +203,7 @@ if sys.version_info[:2] >= (3, 4):
self._greenlet.join(timeout=timeout) self._greenlet.join(timeout=timeout)
def _wait_for_tstate_lock(self, *args, **kwargs): def _wait_for_tstate_lock(self, *args, **kwargs):
# pylint:disable=arguments-differ
raise NotImplementedError() raise NotImplementedError()
__implements__.append('Thread') __implements__.append('Thread')
......
...@@ -402,7 +402,7 @@ else: ...@@ -402,7 +402,7 @@ else:
# We should only be called when _waiters has # We should only be called when _waiters has
# already been accessed. # already been accessed.
waiters = getattr(self, '_waiters') waiters = getattr(self, '_waiters')
for w in waiters: for w in waiters: # pylint:disable=not-an-iterable
if self.successful(): if self.successful():
w.add_result(self) w.add_result(self)
else: else:
...@@ -475,7 +475,7 @@ else: ...@@ -475,7 +475,7 @@ else:
self._threadpool._destroy_worker_hub = True self._threadpool._destroy_worker_hub = True
def submit(self, fn, *args, **kwargs): def submit(self, fn, *args, **kwargs):
with self._shutdown_lock: with self._shutdown_lock: # pylint:disable=not-context-manager
if self._shutdown: if self._shutdown:
raise RuntimeError('cannot schedule new futures after shutdown') raise RuntimeError('cannot schedule new futures after shutdown')
...@@ -486,7 +486,7 @@ else: ...@@ -486,7 +486,7 @@ else:
super(ThreadPoolExecutor, self).shutdown(wait) super(ThreadPoolExecutor, self).shutdown(wait)
# XXX: We don't implement wait properly # XXX: We don't implement wait properly
kill = getattr(self._threadpool, 'kill', None) kill = getattr(self._threadpool, 'kill', None)
if kill: if kill: # pylint:disable=using-constant-test
self._threadpool.kill() self._threadpool.kill()
self._threadpool = None self._threadpool = None
......
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