[New-bugs-announce] [issue39493] typing.py has an incorrect definition of closed

Shantanu report at bugs.python.org
Wed Jan 29 19:37:08 EST 2020

New submission from Shantanu <hauntsaninja at gmail.com>:


typing.py has the following definition of `closed`:
    def closed(self) -> bool:

This is inconsistent with the behaviour at runtime:
In [17]: sys.version                                                                                                  
Out[17]: '3.8.1 (default, Jan 23 2020, 23:36:06) \n[Clang 11.0.0 (clang-1100.0.33.17)]'

In [18]: f = open("test", "w")                                                                                        

In [19]: f.closed                                                                                                     
Out[19]: False

It seems like the right thing to do is add an @property, as we do with e.g. `mode` and `name`. I'll submit a PR with this change.

Note typeshed also types this as a property to indicate a read-only attribute.

First time filing a bug on BPO, thanks a lot in advance!

messages: 360996
nosy: hauntsaninja
priority: normal
severity: normal
status: open
title: typing.py has an incorrect definition of closed
versions: Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list