From 31b8e48a78cbcde02d0ac8a9f8d8e1891961f40c Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 6 Feb 2017 07:54:41 +0300 Subject: [PATCH] Silence prospector warnings --- .../testing/testing/apps/someapp/middleware.py | 3 ++- .../testing/testing/apps/someapp/models.py | 3 --- .../django/testing/testing/apps/someapp/views.py | 4 +--- .../django/testing/testing/settings.py | 2 +- examples/longpoll.py | 1 - examples/websocket/gevent_websocket.py | 4 ++-- examples/websocket/websocket.py | 2 +- gunicorn/util.py | 2 -- gunicorn/workers/gtornado.py | 16 ++++++++-------- scripts/update_thanks.py | 1 - tests/t.py | 14 -------------- tests/test_config.py | 2 -- tests/test_statsd.py | 3 --- tests/treq.py | 2 -- 14 files changed, 15 insertions(+), 44 deletions(-) diff --git a/examples/frameworks/django/testing/testing/apps/someapp/middleware.py b/examples/frameworks/django/testing/testing/apps/someapp/middleware.py index 8dc50ad1..39a4e234 100644 --- a/examples/frameworks/django/testing/testing/apps/someapp/middleware.py +++ b/examples/frameworks/django/testing/testing/apps/someapp/middleware.py @@ -1,12 +1,13 @@ from multiprocessing import Process, Queue import requests -import gevent + def child_process(queue): while True: print(queue.get()) requests.get('http://requestb.in/15s95oz1') + class GunicornSubProcessTestMiddleware(object): def __init__(self): super(GunicornSubProcessTestMiddleware, self).__init__() diff --git a/examples/frameworks/django/testing/testing/apps/someapp/models.py b/examples/frameworks/django/testing/testing/apps/someapp/models.py index 71a83623..e69de29b 100644 --- a/examples/frameworks/django/testing/testing/apps/someapp/models.py +++ b/examples/frameworks/django/testing/testing/apps/someapp/models.py @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/examples/frameworks/django/testing/testing/apps/someapp/views.py b/examples/frameworks/django/testing/testing/apps/someapp/views.py index 632b340f..ba61d1e3 100755 --- a/examples/frameworks/django/testing/testing/apps/someapp/views.py +++ b/examples/frameworks/django/testing/testing/apps/someapp/views.py @@ -1,5 +1,3 @@ -# Create your views here. - import csv import io import os @@ -7,7 +5,7 @@ from django import forms from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import RequestContext -import tempfile + class MsgForm(forms.Form): subject = forms.CharField(max_length=100) diff --git a/examples/frameworks/django/testing/testing/settings.py b/examples/frameworks/django/testing/testing/settings.py index 97cedf27..d978daa2 100644 --- a/examples/frameworks/django/testing/testing/settings.py +++ b/examples/frameworks/django/testing/testing/settings.py @@ -81,7 +81,7 @@ STATICFILES_FINDERS = ( ) # Make this unique, and don't share it with anybody. -SECRET_KEY = '0!jubm9ho=s_32kac4wt#$9+hb#qzsg6c7+%83hqujcdfw%5*-' +SECRET_KEY = '' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( diff --git a/examples/longpoll.py b/examples/longpoll.py index e832dcf5..1bab8eaa 100644 --- a/examples/longpoll.py +++ b/examples/longpoll.py @@ -17,7 +17,6 @@ class TestIter(object): def app(environ, start_response): """Application which cooperatively pauses 20 seconds (needed to surpass normal timeouts) before responding""" - data = b'Hello, World!\n' status = '200 OK' response_headers = [ ('Content-type', 'text/plain'), diff --git a/examples/websocket/gevent_websocket.py b/examples/websocket/gevent_websocket.py index 64b5fb37..763f23ec 100644 --- a/examples/websocket/gevent_websocket.py +++ b/examples/websocket/gevent_websocket.py @@ -2,7 +2,7 @@ import collections import errno import re -from hashlib import md5, sha1 +from hashlib import sha1 import base64 from base64 import b64encode, b64decode import socket @@ -106,7 +106,7 @@ class WebSocketWSGI(object): try: self.handler(ws) - except socket.error, e: + except socket.error as e: if e[0] != errno.EPIPE: raise # use this undocumented feature of grainbows to ensure that it diff --git a/examples/websocket/websocket.py b/examples/websocket/websocket.py index 24edb9db..4f5c8199 100644 --- a/examples/websocket/websocket.py +++ b/examples/websocket/websocket.py @@ -107,7 +107,7 @@ class WebSocketWSGI(object): try: self.handler(ws) - except socket.error, e: + except socket.error as e: if e[0] != errno.EPIPE: raise # use this undocumented feature of grainbows to ensure that it diff --git a/gunicorn/util.py b/gunicorn/util.py index 73974919..ea23761e 100644 --- a/gunicorn/util.py +++ b/gunicorn/util.py @@ -7,7 +7,6 @@ from __future__ import print_function import email.utils import fcntl -import grp import io import os import pkg_resources @@ -15,7 +14,6 @@ import pwd import random import resource import socket -import stat import sys import textwrap import time diff --git a/gunicorn/workers/gtornado.py b/gunicorn/workers/gtornado.py index 2337991b..2bb30cc1 100644 --- a/gunicorn/workers/gtornado.py +++ b/gunicorn/workers/gtornado.py @@ -27,7 +27,7 @@ class TornadoWorker(Worker): def clear(self): old_clear(self) - if not "Gunicorn" in self._headers["Server"]: + if "Gunicorn" not in self._headers["Server"]: self._headers["Server"] += " (Gunicorn/%s)" % gversion web.RequestHandler.clear = clear sys.modules["tornado.web"] = web @@ -104,13 +104,13 @@ class TornadoWorker(Worker): server_class = _HTTPServer if self.cfg.is_ssl: - _ssl_opt = copy.deepcopy(self.cfg.ssl_options) - # tornado refuses initialization if ssl_options contains following - # options - del _ssl_opt["do_handshake_on_connect"] - del _ssl_opt["suppress_ragged_eofs"] - server = server_class(app, io_loop=self.ioloop, - ssl_options=_ssl_opt) + _ssl_opt = copy.deepcopy(self.cfg.ssl_options) + # tornado refuses initialization if ssl_options contains following + # options + del _ssl_opt["do_handshake_on_connect"] + del _ssl_opt["suppress_ragged_eofs"] + server = server_class(app, io_loop=self.ioloop, + ssl_options=_ssl_opt) else: server = server_class(app, io_loop=self.ioloop) diff --git a/scripts/update_thanks.py b/scripts/update_thanks.py index a1175ceb..8c355848 100644 --- a/scripts/update_thanks.py +++ b/scripts/update_thanks.py @@ -7,7 +7,6 @@ # pip install validate_email pyDNS # from __future__ import print_function -import os import sys from validate_email import validate_email diff --git a/tests/t.py b/tests/t.py index 40c1e2ba..db16e7a6 100644 --- a/tests/t.py +++ b/tests/t.py @@ -10,7 +10,6 @@ import tempfile dirname = os.path.dirname(__file__) from gunicorn.http.parser import RequestParser -from gunicorn.config import Config from gunicorn.six import BytesIO @@ -66,16 +65,3 @@ class FakeSocket(object): def seek(self, offset, whence=0): self.tmp.seek(offset, whence) - - -class http_request(object): - def __init__(self, name): - self.fname = os.path.join(dirname, "requests", name) - - def __call__(self, func): - def run(): - fsock = FakeSocket(data_source(self.fname)) - req = Request(Config(), fsock, ('127.0.0.1', 6000), ('127.0.0.1', 8000)) - func(req) - run.func_name = func.func_name - return run diff --git a/tests/test_config.py b/tests/test_config.py index 2739afd3..28554184 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -3,8 +3,6 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -import t - import os import sys diff --git a/tests/test_statsd.py b/tests/test_statsd.py index babc78db..ed55fa2a 100644 --- a/tests/test_statsd.py +++ b/tests/test_statsd.py @@ -1,8 +1,5 @@ from datetime import timedelta import socket - -import t - import logging import tempfile import shutil diff --git a/tests/treq.py b/tests/treq.py index 703a9673..163664c4 100644 --- a/tests/treq.py +++ b/tests/treq.py @@ -3,8 +3,6 @@ # This file is part of the pywebmachine package released # under the MIT license. -import t - import inspect import os import random