diff options
author | engn33r <engn33r@users.noreply.github.com> | 2022-02-25 16:34:15 -0500 |
---|---|---|
committer | engn33r <engn33r@users.noreply.github.com> | 2022-02-25 16:34:15 -0500 |
commit | dca4022abe1b229dd0f67dbce2fee6001aa1cdc6 (patch) | |
tree | 1fb1f96c357eb5a7ea4a0e5f2edd1e64b55534b0 | |
parent | db1f2cca25d9ca5c91ad678d04bada730a77ecdf (diff) | |
download | websocket-client-dca4022abe1b229dd0f67dbce2fee6001aa1cdc6.tar.gz |
Linting improvements, improved flake8 linting CI cmd
-rw-r--r-- | .github/workflows/lint.yml | 2 | ||||
-rw-r--r-- | compliance/test_fuzzingclient.py | 10 | ||||
-rw-r--r-- | examples/rel_client.py | 5 | ||||
-rw-r--r-- | setup.py | 10 | ||||
-rw-r--r-- | websocket/_abnf.py | 17 | ||||
-rw-r--r-- | websocket/_app.py | 22 | ||||
-rw-r--r-- | websocket/_cookiejar.py | 5 | ||||
-rw-r--r-- | websocket/_core.py | 33 | ||||
-rw-r--r-- | websocket/_exceptions.py | 4 | ||||
-rw-r--r-- | websocket/_logging.py | 5 | ||||
-rw-r--r-- | websocket/_socket.py | 15 | ||||
-rw-r--r-- | websocket/_url.py | 14 | ||||
-rw-r--r-- | websocket/tests/test_abnf.py | 8 | ||||
-rw-r--r-- | websocket/tests/test_app.py | 14 | ||||
-rw-r--r-- | websocket/tests/test_cookiejar.py | 7 | ||||
-rw-r--r-- | websocket/tests/test_http.py | 18 | ||||
-rw-r--r-- | websocket/tests/test_url.py | 8 | ||||
-rw-r--r-- | websocket/tests/test_websocket.py | 25 |
18 files changed, 89 insertions, 133 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 598dc0f..12b6856 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: run: | pip3 install flake8 flake8 --version - flake8 . --builtins=FileNotFoundError --count --select=E11,E12,E22,E25,E26,E3,E71,F63,F7,F82,F84,W3,W503 --show-source --statistics + flake8 . --show-source --statistics --count --ignore E231,E241,E501,E722,E741,F401,F403,F405,W504 - name: Perform optional exit-zero flake8 linting run: | diff --git a/compliance/test_fuzzingclient.py b/compliance/test_fuzzingclient.py index 30f1dde..48db6e1 100644 --- a/compliance/test_fuzzingclient.py +++ b/compliance/test_fuzzingclient.py @@ -1,6 +1,6 @@ -""" - -""" +import json +import traceback +import websocket """ test_fuzzingclient.py @@ -20,10 +20,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import json -import traceback - -import websocket SERVER = 'ws://127.0.0.1:8642' AGENT = 'py-websockets-client' diff --git a/examples/rel_client.py b/examples/rel_client.py index 7d7a641..86562b6 100644 --- a/examples/rel_client.py +++ b/examples/rel_client.py @@ -1,11 +1,12 @@ -import websocket, rel +import websocket +import rel addr = "wss://api.gemini.com/v1/marketdata/%s" if __name__ == "__main__": rel.safe_read() for symbol in ["BTCUSD", "ETHUSD", "ETHBTC"]: - ws = websocket.WebSocketApp(addr % (symbol,), on_message=lambda w, m : print(m)) + ws = websocket.WebSocketApp(addr % (symbol,), on_message=lambda w, m: print(m)) ws.run_forever(dispatcher=rel) rel.signal(2, rel.abort) # Keyboard Interrupt rel.dispatch() @@ -1,6 +1,6 @@ -""" - -""" +import sys +import pkg_resources +from setuptools import setup, find_packages """ setup.py @@ -20,10 +20,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import sys - -from setuptools import setup, find_packages -import pkg_resources VERSION = "1.3.1" diff --git a/websocket/_abnf.py b/websocket/_abnf.py index 025a8ee..e69dffc 100644 --- a/websocket/_abnf.py +++ b/websocket/_abnf.py @@ -1,6 +1,11 @@ -""" +import array +import os +import struct +import sys -""" +from ._exceptions import * +from ._utils import validate_utf8 +from threading import Lock """ _abnf.py @@ -20,14 +25,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import array -import os -import struct -import sys - -from ._exceptions import * -from ._utils import validate_utf8 -from threading import Lock try: # If wsaccel is available, use compiled routines to mask data. diff --git a/websocket/_app.py b/websocket/_app.py index 877ab6d..d64bd4d 100644 --- a/websocket/_app.py +++ b/websocket/_app.py @@ -1,6 +1,12 @@ -""" - -""" +import selectors +import sys +import threading +import time +import traceback +from ._abnf import ABNF +from ._core import WebSocket, getdefaulttimeout +from ._exceptions import * +from . import _logging """ _app.py @@ -20,16 +26,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import selectors -import sys -import threading -import time -import traceback -from ._abnf import ABNF -from ._core import WebSocket, getdefaulttimeout -from ._exceptions import * -from . import _logging - __all__ = ["WebSocketApp"] diff --git a/websocket/_cookiejar.py b/websocket/_cookiejar.py index ea98e1f..5476d1d 100644 --- a/websocket/_cookiejar.py +++ b/websocket/_cookiejar.py @@ -1,6 +1,4 @@ -""" - -""" +import http.cookies """ _cookiejar.py @@ -20,7 +18,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import http.cookies class SimpleCookieJar: diff --git a/websocket/_core.py b/websocket/_core.py index a2a85e5..c36b780 100644 --- a/websocket/_core.py +++ b/websocket/_core.py @@ -1,8 +1,17 @@ -""" -_core.py -==================================== -WebSocket Python client -""" +import socket +import struct +import threading +import time + +# websocket modules +from ._abnf import * +from ._exceptions import * +from ._handshake import * +from ._http import * +from ._logging import * +from ._socket import * +from ._ssl_compat import * +from ._utils import * """ _core.py @@ -22,20 +31,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import socket -import struct -import threading -import time - -# websocket modules -from ._abnf import * -from ._exceptions import * -from ._handshake import * -from ._http import * -from ._logging import * -from ._socket import * -from ._ssl_compat import * -from ._utils import * __all__ = ['WebSocket', 'create_connection'] diff --git a/websocket/_exceptions.py b/websocket/_exceptions.py index 1ce3069..811d594 100644 --- a/websocket/_exceptions.py +++ b/websocket/_exceptions.py @@ -1,8 +1,4 @@ """ -Define WebSocket exceptions -""" - -""" _exceptions.py websocket - WebSocket client library for Python diff --git a/websocket/_logging.py b/websocket/_logging.py index 4d440c9..df690dc 100644 --- a/websocket/_logging.py +++ b/websocket/_logging.py @@ -1,6 +1,4 @@ -""" - -""" +import logging """ _logging.py @@ -20,7 +18,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import logging _logger = logging.getLogger('websocket') try: diff --git a/websocket/_socket.py b/websocket/_socket.py index d296361..54e6399 100644 --- a/websocket/_socket.py +++ b/websocket/_socket.py @@ -1,6 +1,10 @@ -""" +import errno +import selectors +import socket -""" +from ._exceptions import * +from ._ssl_compat import * +from ._utils import * """ _socket.py @@ -20,13 +24,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import errno -import selectors -import socket - -from ._exceptions import * -from ._ssl_compat import * -from ._utils import * DEFAULT_SOCKET_OPTION = [(socket.SOL_TCP, socket.TCP_NODELAY, 1)] if hasattr(socket, "SO_KEEPALIVE"): diff --git a/websocket/_url.py b/websocket/_url.py index 0875242..2d3d265 100644 --- a/websocket/_url.py +++ b/websocket/_url.py @@ -1,6 +1,9 @@ -""" +import os +import socket +import struct + +from urllib.parse import unquote, urlparse -""" """ _url.py websocket - WebSocket client library for Python @@ -20,13 +23,6 @@ See the License for the specific language governing permissions and limitations under the License. """ -import os -import socket -import struct - -from urllib.parse import unquote, urlparse - - __all__ = ["parse_url", "get_proxy_info"] diff --git a/websocket/tests/test_abnf.py b/websocket/tests/test_abnf.py index 3521aea..7c9d89d 100644 --- a/websocket/tests/test_abnf.py +++ b/websocket/tests/test_abnf.py @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- # +import websocket as ws +from websocket._abnf import * +import unittest + """ test_abnf.py websocket - WebSocket client library for Python @@ -19,10 +23,6 @@ See the License for the specific language governing permissions and limitations under the License. """ -import websocket as ws -from websocket._abnf import * -import unittest - class ABNFTest(unittest.TestCase): diff --git a/websocket/tests/test_app.py b/websocket/tests/test_app.py index 94abf0c..ac2a7dd 100644 --- a/websocket/tests/test_app.py +++ b/websocket/tests/test_app.py @@ -1,5 +1,12 @@ # -*- coding: utf-8 -*- # +import os +import os.path +import threading +import websocket as ws +import ssl +import unittest + """ test_app.py websocket - WebSocket client library for Python @@ -19,13 +26,6 @@ See the License for the specific language governing permissions and limitations under the License. """ -import os -import os.path -import threading -import websocket as ws -import ssl -import unittest - # Skip test to access the internet unless TEST_WITH_INTERNET == 1 TEST_WITH_INTERNET = os.environ.get('TEST_WITH_INTERNET', '0') == '1' # Skip tests relying on local websockets server unless LOCAL_WS_SERVER_PORT != -1 diff --git a/websocket/tests/test_cookiejar.py b/websocket/tests/test_cookiejar.py index 93c8ec1..559b2e0 100644 --- a/websocket/tests/test_cookiejar.py +++ b/websocket/tests/test_cookiejar.py @@ -1,6 +1,5 @@ -""" - -""" +import unittest +from websocket._cookiejar import SimpleCookieJar """ test_cookiejar.py @@ -20,8 +19,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import unittest -from websocket._cookiejar import SimpleCookieJar class CookieJarTest(unittest.TestCase): diff --git a/websocket/tests/test_http.py b/websocket/tests/test_http.py index b5b1f13..649e0fe 100644 --- a/websocket/tests/test_http.py +++ b/websocket/tests/test_http.py @@ -1,5 +1,14 @@ # -*- coding: utf-8 -*- # +import os +import os.path +import websocket as ws +from websocket._http import proxy_info, read_headers, _start_proxied_socket, _tunnel, _get_addrinfo_list, connect +import unittest +import ssl +import websocket +import socket + """ test_http.py websocket - WebSocket client library for Python @@ -19,15 +28,6 @@ See the License for the specific language governing permissions and limitations under the License. """ -import os -import os.path -import websocket as ws -from websocket._http import proxy_info, read_headers, _start_proxied_socket, _tunnel, _get_addrinfo_list, connect -import unittest -import ssl -import websocket -import socket - try: from python_socks._errors import ProxyError, ProxyTimeoutError, ProxyConnectionError except: diff --git a/websocket/tests/test_url.py b/websocket/tests/test_url.py index bd6e90a..7e155fd 100644 --- a/websocket/tests/test_url.py +++ b/websocket/tests/test_url.py @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- # +import os +import unittest +from websocket._url import get_proxy_info, parse_url, _is_address_in_network, _is_no_proxy_host + """ test_url.py websocket - WebSocket client library for Python @@ -19,10 +23,6 @@ See the License for the specific language governing permissions and limitations under the License. """ -import os -import unittest -from websocket._url import get_proxy_info, parse_url, _is_address_in_network, _is_no_proxy_host - class UrlTest(unittest.TestCase): diff --git a/websocket/tests/test_websocket.py b/websocket/tests/test_websocket.py index e888811..ae42ab5 100644 --- a/websocket/tests/test_websocket.py +++ b/websocket/tests/test_websocket.py @@ -1,8 +1,15 @@ # -*- coding: utf-8 -*- # -""" - -""" +import os +import os.path +import socket +import websocket as ws +import unittest +from websocket._handshake import _create_sec_websocket_key, \ + _validate as _validate_header +from websocket._http import read_headers +from websocket._utils import validate_utf8 +from base64 import decodebytes as base64decode """ test_websocket.py @@ -23,18 +30,6 @@ See the License for the specific language governing permissions and limitations under the License. """ -import os -import os.path -import socket -import websocket as ws -from websocket._handshake import _create_sec_websocket_key, \ - _validate as _validate_header -from websocket._http import read_headers -from websocket._utils import validate_utf8 -from base64 import decodebytes as base64decode - -import unittest - try: import ssl from ssl import SSLError |