Skip to content

Importing generic type aliases #2887

Closed
Closed

Description

@dmzkrsk

lib.py:

from typing import Callable, TypeVar, Tuple

T = TypeVar('T')
R = TypeVar('R')

Transform = Callable[[T, int], Tuple[T, R]]

main.py:

from typing import Tuple
from lib import Transform


def int_tf(m: int) -> Transform[int, str]:  # Bad number of arguments for type alias, expected: 0, given: 2
    def transform(i: int, pos: int) -> Tuple[int, str]:
        a = (i + pos) % m  # Name 'T' is not defined Name 'R' is not defined
        return (a, 'ok')

    return transform

It works when an alias is defined in the same file

Activity

  1. dmzkrsk commented on Feb 21, 2017

    @dmzkrsk
    Author

    Looks like T and R are not "bound" to Transform

    from lib import T, R solves this issue (but it doesn't look right)
    Defining T and R in main.py works too

  2. ilevkivskyi commented on Feb 21, 2017

    @ilevkivskyi
    Member

    Thanks for reporting this! Indeed, this looks like a bug. I will take a look at this.

  3. self-assigned this
    on Mar 31, 2017
  4. JukkaL commented on May 31, 2017

    @JukkaL
    Collaborator

    @ilevkivskyi Are you still working on this?

  5. ilevkivskyi commented on May 31, 2017

    @ilevkivskyi
    Member

    Sorry, last weeks were busy, so I could not finish this. I actually wanted to spend next week less on reviewing PRs and more on fixing old assigned issues. Do you want to work on this one?

  6. JukkaL commented on May 31, 2017

    @JukkaL
    Collaborator

    I'm reviewing github issues and trying keep the information about who's working on what up-to-date. This issue isn't particularly urgent among the high-priority issues.

  7. added a commit that references this issue on Jul 7, 2017
    70d5f45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions