Skip to content

Commit

Permalink
refactor: remove deprecate warning from telnetlib.py
Browse files Browse the repository at this point in the history
and ignore some ruff warnings
  • Loading branch information
hfudev committed Sep 17, 2024
1 parent 6f961f2 commit 2954d13
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@
import selectors
import socket
import sys
import warnings
from time import monotonic as _time

warnings._deprecated(__name__, remove=(3, 13))

__all__ = ["Telnet"]

# Tunable parameters
Expand Down Expand Up @@ -250,7 +247,7 @@ def msg(self, msg, *args):
"""
if self.debuglevel > 0:
print('Telnet(%s,%s):' % (self.host, self.port), end=' ')
print(f'Telnet({self.host},{self.port}):', end=' ')
if args:
print(msg % args)
else:
Expand Down Expand Up @@ -447,7 +444,7 @@ def process_rawq(self):
else:
self.iacseq += c
elif len(self.iacseq) == 1:
# 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]'
# 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]' # noqa: ERA001
if c in (DO, DONT, WILL, WONT):
self.iacseq += c
continue
Expand Down Expand Up @@ -586,7 +583,7 @@ def listener(self):
else:
sys.stdout.flush()

def expect(self, list, timeout=None):
def expect(self, list, timeout=None): # noqa: A002
"""Read until one from a list of a regular expressions matches.
The first argument is a list of regular expressions, either
Expand All @@ -609,11 +606,12 @@ def expect(self, list, timeout=None):
"""
re = None
list = list[:]
list = list[:] # noqa: A001
indices = range(len(list))
for i in indices:
if not hasattr(list[i], "search"):
if not re: import re
if not re:
import re
list[i] = re.compile(list[i])
if timeout is not None:
deadline = _time() + timeout
Expand Down Expand Up @@ -645,7 +643,7 @@ def expect(self, list, timeout=None):
def __enter__(self):
return self

def __exit__(self, type, value, traceback):
def __exit__(self, type, value, traceback): # noqa: A002
self.close()


Expand Down

0 comments on commit 2954d13

Please sign in to comment.