diff options
author | Sergey Shepelev <temotor@gmail.com> | 2023-01-18 00:58:18 +0300 |
---|---|---|
committer | Sergey Shepelev <temotor@gmail.com> | 2023-01-18 08:55:02 +0300 |
commit | d05b2a9dde875eece42c8c09c7a793dd43407cc3 (patch) | |
tree | 1cf5686809ec5dcd52ed4696500c82377ea1a0fd | |
parent | caf9f9983a43c537efff5c4c9ff1d543af6e1220 (diff) | |
download | eventlet-d05b2a9dde875eece42c8c09c7a793dd43407cc3.tar.gz |
chore: CI upgrades, pycodestyle fix 2 empty lines after class/def
- github actions ubuntu-latest switched to 22.04 with python3>=3.7
- tool: pep8 was renamed and upgraded to pycodestyle 2.1, fixed 2 empty lines after class/def
- common github actions upgrade to v3 https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
29 files changed, 75 insertions, 39 deletions
diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index d3955f7..d3f6384 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -10,10 +10,10 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: cache pip - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('.github/workflows/style.yaml') }} @@ -21,7 +21,7 @@ jobs: ${{ runner.os }}-pip- ${{ runner.os }}- - name: cache tox - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-tox-style-${{ hashFiles('tox.ini') }} @@ -31,7 +31,7 @@ jobs: ${{ runner.os }}- - name: setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: 3.x - name: install tox diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3801d2a..914f8ca 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,7 +8,7 @@ jobs: tox: name: "tox ${{ matrix.toxenv }}" continue-on-error: ${{ matrix.ignore-error }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} # https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5 if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'eventlet/eventlet' timeout-minutes: 10 @@ -29,38 +29,38 @@ jobs: fail-fast: false matrix: include: - - { py: 2.7, toxenv: py27-epolls, ignore-error: false } - - { py: 2.7, toxenv: py27-poll, ignore-error: false } - - { py: 2.7, toxenv: py27-selects, ignore-error: false } - - { py: 2.7, toxenv: py27-dnspython1, ignore-error: false } - - { py: 3.5, toxenv: py35-epolls, ignore-error: false } - - { py: 3.5, toxenv: py35-poll, ignore-error: false } - - { py: 3.5, toxenv: py35-selects, ignore-error: false } - - { py: 3.6, toxenv: py36-epolls, ignore-error: false } - - { py: 3.6, toxenv: py36-poll, ignore-error: false } - - { py: 3.6, toxenv: py36-selects, ignore-error: false } - - { py: 3.7, toxenv: py37-epolls, ignore-error: false } - - { py: 3.7, toxenv: py37-poll, ignore-error: false } - - { py: 3.7, toxenv: py37-selects, ignore-error: false } - - { py: 3.8, toxenv: py38-epolls, ignore-error: false } - - { py: 3.8, toxenv: py38-openssl, ignore-error: false } - - { py: 3.8, toxenv: py38-poll, ignore-error: false } - - { py: 3.8, toxenv: py38-selects, ignore-error: false } - - { py: 3.9, toxenv: py39-epolls, ignore-error: false } - - { py: 3.9, toxenv: py39-poll, ignore-error: false } - - { py: 3.9, toxenv: py39-selects, ignore-error: false } - - { py: 3.9, toxenv: py39-dnspython1, ignore-error: false } - - { py: 3.x, toxenv: ipv6, ignore-error: false } - - { py: pypy2, toxenv: pypy2-epolls, ignore-error: true } - - { py: pypy3, toxenv: pypy3-epolls, ignore-error: true } + - { py: 2.7, toxenv: py27-epolls, ignore-error: false, os: ubuntu-latest } + - { py: 2.7, toxenv: py27-poll, ignore-error: false, os: ubuntu-latest } + - { py: 2.7, toxenv: py27-selects, ignore-error: false, os: ubuntu-latest } + - { py: 2.7, toxenv: py27-dnspython1, ignore-error: false, os: ubuntu-latest } + - { py: 3.5, toxenv: py35-epolls, ignore-error: false, os: ubuntu-20.04 } + - { py: 3.5, toxenv: py35-poll, ignore-error: false, os: ubuntu-20.04 } + - { py: 3.5, toxenv: py35-selects, ignore-error: false, os: ubuntu-20.04 } + - { py: 3.6, toxenv: py36-epolls, ignore-error: false, os: ubuntu-20.04 } + - { py: 3.6, toxenv: py36-poll, ignore-error: false, os: ubuntu-20.04 } + - { py: 3.6, toxenv: py36-selects, ignore-error: false, os: ubuntu-20.04 } + - { py: 3.7, toxenv: py37-epolls, ignore-error: false, os: ubuntu-latest } + - { py: 3.7, toxenv: py37-poll, ignore-error: false, os: ubuntu-latest } + - { py: 3.7, toxenv: py37-selects, ignore-error: false, os: ubuntu-latest } + - { py: 3.8, toxenv: py38-epolls, ignore-error: false, os: ubuntu-latest } + - { py: 3.8, toxenv: py38-openssl, ignore-error: false, os: ubuntu-latest } + - { py: 3.8, toxenv: py38-poll, ignore-error: false, os: ubuntu-latest } + - { py: 3.8, toxenv: py38-selects, ignore-error: false, os: ubuntu-latest } + - { py: 3.9, toxenv: py39-epolls, ignore-error: false, os: ubuntu-latest } + - { py: 3.9, toxenv: py39-poll, ignore-error: false, os: ubuntu-latest } + - { py: 3.9, toxenv: py39-selects, ignore-error: false, os: ubuntu-latest } + - { py: 3.9, toxenv: py39-dnspython1, ignore-error: false, os: ubuntu-latest } + - { py: 3.x, toxenv: ipv6, ignore-error: false, os: ubuntu-latest } + - { py: pypy2.7, toxenv: pypy2-epolls, ignore-error: true, os: ubuntu-20.04 } + - { py: pypy3.9, toxenv: pypy3-epolls, ignore-error: true, os: ubuntu-20.04 } steps: - name: install system packages run: sudo apt install -y --no-install-recommends ccache libffi-dev default-libmysqlclient-dev libpq-dev libssl-dev libzmq3-dev - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: cache pip - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.toxenv }}-${{ hashFiles('.github/workflows/test.yaml', 'setup.py') }} @@ -68,7 +68,7 @@ jobs: ${{ runner.os }}-pip- ${{ runner.os }}- - name: cache tox - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: .tox key: ${{ runner.os }}-tox-${{ matrix.toxenv }}-${{ hashFiles('tox.ini') }} @@ -77,7 +77,7 @@ jobs: ${{ runner.os }}- - name: setup python ${{ matrix.py }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.py }} - name: install codecov, tox diff --git a/eventlet/convenience.py b/eventlet/convenience.py index 5f99ade..a02284d 100644 --- a/eventlet/convenience.py +++ b/eventlet/convenience.py @@ -157,6 +157,7 @@ def wrap_ssl(sock, *a, **kw): """ return wrap_ssl_impl(sock, *a, **kw) + try: from eventlet.green import ssl wrap_ssl_impl = ssl.wrap_socket diff --git a/eventlet/db_pool.py b/eventlet/db_pool.py index 45b1771..ef74d99 100644 --- a/eventlet/db_pool.py +++ b/eventlet/db_pool.py @@ -361,6 +361,8 @@ class GenericConnectionWrapper(object): 'use_result', 'warning_count', ) + + for _proxy_fun in GenericConnectionWrapper._proxy_funcs: # excess wrapper for early binding (closure by value) def _wrapper(_proxy_fun=_proxy_fun): diff --git a/eventlet/event.py b/eventlet/event.py index 6ab455f..9d99a54 100644 --- a/eventlet/event.py +++ b/eventlet/event.py @@ -10,6 +10,7 @@ class NOT_USED: def __repr__(self): return 'NOT_USED' + NOT_USED = NOT_USED() diff --git a/eventlet/green/MySQLdb.py b/eventlet/green/MySQLdb.py index 3593542..2395e51 100644 --- a/eventlet/green/MySQLdb.py +++ b/eventlet/green/MySQLdb.py @@ -16,6 +16,8 @@ __orig_connections = __import__('MySQLdb.connections').connections def Connection(*args, **kw): conn = tpool.execute(__orig_connections.Connection, *args, **kw) return tpool.Proxy(conn, autowrap_names=('cursor',)) + + connect = Connect = Connection @@ -23,6 +25,7 @@ connect = Connect = Connection class MySQLdbConnectionsModule(object): pass + connections = MySQLdbConnectionsModule() for var in dir(__orig_connections): if not var.startswith('__'): diff --git a/eventlet/green/OpenSSL/SSL.py b/eventlet/green/OpenSSL/SSL.py index f534cea..bb06c8b 100644 --- a/eventlet/green/OpenSSL/SSL.py +++ b/eventlet/green/OpenSSL/SSL.py @@ -119,6 +119,7 @@ class GreenConnection(greenio.GreenSocket): timeout=self.gettimeout(), timeout_exc=socket.timeout) + Connection = ConnectionType = GreenConnection del greenio diff --git a/eventlet/green/Queue.py b/eventlet/green/Queue.py index f999c3b..59a9a30 100644 --- a/eventlet/green/Queue.py +++ b/eventlet/green/Queue.py @@ -28,5 +28,6 @@ class LifoQueue(queue.LifoQueue): maxsize = None super(LifoQueue, self).__init__(maxsize) + Empty = queue.Empty Full = queue.Full diff --git a/eventlet/green/os.py b/eventlet/green/os.py index e13a51e..2d1fe6a 100644 --- a/eventlet/green/os.py +++ b/eventlet/green/os.py @@ -29,6 +29,7 @@ def fdopen(fd, *args, **kw): except IOError as e: raise OSError(*e.args) + __original_read__ = os_orig.read @@ -51,6 +52,7 @@ def read(fd, n): except hubs.IOClosed: return '' + __original_write__ = os_orig.write @@ -77,6 +79,7 @@ def wait(): Wait for completion of a child process.""" return waitpid(0, 0) + __original_waitpid__ = os_orig.waitpid @@ -95,6 +98,7 @@ def waitpid(pid, options): return rpid, status greenthread.sleep(0.01) + __original_open__ = os_orig.open diff --git a/eventlet/green/threading.py b/eventlet/green/threading.py index fce9bca..93be29e 100644 --- a/eventlet/green/threading.py +++ b/eventlet/green/threading.py @@ -131,4 +131,5 @@ def current_thread(): return t + currentThread = current_thread diff --git a/eventlet/green/zmq.py b/eventlet/green/zmq.py index 1e41103..373aca1 100644 --- a/eventlet/green/zmq.py +++ b/eventlet/green/zmq.py @@ -148,6 +148,7 @@ def _wraps(source_fn): return dest_fn return wrapper + # Implementation notes: Each socket in 0mq contains a pipe that the # background IO threads use to communicate with the socket. These # events are important because they tell the socket when it is able to diff --git a/eventlet/greenio/py3.py b/eventlet/greenio/py3.py index fc6c67f..5762d6d 100644 --- a/eventlet/greenio/py3.py +++ b/eventlet/greenio/py3.py @@ -214,4 +214,5 @@ def GreenPipe(name, mode="r", buffering=-1, encoding=None, errors=None, return _open(name, mode, buffering, encoding, errors, newline, closefd, opener) + GreenPipe.__doc__ = greenpipe_doc diff --git a/eventlet/greenthread.py b/eventlet/greenthread.py index c26d5a1..28f0a57 100644 --- a/eventlet/greenthread.py +++ b/eventlet/greenthread.py @@ -145,6 +145,7 @@ def exc_after(seconds, *throw_args): hub = hubs.get_hub() return hub.schedule_call_local(seconds, getcurrent().throw, *throw_args) + # deprecate, remove TimeoutError, with_timeout = ( support.wrap_deprecated(old, new)(fun) for old, new, fun in ( diff --git a/eventlet/patcher.py b/eventlet/patcher.py index b249d6f..9c6727d 100644 --- a/eventlet/patcher.py +++ b/eventlet/patcher.py @@ -222,6 +222,7 @@ def original(modname): return sys.modules[original_name] + already_patched = {} diff --git a/eventlet/support/greendns.py b/eventlet/support/greendns.py index 6b5a6cb..658bb9c 100644 --- a/eventlet/support/greendns.py +++ b/eventlet/support/greendns.py @@ -924,6 +924,7 @@ def tcp(q, where, timeout=DNS_QUERY_TIMEOUT, port=53, def reset(): resolver.clear() + # Install our coro-friendly replacements for the tcp and udp query methods. dns.query.tcp = tcp dns.query.udp = udp diff --git a/tests/greenpool_test.py b/tests/greenpool_test.py index c5e6fad..6a5bc69 100644 --- a/tests/greenpool_test.py +++ b/tests/greenpool_test.py @@ -386,6 +386,7 @@ def test_greenpool_type_check(): class StressException(Exception): pass + r = random.Random(0) diff --git a/tests/isolated/hub_use_hub_class.py b/tests/isolated/hub_use_hub_class.py index 9f7f308..c7b3782 100644 --- a/tests/isolated/hub_use_hub_class.py +++ b/tests/isolated/hub_use_hub_class.py @@ -5,6 +5,7 @@ __test__ = False class Foo(object): pass + if __name__ == '__main__': import eventlet.hubs eventlet.hubs.use_hub(Foo) diff --git a/tests/isolated/wsgi_connection_timeout.py b/tests/isolated/wsgi_connection_timeout.py index 10e88b8..80b5242 100644 --- a/tests/isolated/wsgi_connection_timeout.py +++ b/tests/isolated/wsgi_connection_timeout.py @@ -188,5 +188,6 @@ def main(): assert "Traceback" not in output_normal, repr(output_normal) print("pass") + if __name__ == '__main__': main() diff --git a/tests/manual/websocket-gunicorn.py b/tests/manual/websocket-gunicorn.py index 88b823a..31ffd97 100644 --- a/tests/manual/websocket-gunicorn.py +++ b/tests/manual/websocket-gunicorn.py @@ -42,6 +42,7 @@ def app(environ, start_response): ) return [body] + if __name__ == '__main__': cmd = 'gunicorn websocket-gunicorn:app -b 127.0.0.1:5001 -k eventlet -w 1' sys.stderr.write('exec ' + cmd + '\n') diff --git a/tests/parse_results.py b/tests/parse_results.py index 18bd5e3..1761327 100644 --- a/tests/parse_results.py +++ b/tests/parse_results.py @@ -31,6 +31,7 @@ def parse_stdout(s): hub += '/%s' % reactor return testname, hub + unittest_delim = '----------------------------------------------------------------------' @@ -102,6 +103,7 @@ def main(db): (id, testname, hub, runs, errors, fails, timeouts)) c.commit() + if __name__ == '__main__': if not sys.argv[1:]: latest_db = sorted(glob.glob('results.*.db'), key=lambda f: os.stat(f).st_mtime)[-1] diff --git a/tests/pools_test.py b/tests/pools_test.py index 3efca3e..32e971e 100644 --- a/tests/pools_test.py +++ b/tests/pools_test.py @@ -248,5 +248,6 @@ SOMETIMES = RuntimeError('I fail half the time') class TestTookTooLong(Exception): pass + if __name__ == '__main__': main() diff --git a/tests/stdlib/all.py b/tests/stdlib/all.py index 3d05d1e..a4ddfd2 100644 --- a/tests/stdlib/all.py +++ b/tests/stdlib/all.py @@ -45,6 +45,7 @@ def assimilate_patched(name): except AttributeError: print("No test_main for %s, assuming it tests on import" % name) + import all_modules for m in all_modules.get_modules(): diff --git a/tests/stdlib/all_monkey.py b/tests/stdlib/all_monkey.py index 903b9f3..f6e901c 100644 --- a/tests/stdlib/all_monkey.py +++ b/tests/stdlib/all_monkey.py @@ -19,6 +19,7 @@ def assimilate_real(name): except AttributeError: print("No test_main for %s, assuming it tests on import" % name) + import all_modules for m in all_modules.get_modules(): diff --git a/tests/stdlib/test_asyncore.py b/tests/stdlib/test_asyncore.py index ea889aa..85b4006 100644 --- a/tests/stdlib/test_asyncore.py +++ b/tests/stdlib/test_asyncore.py @@ -40,6 +40,7 @@ def new_closeall_check(self, usedefault): for c in l: self.assertEqual(c.socket.closed, True) + HelperFunctionTests.closeall_check = new_closeall_check try: diff --git a/tests/stdlib/test_socket_ssl.py b/tests/stdlib/test_socket_ssl.py index acee557..3d9c076 100644 --- a/tests/stdlib/test_socket_ssl.py +++ b/tests/stdlib/test_socket_ssl.py @@ -13,6 +13,8 @@ def is_resource_enabled(resource): return True else: return i_r_e(resource) + + test.test_support.is_resource_enabled = is_resource_enabled try: diff --git a/tests/stdlib/test_ssl.py b/tests/stdlib/test_ssl.py index 5721a17..44cf62f 100644 --- a/tests/stdlib/test_ssl.py +++ b/tests/stdlib/test_ssl.py @@ -19,6 +19,8 @@ def is_resource_enabled(resource): return True else: return i_r_e(resource) + + test.test_support.is_resource_enabled = is_resource_enabled patcher.inject( diff --git a/tests/stdlib/test_thread__boundedsem.py b/tests/stdlib/test_thread__boundedsem.py index 9e99dc4..3fc4ee6 100644 --- a/tests/stdlib/test_thread__boundedsem.py +++ b/tests/stdlib/test_thread__boundedsem.py @@ -6,6 +6,7 @@ from eventlet.green import thread def allocate_lock(): return semaphore.Semaphore(1, 9999) + original_allocate_lock = thread.allocate_lock thread.allocate_lock = allocate_lock original_LockType = thread.LockType diff --git a/tests/websocket_test.py b/tests/websocket_test.py index 61ba3dc..666d642 100644 --- a/tests/websocket_test.py +++ b/tests/websocket_test.py @@ -32,6 +32,7 @@ def handle(ws): else: ws.close() + wsapp = WebSocketWSGI(handle) @@ -5,10 +5,10 @@ exclude = *.egg*,.env,.git,.hg,.tox,_*,build*,dist*,venv*,mock.py,eventlet/green ignore = E261,E402,E731,W503 max-line-length = 123 -[pep8] +[pycodestyle] count = 1 exclude = *.egg*,.env,.git,.hg,.tox,_*,build*,dist*,venv*,mock.py,eventlet/green/http/* -ignore = E261,E402,E731,W503 +ignore = E261,E402,E731,E741,W503 max-line-length = 123 show-source = 1 statistics = 1 @@ -35,14 +35,14 @@ commands = coverage xml -i [testenv:pep8] -basepython = python2.7 +basepython = python3 setenv = {[testenv]setenv} deps = - pep8==1.7.1 + pycodestyle==2.1.0 usedevelop = False commands = - pep8 benchmarks/ eventlet/ tests/ + pycodestyle benchmarks/ eventlet/ tests/ [testenv] passenv = @@ -62,7 +62,7 @@ deps = py27: subprocess32==3.2.7 py38-openssl: pyopenssl==20.0.0 pypy{2,3}: psycopg2cffi-compat==1.1 - py{27,35,36,37}: psycopg2-binary==2.7.4 + py{27,35,36,37}: psycopg2-binary==2.7.7 py{35,36,37,38,39}: mysqlclient==2.0.3 py{38,39}: psycopg2-binary==2.8.4 setuptools==38.5.1 @@ -70,5 +70,6 @@ deps = dnspython1: dnspython<2 usedevelop = True commands = + pip install -e . nosetests --verbose {env:tox_cover_args} {posargs:tests/} coverage xml -i |