Skip to content

Commit 530f6d4

Browse files
committed
Comment: remove annotations
1 parent d6233e9 commit 530f6d4

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

Lib/email/feedparser.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,30 @@ class BufferedSubFile(object):
5353
simple abstraction -- it parses until EOF closes the current message.
5454
"""
5555
def __init__(self):
56-
self._partial: list[str] = []
57-
self._dangling_partial: bool = False
56+
self._partial = []
57+
self._dangling_partial = False
5858
# A deque of full, pushed lines
59-
self._lines: deque[str] = deque()
59+
self._lines = deque()
6060
# The stack of false-EOF checking predicates.
6161
self._eofstack = []
6262
# A flag indicating whether the file has been closed or not.
63-
self._closed: bool = False
64-
self._dump_destination: deque[str]|None = None
65-
self._dump_result: str|None = None
63+
self._closed = False
64+
self._dump_destination = None
65+
self._dump_result = None
6666

67-
def push_eof_matcher(self, pred) -> None:
67+
def push_eof_matcher(self, pred):
6868
self._eofstack.append(pred)
6969

7070
def pop_eof_matcher(self):
7171
return self._eofstack.pop()
7272

73-
def close(self) -> None:
73+
def close(self):
7474
# Don't forget any trailing partial line.
7575
if self._partial:
7676
self._flush_partial()
7777
self._closed = True
7878

79-
def readline(self) -> str|object:
79+
def readline(self):
8080
if not self._lines:
8181
if self._closed:
8282
return ''
@@ -94,20 +94,20 @@ def readline(self) -> str|object:
9494

9595
return line
9696

97-
def _check_eofstack(self, data, start=0, end=sys.maxsize) -> bool:
97+
def _check_eofstack(self, data, start=0, end=sys.maxsize):
9898
for ateof in reversed(self._eofstack):
9999
if ateof(data, start, end):
100100
# We're at the false EOF.
101101
return True
102102

103103
return False
104104

105-
def unreadline(self, line) -> None:
105+
def unreadline(self, line):
106106
# Let the consumer push a line back into the buffer.
107107
assert line is not NeedMoreData
108108
self._lines.appendleft(line)
109109

110-
def _flush_partial(self) -> None:
110+
def _flush_partial(self):
111111
line = EMPTYSTRING.join(self._partial)
112112
if not line:
113113
pass
@@ -125,7 +125,7 @@ def _flush_partial(self) -> None:
125125
self._partial.clear()
126126
self._dangling_partial = False
127127

128-
def push(self, data) -> None:
128+
def push(self, data):
129129
"""Push some new data into this object."""
130130
if not data:
131131
return
@@ -137,7 +137,7 @@ def push(self, data) -> None:
137137

138138
self._push_data(data)
139139

140-
def _can_dump_data(self, data) -> bool:
140+
def _can_dump_data(self, data):
141141
if self._dump_destination is None:
142142
# We're not dumping data
143143
return False
@@ -170,7 +170,7 @@ def _can_dump_data(self, data) -> bool:
170170
# We're still dumping, but there's a potential boundary marker or EOF or similar issue. Force a proper parse.
171171
return False
172172

173-
def _can_dump_partial(self, line, start: int=0, end: int=sys.maxsize) -> bool:
173+
def _can_dump_partial(self, line, start=0, end=sys.maxsize):
174174
# Very similar to _can_dump_data above, except we can make some additional assumptions for partials/lines.
175175
# This should only ever be checked when we have a new partial line, in which case we have no partial,
176176
# or when checking the partial itself, in which case it'll always be the first part
@@ -207,7 +207,7 @@ def _is_dump_midline(self):
207207
assert self._dump_destination[-1] # Never push empty strings to _dump_destination
208208
return self._dump_destination[-1][-1] not in ('\n', '\r')
209209

210-
def _push_data(self, data) -> None:
210+
def _push_data(self, data):
211211
# Find first newline character in the data
212212
unl_start_index = BufferedSubFile._find_unl(data)
213213
if unl_start_index < 0:
@@ -268,7 +268,7 @@ def _push_data(self, data) -> None:
268268
# unl_start_index is an index which points to the start of the next newline character, if there is one
269269
self._push_data_no_partial(data, data_start_index, unl_start_index)
270270

271-
def _push_data_no_partial(self, data, data_start_index: int, unl_start_index: int) -> None:
271+
def _push_data_no_partial(self, data, data_start_index, unl_start_index):
272272
# _partial is now guaranteed to point to be empty
273273
# data_start_index is an index which points to the start of the next line
274274
# unl_start_index is an index which points to the start of the next newline character, if there is one
@@ -349,14 +349,14 @@ def _push_data_no_partial(self, data, data_start_index: int, unl_start_index: in
349349
if data_start_index < len(data):
350350
self._partial.append(data[data_start_index:])
351351

352-
def pushlines(self, lines) -> None:
352+
def pushlines(self, lines):
353353
# This method is not documented on docs.python.org
354354
self._lines.extend(lines)
355355

356356
def __iter__(self):
357357
return self
358358

359-
def __next__(self) -> str|object:
359+
def __next__(self):
360360
line = self.readline()
361361
if line == '':
362362
raise StopIteration
@@ -394,13 +394,13 @@ def _get_dump(self, start_value:str|None = None):
394394
self._dump_destination = None
395395
self._dump_result = EMPTYSTRING.join(_dump_destination)
396396

397-
def _pop_dump(self) -> str:
397+
def _pop_dump(self):
398398
result = self._dump_result
399399
self._dump_result = None
400400
return result
401401

402402
@staticmethod
403-
def _find_unl(data, start=0) -> int:
403+
def _find_unl(data, start=0):
404404
# Like str.find(), but for universal newlines
405405
# Originally, this iterated over the string, however just calling find() twice is drastically faster
406406
# This could be sped up by replacing with a similar function in C, so we don't pass over the string twice.
@@ -412,7 +412,7 @@ def _find_unl(data, start=0) -> int:
412412
return nl_index if nl_index >= 0 else cr_index
413413

414414
@staticmethod
415-
def _find_unl_end(data, start) -> int:
415+
def _find_unl_end(data, start):
416416
# A helper function which returns the 1-past-the-end index of a universal newline
417417
# This could be sped up by replacing with a similar function in C.
418418
#assert data[start] in '\r\n'
@@ -467,15 +467,15 @@ def __init__(self, _factory=None, *, policy=compat32):
467467
self._headersonly = False
468468

469469
# Non-public interface for supporting Parser's headersonly flag
470-
def _set_headersonly(self) -> None:
470+
def _set_headersonly(self):
471471
self._headersonly = True
472472

473-
def feed(self, data) -> None:
473+
def feed(self, data):
474474
"""Push more data into the parser."""
475475
self._input.push(data)
476476
self._call_parse()
477477

478-
def _call_parse(self) -> None:
478+
def _call_parse(self):
479479
try:
480480
self._parse() # Return value is always NeedMoreData or None, but discarded here in either case
481481
except StopIteration:
@@ -494,7 +494,7 @@ def close(self):
494494
self.policy.handle_defect(root, defect)
495495
return root
496496

497-
def _new_message(self) -> None:
497+
def _new_message(self):
498498
if self._old_style_factory:
499499
msg = self._factory()
500500
else:
@@ -616,7 +616,7 @@ def _parsegen(self): # yields: NeedMoreData
616616
# this onto the input stream until we've scanned past the
617617
# preamble.
618618
separator = '--' + boundary
619-
def boundarymatch(line, pos: int = 0, endpos: int = sys.maxsize):
619+
def boundarymatch(line, pos = 0, endpos = sys.maxsize):
620620
if not line.startswith(separator, pos, endpos):
621621
return None
622622
return boundaryendRE.match(line, pos + len(separator), endpos)
@@ -749,7 +749,7 @@ def boundarymatch(line, pos: int = 0, endpos: int = sys.maxsize):
749749
yield from self._input._get_dump()
750750
self._cur.set_payload(self._input._pop_dump())
751751

752-
def _parse_headers(self, lines) -> None:
752+
def _parse_headers(self, lines):
753753
# Passed a list of lines that make up the headers for the current msg
754754
lastheader = ''
755755
lastvalue = []
@@ -813,5 +813,5 @@ def _parse_headers(self, lines) -> None:
813813
class BytesFeedParser(FeedParser):
814814
"""Like FeedParser, but feed accepts bytes."""
815815

816-
def feed(self, data) -> None:
816+
def feed(self, data):
817817
super().feed(data.decode('ascii', 'surrogateescape'))

0 commit comments

Comments
 (0)