Skip to content

Invalid type error for deferred function #2299

Closed

Description

@JukkaL

Mypy complains about the following program because of deferred type checking:

from typing import Union

def f(a: Union[int, str]) -> None:
    x
    a = x
    a + 1   # Error

x = 1 + 1

If x = 1 + 1 is before the function definition there is no error.

This was originally reported by @ecprice: #1748 (comment). There's additional discussion in the linked PR.

Activity

  1. added this to the milestone on Oct 27, 2016
  2. removed this from the milestone on Mar 29, 2017
  3. ilevkivskyi commented on Sep 3, 2019

    @ilevkivskyi
    Member

    This works correctly on master.

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