Skip to content

Commit 2594062

Browse files
fix: Python upgrade readiness changes
1 parent f3a0535 commit 2594062

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

lib_files/typing_extensions.py renamed to lib_files/cus_typing_extensions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ def __new__(cls, name, bases, ns, *, total=True, closed=False):
984984
if "__annotations__" in ns:
985985
own_annotations = ns["__annotations__"]
986986
elif "__annotate__" in ns:
987-
# TODO: Use inspect.VALUE here, and make the annotations lazily evaluated
987+
# TODO: Use inspect.VALUE here, and make the annotations lazily evaluated # noqa
988988
own_annotations = ns["__annotate__"](1)
989989
else:
990990
own_annotations = {}
@@ -1729,7 +1729,7 @@ def _paramspec_prepare_subst(alias, args):
17291729
args = [*args, paramspec.__default__]
17301730
if i >= len(args):
17311731
raise TypeError(f"Too few arguments for {alias}")
1732-
# Special case where Z[[int, str, bool]] == Z[int, str, bool] in PEP 612.
1732+
# Special case where Z[[int, str, bool]] == Z[int, str, bool] in PEP 612. # noqa
17331733
if len(params) == 1 and not typing._is_param_expr(args[0]):
17341734
assert i == 0
17351735
args = (args,)
@@ -1916,7 +1916,7 @@ def _concatenate_getitem(self, parameters):
19161916
# 3.10+
19171917
if hasattr(typing, "Concatenate"):
19181918
Concatenate = typing.Concatenate
1919-
_ConcatenateGenericAlias = typing._ConcatenateGenericAlias
1919+
_ConcatenateGenericAlias = typing._ConcatenateGenericAlias # noqa
19201920
# 3.9
19211921
elif sys.version_info[:2] >= (3, 9):
19221922

@@ -3296,7 +3296,7 @@ def __new__(cls, typename, bases, ns):
32963296
if "__annotations__" in ns:
32973297
types = ns["__annotations__"]
32983298
elif "__annotate__" in ns:
3299-
# TODO: Use inspect.VALUE here, and make the annotations lazily evaluated
3299+
# TODO: Use inspect.VALUE here, and make the annotations lazily evaluated # noqa
33003300
types = ns["__annotate__"](1)
33013301
else:
33023302
types = {}
@@ -3326,7 +3326,7 @@ def __new__(cls, typename, bases, ns):
33263326
else:
33273327
class_getitem = typing.Generic.__class_getitem__.__func__
33283328
nm_tpl.__class_getitem__ = classmethod(class_getitem)
3329-
# update from user namespace without overriding special namedtuple attributes
3329+
# update from user namespace without overriding special namedtuple attributes # noqa
33303330
for key, val in list(ns.items()):
33313331
if key in _prohibited_namedtuple_fields:
33323332
raise AttributeError("Cannot overwrite NamedTuple attribute " + key)
@@ -3475,7 +3475,7 @@ class Buffer(abc.ABC): # noqa: B024
34753475
else:
34763476

34773477
def get_original_bases(cls, /):
3478-
"""Return the class's "original" bases prior to modification by `__mro_entries__`.
3478+
"""Return the class's "original" bases prior to modification by `__mro_entries__`. # noqa
34793479
34803480
Examples::
34813481

lib_files/socks.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
if os.name == "nt" and sys.version_info < (3, 0):
2525
try:
26-
import win_inet_pton
26+
import win_inet_pton # noqa
2727
except ImportError:
2828
raise ImportError("To run PySocks on Windows you must install win_inet_pton")
2929

@@ -50,7 +50,7 @@ def wrapper(*args, **kwargs):
5050
if _is_blocking == 0:
5151
self.setblocking(True)
5252
return function(*args, **kwargs)
53-
except Exception as e:
53+
except Exception as e: # noqa
5454
raise
5555
finally:
5656
# set orgin blocking
@@ -248,12 +248,12 @@ class _BaseSocket(socket.socket):
248248
def __init__(self, *pos, **kw):
249249
_orig_socket.__init__(self, *pos, **kw)
250250

251-
self._savedmethods = dict()
251+
self._savedmethods = dict() # noqa
252252
for name in self._savenames:
253253
self._savedmethods[name] = getattr(self, name)
254254
delattr(self, name) # Allows normal overriding mechanism to work
255255

256-
_savenames = list()
256+
_savenames = list() # noqa
257257

258258

259259
def _makemethod(name):
@@ -318,7 +318,7 @@ def settimeout(self, timeout):
318318
self._timeout = timeout
319319
try:
320320
# test if we're connected, if so apply timeout
321-
peer = self.get_proxy_peername()
321+
peer = self.get_proxy_peername() # noqa
322322
super(socksocket, self).settimeout(self._timeout)
323323
except socket.error:
324324
pass
@@ -847,11 +847,11 @@ def connect(self, dest_pair, catch_errors=None):
847847
self.close()
848848
if not catch_errors:
849849
proxy_addr, proxy_port = proxy_addr
850-
proxy_server = "{}:{}".format(proxy_addr, proxy_port)
850+
proxy_server = "{}:{}".format(proxy_addr, proxy_port) # noqa
851851
printable_type = PRINTABLE_PROXY_TYPES[proxy_type]
852852

853-
msg = "Error connecting to {} proxy {}".format(
854-
printable_type, proxy_server
853+
msg = "Error connecting to {} proxy at address {}:{}".format(
854+
printable_type, proxy_addr, proxy_port
855855
)
856856
log.debug("%s due to: %s", msg, error)
857857
raise ProxyConnectionError(msg, error)
@@ -879,14 +879,14 @@ def connect(self, dest_pair, catch_errors=None):
879879
@set_self_blocking
880880
def connect_ex(self, dest_pair):
881881
"""https://docs.python.org/3/library/socket.html#socket.socket.connect_ex
882-
Like connect(address), but return an error indicator instead of raising an exception for errors returned by the C-level connect() call (other problems, such as "host not found" can still raise exceptions).
882+
Like connect(address), but return an error indicator instead of raising an exception for errors returned by the C-level connect() call (other problems, such as "host not found" can still raise exceptions). # noqa
883883
"""
884884
try:
885885
self.connect(dest_pair, catch_errors=True)
886886
return 0
887887
except OSError as e:
888888
# If the error is numeric (socket errors are numeric), then return number as
889-
# connect_ex expects. Otherwise raise the error again (socket timeout for example)
889+
# connect_ex expects. Otherwise raise the error again (socket timeout for example) # noqa
890890
if e.errno:
891891
return e.errno
892892
else:

lib_files/sockshandler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
version: 0.3
77
88
9-
This module provides a Handler which you can use with urllib2 to allow it to tunnel your connection through a socks.sockssocket socket, with out monkey patching the original socket...
9+
This module provides a Handler which you can use with urllib2 to allow it to tunnel your connection through a socks.sockssocket socket, with out monkey patching the original socket... # noqa
1010
"""
1111
from __future__ import print_function
1212

@@ -19,7 +19,7 @@
1919
import six.moves.urllib.parse
2020
import six.moves.urllib.request
2121
except ImportError: # Python 3
22-
import urllib.request as urllib2
22+
import urllib.request as urllib2 # noqa
2323
import http.client as httplib
2424

2525
import socks # $ pip install PySocks
@@ -39,7 +39,7 @@ def is_ip(s):
3939
socket.inet_aton(s)
4040
else:
4141
return False
42-
except:
42+
except: # noqa
4343
return False
4444
else:
4545
return True

scripts/pack.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ echo "Generate package - ${version}" && \
6262
ucc-gen --source "${input}" --ta-version "${version}" && \
6363
jq '.' globalConfig.json > globalConfig.new.json && \
6464
mv globalConfig.new.json globalConfig.json && \
65-
cp -f "lib_files/typing_extensions.py" "$output/TA_dataset/lib/typing_extensions.py" && \
65+
echo "Updating typing_extensions.py, socks.py and sockshandler.py in lib of output"
66+
cp -f "lib_files/cus_typing_extensions.py" "$output/TA_dataset/lib/typing_extensions.py" && \
6667
cp -f "lib_files/socks.py" "$output/TA_dataset/lib/socks.py" && \
6768
cp -f "lib_files/sockshandler.py" "$output/TA_dataset/lib/sockshandler.py" && \
6869
echo "Construct tarball" && \

0 commit comments

Comments
 (0)