[case testIgnoreTypeError]
x = 1
x() # type: ignore
x() # E: "int" not callable

[case testIgnoreUndefinedName]
x = 1
y # type: ignore
z # E: Name 'z' is not defined

[case testIgnoreImportError]
import xyz_m # type: ignore
xyz_m.foo
1() # E: "int" not callable

[case testIgnoreImportFromError]
from xyz_m import a, b # type: ignore
a.foo
b()
1() # E: "int" not callable

[case testIgnoreImportFromErrorMultiline]
from xyz_m import ( # type: ignore
    a, b
)
a.foo
b()
1() # E: "int" not callable

[case testIgnoreImportAllError]
from xyz_m import * # type: ignore
x   # E: Name 'x' is not defined
1() # E: "int" not callable

[case testIgnoreImportBadModule]
import m # type: ignore
from m import a # type: ignore
[file m.py]
+
[out]
tmp/m.py:1: error: invalid syntax

[case testIgnoreAppliesOnlyToMissing]
import a # type: ignore
import b # type: ignore
reveal_type(a.foo) # E: Revealed type is 'Any'
reveal_type(b.foo) # E: Revealed type is 'builtins.int'
a.bar()
b.bar() # E: Module has no attribute "bar"

[file b.py]
foo = 3

[builtins fixtures/module_all.pyi]
[out]

[case testIgnoreImportStarFromBadModule]
from m import * # type: ignore
[file m.py]
+
[out]
tmp/m.py:1: error: invalid syntax

[case testIgnoreAssignmentTypeError]
x = 1
x = '' # type: ignore
x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")

[case testIgnoreInvalidOverride]
class A:
    def f(self) -> int: pass
class B(A):
    def f(self) -> str: pass # type: ignore

[case testIgnoreMissingModuleAttribute]
import m
m.x = object # type: ignore
m.f() # type: ignore
m.y # E: Module has no attribute "y"
[file m.py]
[builtins fixtures/module.pyi]

[case testIgnoreTypeInferenceError]
x = [] # type: ignore
y = x
x.append(1)
[builtins fixtures/list.pyi]

[case testIgnoreTypeInferenceError2]
def f() -> None: pass
x = f() # type: ignore
y = x
x = 1
[builtins fixtures/list.pyi]

[case testIgnoreTypeInferenceErrorAndMultipleAssignment]
x, y = [], [] # type: ignore
z = x
z = y
[builtins fixtures/list.pyi]

[case testIgnoreSomeStarImportErrors]
from m1 import *
from m2 import * # type: ignore
# We should still import things that don't conflict.
y() # E: "str" not callable
z() # E: "int" not callable
x() # E: "int" not callable
[file m1.py]
x = 1
y = ''
[file m2.py]
x = ''
z = 1

[case testIgnoredModuleDefinesBaseClass1]
from m import B # type: ignore

class C(B):
    def f(self) -> None:
        self.f(1) # E: Too many arguments for "f" of "C"
        self.g(1)
[out]

[case testIgnoredModuleDefinesBaseClass2]
import m # type: ignore

class C(m.B):
    def f(self) -> None: ...

c = C()
c.f(1) # E: Too many arguments for "f" of "C"
c.g(1)
c.x = 1
[out]

[case testIgnoredModuleDefinesBaseClassAndClassAttribute]
import m # type: ignore

class C(m.B):
    @staticmethod
    def f() -> None: pass

C.f(1) # E: Too many arguments for "f" of "C"
C.g(1)
C.x = 1
[builtins fixtures/staticmethod.pyi]
[out]

[case testIgnoredModuleDefinesBaseClassWithInheritance1]
from m import B # type: ignore

class C: pass
class D(C, B):
    def f(self) -> None:
        self.f(1) # E: Too many arguments for "f" of "D"
        self.g(1)
[out]

[case testIgnoredModuleDefinesBaseClassWithInheritance2]
from m import B # type: ignore

class C(B): pass
class D(C):
    def f(self) -> None:
        self.f(1) # E: Too many arguments for "f" of "D"
        self.g(1)
[out]

[case testIgnoreWithFollowingIndentedComment]
if 1:  # type: ignore
    # blah
    pass
[out]

[case testIgnoreTooManyTypeArguments]
from typing import TypeVar, Generic
T = TypeVar('T')
U = TypeVar('U')

class Base(Generic[T, U]):
  pass

class PartialBase(Base[T, int], Generic[T]):
  pass

class Child(PartialBase[str, int]):  # type: ignore
  pass


def foo(x: Base[str, int]) -> None: pass
foo(Child())

def bar(x: Base[str, str]) -> None: pass
bar(Child())
[out]
main:19: error: Argument 1 to "bar" has incompatible type "Child"; expected "Base[str, str]"

[case testTypeIgnoreLineNumberWithinFile]
import m
pass # type: ignore
m.f(kw=1)
[file m.py]
pass
def f() -> None: pass
[out]
main:3: error: Unexpected keyword argument "kw" for "f"
tmp/m.py:2: note: "f" defined here

[case testIgnoreUnexpectedKeywordArgument]
import m
m.f(kw=1)  # type: ignore
[file m.py]
def f() -> None: pass
[out]

[case testCannotIgnoreBlockingError]
yield  # type: ignore  # E: 'yield' outside function
