Skip to content

Fix namedtuple discrepancies #2090

Closed
Closed

Description

@elazarg

Activity

  1. dlinnemeyer commented on Sep 22, 2016

    @dlinnemeyer

    I'm working on trying out NamedTuple from typing with mypy, and I ran into an error claiming my tuple has no attribute "_replace" when I try to call _replace.

    Is this what you're talking about here, or am I running into a different problem?

  2. elazarg commented on Sep 22, 2016

    @elazarg
    ContributorAuthor

    What version of mypy do you use? This sounds like an old bug that should have been fixed. Can you post an example code?

  3. dlinnemeyer commented on Sep 22, 2016

    @dlinnemeyer

    0.4.4. I'll work on some example code quickly.

  4. dlinnemeyer commented on Sep 22, 2016

    @dlinnemeyer
    from typing import NamedTuple
    
    Foo = NamedTuple('Foo', [
        ('x', int),
        ('y', str)
    ])
    
    def do_something(foo: Foo) -> Foo:
        return foo._replace(x=7)

    I'm getting this error:

    test.py: note: In function "do_something":
    test.py:9: error: "Foo" has no attribute "_replace"

  5. gvanrossum commented on Sep 22, 2016

    @gvanrossum
    Member
  6. elazarg commented on Sep 22, 2016

    @elazarg
    ContributorAuthor

    No it was fixed but not released yet.

  7. gvanrossum commented on Sep 22, 2016

    @gvanrossum
    Member

    Our policy is to close bugs when the fix lands in the repo. So if this issue is fixed in the repo it should be closed now. (As the originator you should be able to.)

  8. dlinnemeyer commented on Sep 22, 2016

    @dlinnemeyer

    You were right. Installing directly from git doesn't give any errors.

  9. elazarg commented on Sep 22, 2016

    @elazarg
    ContributorAuthor

    @gvanrossum please don't close this issue. It is about other problems, not yet solved.

  10. gvanrossum commented on Sep 22, 2016

    @gvanrossum
    Member

    Sorry!

  11. emmatyping commented on Dec 27, 2024

    @emmatyping
    Member

    namedtuple is no longer an experimental mypy concept, I think this can be closed. Any work left belongs in python/typing or CPython :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions