mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Fix various warnings and errors reported by pylint
This commit is contained in:
parent
249783567f
commit
76eaa0805b
@ -78,6 +78,9 @@ class BaseApplication(object):
|
|||||||
|
|
||||||
class Application(BaseApplication):
|
class Application(BaseApplication):
|
||||||
|
|
||||||
|
# 'init' and 'load' methods are implemented by WSGIApplication.
|
||||||
|
# pylint: disable=abstract-method
|
||||||
|
|
||||||
def chdir(self):
|
def chdir(self):
|
||||||
# chdir to the configured path before loading,
|
# chdir to the configured path before loading,
|
||||||
# default is the current dir
|
# default is the current dir
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
# pylint: skip-file
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import sys
|
import sys
|
||||||
@ -120,7 +122,8 @@ class PasterApplication(PasterBaseApplication):
|
|||||||
|
|
||||||
class PasterServerApplication(PasterBaseApplication):
|
class PasterServerApplication(PasterBaseApplication):
|
||||||
|
|
||||||
def __init__(self, app, gcfg=None, host="127.0.0.1", port=None, *args, **kwargs):
|
def __init__(self, app, gcfg=None, host="127.0.0.1", port=None, **kwargs):
|
||||||
|
# pylint: disable=super-init-not-called
|
||||||
self.cfg = Config()
|
self.cfg = Config()
|
||||||
self.gcfg = gcfg # need to hold this for app_config
|
self.gcfg = gcfg # need to hold this for app_config
|
||||||
self.app = app
|
self.app = app
|
||||||
@ -182,7 +185,7 @@ def run():
|
|||||||
PasterApplication("%(prog)s [OPTIONS] pasteconfig.ini").run()
|
PasterApplication("%(prog)s [OPTIONS] pasteconfig.ini").run()
|
||||||
|
|
||||||
|
|
||||||
def paste_server(app, gcfg=None, host="127.0.0.1", port=None, *args, **kwargs):
|
def paste_server(app, gcfg=None, host="127.0.0.1", port=None, **kwargs):
|
||||||
"""\
|
"""\
|
||||||
A paster server.
|
A paster server.
|
||||||
|
|
||||||
@ -203,4 +206,4 @@ def paste_server(app, gcfg=None, host="127.0.0.1", port=None, *args, **kwargs):
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
from gunicorn.app.pasterapp import PasterServerApplication
|
from gunicorn.app.pasterapp import PasterServerApplication
|
||||||
PasterServerApplication(app, gcfg=gcfg, host=host, port=port, *args, **kwargs).run()
|
PasterServerApplication(app, gcfg=gcfg, host=host, port=port, **kwargs).run()
|
||||||
|
|||||||
@ -13,12 +13,11 @@ import inspect
|
|||||||
|
|
||||||
__all__ = ['spew', 'unspew']
|
__all__ = ['spew', 'unspew']
|
||||||
|
|
||||||
_token_spliter = re.compile('\W+')
|
_token_spliter = re.compile(r'\W+')
|
||||||
|
|
||||||
|
|
||||||
class Spew(object):
|
class Spew(object):
|
||||||
"""
|
|
||||||
"""
|
|
||||||
def __init__(self, trace_names=None, show_values=True):
|
def __init__(self, trace_names=None, show_values=True):
|
||||||
self.trace_names = trace_names
|
self.trace_names = trace_names
|
||||||
self.show_values = show_values
|
self.show_values = show_values
|
||||||
|
|||||||
@ -3,8 +3,14 @@
|
|||||||
# This file is part of gunicorn released under the MIT license.
|
# This file is part of gunicorn released under the MIT license.
|
||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
|
|
||||||
|
# We don't need to call super() in __init__ methods of our
|
||||||
|
# BaseException and Exception classes because we also define
|
||||||
|
# our own __str__ methods so there is no need to pass 'message'
|
||||||
|
# to the base class to get a meaningful output from 'str(exc)'.
|
||||||
|
# pylint: disable=super-init-not-called
|
||||||
|
|
||||||
# we inherit from BaseException here to make sure to not be caucght
|
|
||||||
|
# we inherit from BaseException here to make sure to not be caught
|
||||||
# at application level
|
# at application level
|
||||||
class HaltServer(BaseException):
|
class HaltServer(BaseException):
|
||||||
def __init__(self, reason, exit_status=1):
|
def __init__(self, reason, exit_status=1):
|
||||||
|
|||||||
@ -3,6 +3,12 @@
|
|||||||
# This file is part of gunicorn released under the MIT license.
|
# This file is part of gunicorn released under the MIT license.
|
||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
|
|
||||||
|
# We don't need to call super() in __init__ methods of our
|
||||||
|
# BaseException and Exception classes because we also define
|
||||||
|
# our own __str__ methods so there is no need to pass 'message'
|
||||||
|
# to the base class to get a meaningful output from 'str(exc)'.
|
||||||
|
# pylint: disable=super-init-not-called
|
||||||
|
|
||||||
|
|
||||||
class ParseException(Exception):
|
class ParseException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -22,7 +22,7 @@ MAX_REQUEST_LINE = 8190
|
|||||||
MAX_HEADERS = 32768
|
MAX_HEADERS = 32768
|
||||||
DEFAULT_MAX_HEADERFIELD_SIZE = 8190
|
DEFAULT_MAX_HEADERFIELD_SIZE = 8190
|
||||||
|
|
||||||
HEADER_RE = re.compile("[\x00-\x1F\x7F()<>@,;:\[\]={} \t\\\\\"]")
|
HEADER_RE = re.compile(r"[\x00-\x1F\x7F()<>@,;:\[\]={} \t\\\"]")
|
||||||
METH_RE = re.compile(r"[A-Z0-9$-_.]{3,20}")
|
METH_RE = re.compile(r"[A-Z0-9$-_.]{3,20}")
|
||||||
VERSION_RE = re.compile(r"HTTP/(\d+)\.(\d+)")
|
VERSION_RE = re.compile(r"HTTP/(\d+)\.(\d+)")
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,9 @@ class FileWrapper(object):
|
|||||||
class WSGIErrorsWrapper(io.RawIOBase):
|
class WSGIErrorsWrapper(io.RawIOBase):
|
||||||
|
|
||||||
def __init__(self, cfg):
|
def __init__(self, cfg):
|
||||||
|
# There is no public __init__ method for RawIOBase so
|
||||||
|
# we don't need to call super() in the __init__ method.
|
||||||
|
# pylint: disable=super-init-not-called
|
||||||
errorlog = logging.getLogger("gunicorn.error")
|
errorlog = logging.getLogger("gunicorn.error")
|
||||||
handlers = errorlog.handlers
|
handlers = errorlog.handlers
|
||||||
self.streams = []
|
self.streams = []
|
||||||
|
|||||||
@ -27,7 +27,7 @@ class Statsd(Logger):
|
|||||||
"""host, port: statsD server
|
"""host, port: statsD server
|
||||||
"""
|
"""
|
||||||
Logger.__init__(self, cfg)
|
Logger.__init__(self, cfg)
|
||||||
self.prefix = sub(r"^(.+[^.]+)\.*$", "\g<1>.", cfg.statsd_prefix)
|
self.prefix = sub(r"^(.+[^.]+)\.*$", "\\g<1>.", cfg.statsd_prefix)
|
||||||
try:
|
try:
|
||||||
host, port = cfg.statsd_host
|
host, port = cfg.statsd_host
|
||||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
|||||||
@ -199,7 +199,7 @@ if sys.platform.startswith("win"):
|
|||||||
# Other Windows APIs can fail or give incorrect results when
|
# Other Windows APIs can fail or give incorrect results when
|
||||||
# dealing with files that are pending deletion.
|
# dealing with files that are pending deletion.
|
||||||
L = os.listdir(dirname)
|
L = os.listdir(dirname)
|
||||||
if not (L if waitall else name in L):
|
if not L if waitall else name in L:
|
||||||
return
|
return
|
||||||
# Increase the timeout and try again
|
# Increase the timeout and try again
|
||||||
time.sleep(timeout)
|
time.sleep(timeout)
|
||||||
|
|||||||
@ -9,7 +9,7 @@ from gunicorn import util
|
|||||||
|
|
||||||
if sys.version_info >= (3, 4):
|
if sys.version_info >= (3, 4):
|
||||||
try:
|
try:
|
||||||
import aiohttp # NOQA
|
import aiohttp # pylint: disable=unused-import
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise RuntimeError("You need aiohttp installed to use this worker.")
|
raise RuntimeError("You need aiohttp installed to use this worker.")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -50,7 +50,7 @@ def requires_mac_ver(*min_version):
|
|||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from types import SimpleNamespace # noqa
|
from types import SimpleNamespace # pylint: disable=unused-import
|
||||||
except ImportError:
|
except ImportError:
|
||||||
class SimpleNamespace(object):
|
class SimpleNamespace(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|||||||
@ -92,7 +92,7 @@ def test_http_header_encoding():
|
|||||||
header_str = "%s\r\n" % "".join(tosend)
|
header_str = "%s\r\n" % "".join(tosend)
|
||||||
|
|
||||||
with pytest.raises(UnicodeEncodeError):
|
with pytest.raises(UnicodeEncodeError):
|
||||||
mocked_socket.sendall(util.to_bytestring(header_str,"ascii"))
|
mocked_socket.sendall(util.to_bytestring(header_str, "ascii"))
|
||||||
|
|
||||||
|
|
||||||
def test_http_invalid_response_header():
|
def test_http_invalid_response_header():
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import pytest
|
|||||||
|
|
||||||
from gunicorn import util
|
from gunicorn import util
|
||||||
from gunicorn.errors import AppImportError
|
from gunicorn.errors import AppImportError
|
||||||
from gunicorn.six.moves.urllib.parse import SplitResult
|
from gunicorn.six.moves.urllib.parse import SplitResult # pylint: disable=no-name-in-module
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('test_input, expected', [
|
@pytest.mark.parametrize('test_input, expected', [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user