Skip to content

typing.py has an incorrect definition of closed #83674

Closed

Description

@hauntsaninja
BPO 39493
Nosy @gvanrossum, @miss-islington, @hauntsaninja
PRs
  • bpo-39493: Fix definition of IO.closed in typing.py #18265
  • [3.7] bpo-39493: Fix definition of IO.closed in typing.py (GH-18265) #18273
  • [3.8] bpo-39493: Fix definition of IO.closed in typing.py (GH-18265) #18274
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-01-30.06:00:37.441>
    created_at = <Date 2020-01-30.00:37:07.981>
    labels = ['3.8']
    title = 'typing.py has an incorrect definition of closed'
    updated_at = <Date 2020-01-30.06:00:37.440>
    user = 'https://github.com/hauntsaninja'

    bugs.python.org fields:

    activity = <Date 2020-01-30.06:00:37.440>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-30.06:00:37.441>
    closer = 'gvanrossum'
    components = []
    creation = <Date 2020-01-30.00:37:07.981>
    creator = 'hauntsaninja'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39493
    keywords = ['patch']
    message_count = 5.0
    messages = ['360996', '361004', '361010', '361011', '361012']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'miss-islington', 'hauntsaninja']
    pr_nums = ['18265', '18273', '18274']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39493'
    versions = ['Python 3.8']

    Activity

    1. hauntsaninja commented on Jan 30, 2020

      @hauntsaninja
      ContributorAuthor

      Hello!

      typing.py has the following definition of closed:
      https://github.com/python/cpython/blob/master/Lib/typing.py#L1834

          @abstractmethod
          def closed(self) -> bool:
              pass
      

      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.
      https://github.com/python/typeshed/blob/master/stdlib/3/typing.pyi#L459

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

    2. gvanrossum commented on Jan 30, 2020

      @gvanrossum
      Member

      New changeset 2e6569b by Shantanu in branch 'master':
      bpo-39493: Fix definition of IO.closed in typing.py (bpo-18265)
      2e6569b

    3. miss-islington commented on Jan 30, 2020

      @miss-islington
      Contributor

      New changeset 58076df by Miss Islington (bot) in branch '3.8':
      bpo-39493: Fix definition of IO.closed in typing.py (GH-18265)
      58076df

    4. gvanrossum commented on Jan 30, 2020

      @gvanrossum
      Member

      New changeset 194c7ae by Miss Islington (bot) in branch '3.7':
      [3.7] bpo-39493: Fix definition of IO.closed in typing.py (GH-18273)
      194c7ae

    5. gvanrossum commented on Jan 30, 2020

      @gvanrossum
      Member

      Thanks, Shantanu!

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions