diff --git a/mypyc/test-data/irbuild-match.test b/mypyc/test-data/irbuild-match.test index 57d9e5c22d40..28aff3dcfc45 100644 --- a/mypyc/test-data/irbuild-match.test +++ b/mypyc/test-data/irbuild-match.test @@ -1729,7 +1729,7 @@ L6: unreachable [case testMatchLiteralMatchArgs_python3_10] -from typing_extensions import Literal +from typing import Literal class Foo: __match_args__: tuple[Literal["foo"]] = ("foo",) diff --git a/mypyc/test-data/run-classes.test b/mypyc/test-data/run-classes.test index 127f67902b7d..5d7aadb15045 100644 --- a/mypyc/test-data/run-classes.test +++ b/mypyc/test-data/run-classes.test @@ -1068,7 +1068,7 @@ assert b.z is None assert not hasattr(b, 'bogus') [case testProtocol] -from typing_extensions import Protocol +from typing import Protocol class Proto(Protocol): def foo(self, x: int) -> None: diff --git a/mypyc/test-data/run-misc.test b/mypyc/test-data/run-misc.test index 94d8ffb41e4e..a08be091bcc3 100644 --- a/mypyc/test-data/run-misc.test +++ b/mypyc/test-data/run-misc.test @@ -612,8 +612,7 @@ for a in sorted(s): 9 8 72 [case testDummyTypes] -from typing import Tuple, List, Dict, Literal, NamedTuple, TypedDict -from typing_extensions import NewType +from typing import Tuple, List, Dict, Literal, NamedTuple, NewType, TypedDict class A: pass diff --git a/mypyc/test-data/run-multimodule.test b/mypyc/test-data/run-multimodule.test index 11e898b45572..5112e126169f 100644 --- a/mypyc/test-data/run-multimodule.test +++ b/mypyc/test-data/run-multimodule.test @@ -495,7 +495,7 @@ class Bar: bar(self) [file other.py] -from typing_extensions import TYPE_CHECKING +from typing import TYPE_CHECKING MYPY = False if MYPY: from native import Foo @@ -525,7 +525,7 @@ def f(c: 'C') -> int: return c.x [file other.py] -from typing_extensions import TYPE_CHECKING +from typing import TYPE_CHECKING if TYPE_CHECKING: from native import D diff --git a/test-data/unit/check-deprecated.test b/test-data/unit/check-deprecated.test index c6953122d788..6cc160fad81f 100644 --- a/test-data/unit/check-deprecated.test +++ b/test-data/unit/check-deprecated.test @@ -380,8 +380,8 @@ for i in a: # E: function __main__.A.__iter__ is deprecated: no iteration [case testDeprecatedOverloadedInstanceMethods] # flags: --enable-error-code=deprecated -from typing import Iterator, Union -from typing_extensions import deprecated, overload +from typing import Iterator, Union, overload +from typing_extensions import deprecated class A: @overload @@ -429,8 +429,8 @@ b.h("x") # E: function __main__.A.h is deprecated: use `h2` instead [case testDeprecatedOverloadedClassMethods] # flags: --enable-error-code=deprecated -from typing import Iterator, Union -from typing_extensions import deprecated, overload +from typing import Iterator, Union, overload +from typing_extensions import deprecated class A: @overload @@ -487,8 +487,8 @@ b.h("x") # E: function __main__.A.h is deprecated: use `h2` instead [case testDeprecatedOverloadedStaticMethods] # flags: --enable-error-code=deprecated -from typing import Iterator, Union -from typing_extensions import deprecated, overload +from typing import Iterator, Union, overload +from typing_extensions import deprecated class A: @overload @@ -545,8 +545,8 @@ b.h("x") # E: function __main__.A.h is deprecated: use `h2` instead [case testDeprecatedOverloadedSpecialMethods] # flags: --enable-error-code=deprecated -from typing import Iterator, Union -from typing_extensions import deprecated, overload +from typing import Iterator, Union, overload +from typing_extensions import deprecated class A: @overload @@ -671,8 +671,8 @@ C().g = "x" # E: function __main__.C.g is deprecated: use g2 instead \ [case testDeprecatedDescriptor] # flags: --enable-error-code=deprecated -from typing import Any, Optional, Union -from typing_extensions import deprecated, overload +from typing import Any, Optional, Union, overload +from typing_extensions import deprecated @deprecated("use E1 instead") class D1: @@ -725,8 +725,8 @@ c.d3 = "x" # E: overload def (self: __main__.D3, obj: __main__.C, value: builti [case testDeprecatedOverloadedFunction] # flags: --enable-error-code=deprecated -from typing import Union -from typing_extensions import deprecated, overload +from typing import Union, overload +from typing_extensions import deprecated @overload def f(x: int) -> int: ... @@ -788,8 +788,8 @@ m.g("x") [file m.py] -from typing import Union -from typing_extensions import deprecated, overload +from typing import Union, overload +from typing_extensions import deprecated @overload @deprecated("work with str instead") diff --git a/test-data/unit/check-errorcodes.test b/test-data/unit/check-errorcodes.test index 45b9dced046d..6ec246fb3a13 100644 --- a/test-data/unit/check-errorcodes.test +++ b/test-data/unit/check-errorcodes.test @@ -652,7 +652,7 @@ def g() -> int: x: List[int] # type: ignore[name-defined] [case testErrorCodeProtocolProblemsIgnore] -from typing_extensions import Protocol +from typing import Protocol class P(Protocol): def f(self, x: str) -> None: ... diff --git a/test-data/unit/check-expressions.test b/test-data/unit/check-expressions.test index 8dd589937df8..81eb4c7c0dc8 100644 --- a/test-data/unit/check-expressions.test +++ b/test-data/unit/check-expressions.test @@ -1010,25 +1010,23 @@ y: Gen[Literal[1]] = assert_type(Gen(1), Gen[Literal[1]]) [builtins fixtures/tuple.pyi] [case testAssertTypeUncheckedFunction] -from typing import assert_type -from typing_extensions import Literal +from typing import Literal, assert_type def f(): x = 42 assert_type(x, Literal[42]) [out] -main:5: error: Expression is of type "Any", not "Literal[42]" -main:5: note: "assert_type" expects everything to be "Any" in unchecked functions +main:4: error: Expression is of type "Any", not "Literal[42]" +main:4: note: "assert_type" expects everything to be "Any" in unchecked functions [builtins fixtures/tuple.pyi] [case testAssertTypeUncheckedFunctionWithUntypedCheck] # flags: --check-untyped-defs -from typing import assert_type -from typing_extensions import Literal +from typing import Literal, assert_type def f(): x = 42 assert_type(x, Literal[42]) [out] -main:6: error: Expression is of type "int", not "Literal[42]" +main:5: error: Expression is of type "int", not "Literal[42]" [builtins fixtures/tuple.pyi] [case testAssertTypeNoPromoteUnion] diff --git a/test-data/unit/check-modules.test b/test-data/unit/check-modules.test index 9e99a1ca5cf0..87eb25a48cc2 100644 --- a/test-data/unit/check-modules.test +++ b/test-data/unit/check-modules.test @@ -519,8 +519,7 @@ def bar(x: Both, y: Both = ...) -> Both: [out] [case testEllipsisDefaultArgValueInNonStubsMethods] -from typing import Generic, TypeVar -from typing_extensions import Protocol +from typing import Generic, Protocol, TypeVar from abc import abstractmethod T = TypeVar('T') diff --git a/test-data/unit/check-namedtuple.test b/test-data/unit/check-namedtuple.test index a65a99cc25d0..b8a753b3c90a 100644 --- a/test-data/unit/check-namedtuple.test +++ b/test-data/unit/check-namedtuple.test @@ -69,8 +69,7 @@ a.y = 5 # E: Property "y" defined in "X" is read-only [case testTypingNamedTupleAttributesAreReadOnly] -from typing import NamedTuple -from typing_extensions import Protocol +from typing import NamedTuple, Protocol class HasX(Protocol): x: str @@ -82,8 +81,8 @@ a: HasX = A("foo") a.x = "bar" [builtins fixtures/tuple.pyi] [out] -main:10: error: Incompatible types in assignment (expression has type "A", variable has type "HasX") -main:10: note: Protocol member HasX.x expected settable variable, got read-only attribute +main:9: error: Incompatible types in assignment (expression has type "A", variable has type "HasX") +main:9: note: Protocol member HasX.x expected settable variable, got read-only attribute [case testNamedTupleCreateWithPositionalArguments] diff --git a/test-data/unit/check-protocols.test b/test-data/unit/check-protocols.test index 1400f3b152ec..a7124b7a83d3 100644 --- a/test-data/unit/check-protocols.test +++ b/test-data/unit/check-protocols.test @@ -2339,8 +2339,7 @@ main:19: note: Protocol member AllSettable.b expected settable variable, got rea main:19: note: <2 more conflict(s) not shown> [case testProtocolsMoreConflictsNotShown] -from typing_extensions import Protocol -from typing import Generic, TypeVar +from typing import Generic, Protocol, TypeVar T = TypeVar('T') @@ -2862,7 +2861,7 @@ c1: SupportsClassGetItem = C() [case testNoneVsProtocol] # mypy: strict-optional -from typing_extensions import Protocol +from typing import Protocol class MyHashable(Protocol): def __hash__(self) -> int: ... diff --git a/test-data/unit/check-selftype.test b/test-data/unit/check-selftype.test index 1ac5924262b3..4c49bd7093cd 100644 --- a/test-data/unit/check-selftype.test +++ b/test-data/unit/check-selftype.test @@ -856,8 +856,7 @@ BadSub().get_item() # E: Invalid self argument "BadSub" to attribute function " [builtins fixtures/list.pyi] [case testMixinAllowedWithProtocol] -from typing import TypeVar -from typing_extensions import Protocol +from typing import Protocol, TypeVar class Resource(Protocol): def close(self) -> int: ... @@ -908,8 +907,7 @@ class Bad: class CC(TweakFunc, Bad): pass # E: Definition of "func" in base class "TweakFunc" is incompatible with definition in base class "Bad" [case testBadClassLevelDecoratorHack] -from typing_extensions import Protocol -from typing import TypeVar, Any +from typing import Protocol, TypeVar, Any class FuncLike(Protocol): __call__: Any diff --git a/test-data/unit/check-semanal-error.test b/test-data/unit/check-semanal-error.test index d7ab272aed6c..52abbf09f1e5 100644 --- a/test-data/unit/check-semanal-error.test +++ b/test-data/unit/check-semanal-error.test @@ -137,8 +137,7 @@ def f() -> None: ... # E: Name "f" already defined (possibly by an import) [out] [case testRuntimeProtoTwoBases] -from typing_extensions import Protocol, runtime_checkable -from typing import TypeVar, Generic +from typing import TypeVar, Generic, Protocol, runtime_checkable T = TypeVar('T') @@ -151,6 +150,7 @@ class C: x: P[int] = C() [builtins fixtures/tuple.pyi] +[typing fixtures/typing-full.pyi] [case testSemanalDoesNotLeakSyntheticTypes] # flags: --cache-fine-grained