Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c94024

Browse files
committed
Issue #10899: No function type annotations in the standard library.
Removed function type annotations from _pyio.py.
1 parent 1e28513 commit 3c94024

2 files changed

Lines changed: 34 additions & 31 deletions

File tree

Lib/_pyio.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ def __init__(self, errno, strerror, characters_written=0):
3434
self.characters_written = characters_written
3535

3636

37-
def open(file: (str, bytes), mode: str = "r", buffering: int = -1,
38-
encoding: str = None, errors: str = None,
39-
newline: str = None, closefd: bool = True) -> "IOBase":
37+
def open(file, mode = "r", buffering = -1,
38+
encoding = None, errors = None,
39+
newline = None, closefd = True):
4040

4141
r"""Open file and return a stream. Raise IOError upon failure.
4242
@@ -287,14 +287,14 @@ class IOBase(metaclass=abc.ABCMeta):
287287

288288
### Internal ###
289289

290-
def _unsupported(self, name: str) -> IOError:
290+
def _unsupported(self, name):
291291
"""Internal: raise an exception for unsupported operations."""
292292
raise UnsupportedOperation("%s.%s() not supported" %
293293
(self.__class__.__name__, name))
294294

295295
### Positioning ###
296296

297-
def seek(self, pos: int, whence: int = 0) -> int:
297+
def seek(self, pos, whence = 0):
298298
"""Change stream position.
299299
300300
Change the stream position to byte offset offset. offset is
@@ -309,11 +309,11 @@ def seek(self, pos: int, whence: int = 0) -> int:
309309
"""
310310
self._unsupported("seek")
311311

312-
def tell(self) -> int:
312+
def tell(self):
313313
"""Return current stream position."""
314314
return self.seek(0, 1)
315315

316-
def truncate(self, pos: int = None) -> int:
316+
def truncate(self, pos = None):
317317
"""Truncate file to size bytes.
318318
319319
Size defaults to the current IO position as reported by tell(). Return
@@ -323,7 +323,7 @@ def truncate(self, pos: int = None) -> int:
323323

324324
### Flush and close ###
325325

326-
def flush(self) -> None:
326+
def flush(self):
327327
"""Flush write buffers, if applicable.
328328
329329
This is not implemented for read-only and non-blocking streams.
@@ -333,7 +333,7 @@ def flush(self) -> None:
333333

334334
__closed = False
335335

336-
def close(self) -> None:
336+
def close(self):
337337
"""Flush and close the IO object.
338338
339339
This method has no effect if the file is already closed.
@@ -342,7 +342,7 @@ def close(self) -> None:
342342
self.flush()
343343
self.__closed = True
344344

345-
def __del__(self) -> None:
345+
def __del__(self):
346346
"""Destructor. Calls close()."""
347347
# The try/except block is in case this is called at program
348348
# exit time, when it's possible that globals have already been
@@ -356,7 +356,7 @@ def __del__(self) -> None:
356356

357357
### Inquiries ###
358358

359-
def seekable(self) -> bool:
359+
def seekable(self):
360360
"""Return whether object supports random access.
361361
362362
If False, seek(), tell() and truncate() will raise UnsupportedOperation.
@@ -371,7 +371,7 @@ def _checkSeekable(self, msg=None):
371371
raise UnsupportedOperation("File or stream is not seekable."
372372
if msg is None else msg)
373373

374-
def readable(self) -> bool:
374+
def readable(self):
375375
"""Return whether object was opened for reading.
376376
377377
If False, read() will raise UnsupportedOperation.
@@ -385,7 +385,7 @@ def _checkReadable(self, msg=None):
385385
raise UnsupportedOperation("File or stream is not readable."
386386
if msg is None else msg)
387387

388-
def writable(self) -> bool:
388+
def writable(self):
389389
"""Return whether object was opened for writing.
390390
391391
If False, write() and truncate() will raise UnsupportedOperation.
@@ -416,27 +416,27 @@ def _checkClosed(self, msg=None):
416416

417417
### Context manager ###
418418

419-
def __enter__(self) -> "IOBase": # That's a forward reference
419+
def __enter__(self): # That's a forward reference
420420
"""Context management protocol. Returns self."""
421421
self._checkClosed()
422422
return self
423423

424-
def __exit__(self, *args) -> None:
424+
def __exit__(self, *args):
425425
"""Context management protocol. Calls close()"""
426426
self.close()
427427

428428
### Lower-level APIs ###
429429

430430
# XXX Should these be present even if unimplemented?
431431

432-
def fileno(self) -> int:
432+
def fileno(self):
433433
"""Returns underlying file descriptor if one exists.
434434
435435
An IOError is raised if the IO object does not use a file descriptor.
436436
"""
437437
self._unsupported("fileno")
438438

439-
def isatty(self) -> bool:
439+
def isatty(self):
440440
"""Return whether this is an 'interactive' stream.
441441
442442
Return False if it can't be determined.
@@ -446,7 +446,7 @@ def isatty(self) -> bool:
446446

447447
### Readline[s] and writelines ###
448448

449-
def readline(self, limit: int = -1) -> bytes:
449+
def readline(self, limit = -1):
450450
r"""Read and return a line from the stream.
451451
452452
If limit is specified, at most limit bytes will be read.
@@ -532,7 +532,7 @@ class RawIOBase(IOBase):
532532
# primitive operation, but that would lead to nasty recursion in case
533533
# a subclass doesn't implement either.)
534534

535-
def read(self, n: int = -1) -> bytes:
535+
def read(self, n = -1):
536536
"""Read and return up to n bytes.
537537
538538
Returns an empty bytes object on EOF, or None if the object is
@@ -559,15 +559,15 @@ def readall(self):
559559
res += data
560560
return bytes(res)
561561

562-
def readinto(self, b: bytearray) -> int:
562+
def readinto(self, b):
563563
"""Read up to len(b) bytes into b.
564564
565565
Returns number of bytes read (0 for EOF), or None if the object
566566
is set not to block and has no data to read.
567567
"""
568568
self._unsupported("readinto")
569569

570-
def write(self, b: bytes) -> int:
570+
def write(self, b):
571571
"""Write the given buffer to the IO stream.
572572
573573
Returns the number of bytes written, which may be less than len(b).
@@ -596,7 +596,7 @@ class BufferedIOBase(IOBase):
596596
implementation, but wrap one.
597597
"""
598598

599-
def read(self, n: int = None) -> bytes:
599+
def read(self, n = None):
600600
"""Read and return up to n bytes.
601601
602602
If the argument is omitted, None, or negative, reads and
@@ -616,11 +616,11 @@ def read(self, n: int = None) -> bytes:
616616
"""
617617
self._unsupported("read")
618618

619-
def read1(self, n: int=None) -> bytes:
619+
def read1(self, n = None):
620620
"""Read up to n bytes with at most one read() system call."""
621621
self._unsupported("read1")
622622

623-
def readinto(self, b: bytearray) -> int:
623+
def readinto(self, b):
624624
"""Read up to len(b) bytes into b.
625625
626626
Like read(), this may issue multiple reads to the underlying raw
@@ -643,7 +643,7 @@ def readinto(self, b: bytearray) -> int:
643643
b[:n] = array.array('b', data)
644644
return n
645645

646-
def write(self, b: bytes) -> int:
646+
def write(self, b):
647647
"""Write the given buffer to the IO stream.
648648
649649
Return the number of bytes written, which is never less than
@@ -654,7 +654,7 @@ def write(self, b: bytes) -> int:
654654
"""
655655
self._unsupported("write")
656656

657-
def detach(self) -> None:
657+
def detach(self):
658658
"""
659659
Separate the underlying raw stream from the buffer and return it.
660660
@@ -1272,30 +1272,30 @@ class TextIOBase(IOBase):
12721272
are immutable. There is no public constructor.
12731273
"""
12741274

1275-
def read(self, n: int = -1) -> str:
1275+
def read(self, n = -1):
12761276
"""Read at most n characters from stream.
12771277
12781278
Read from underlying buffer until we have n characters or we hit EOF.
12791279
If n is negative or omitted, read until EOF.
12801280
"""
12811281
self._unsupported("read")
12821282

1283-
def write(self, s: str) -> int:
1283+
def write(self, s):
12841284
"""Write string s to stream."""
12851285
self._unsupported("write")
12861286

1287-
def truncate(self, pos: int = None) -> int:
1287+
def truncate(self, pos = None):
12881288
"""Truncate size to pos."""
12891289
self._unsupported("truncate")
12901290

1291-
def readline(self) -> str:
1291+
def readline(self):
12921292
"""Read until newline or EOF.
12931293
12941294
Returns an empty string if EOF is hit immediately.
12951295
"""
12961296
self._unsupported("readline")
12971297

1298-
def detach(self) -> None:
1298+
def detach(self):
12991299
"""
13001300
Separate the underlying buffer from the TextIOBase and return it.
13011301

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Core and Builtins
4343
Library
4444
-------
4545

46+
- Issue #10899: No function type annotations in the standard library.
47+
Removed function type annotations from _pyio.py.
48+
4649
- Issue #10875: Update Regular Expression HOWTO; patch by 'SilentGhost'.
4750

4851
- Issue #10872: The repr() of TextIOWrapper objects now includes the mode

0 commit comments

Comments
 (0)