Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update a few more imports in tests #18655

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypyc/test-data/irbuild-match.test
Original file line number Diff line number Diff line change
Expand Up @@ -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",)
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test-data/run-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions mypyc/test-data/run-misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mypyc/test-data/run-multimodule.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
28 changes: 14 additions & 14 deletions test-data/unit/check-deprecated.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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: ...
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
12 changes: 5 additions & 7 deletions test-data/unit/check-expressions.test
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions test-data/unit/check-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
7 changes: 3 additions & 4 deletions test-data/unit/check-namedtuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
5 changes: 2 additions & 3 deletions test-data/unit/check-protocols.test
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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: ...
Expand Down
6 changes: 2 additions & 4 deletions test-data/unit/check-selftype.test
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-semanal-error.test
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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
Expand Down