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

Use consistent capitalization of TypeVar #13687

Merged
merged 1 commit into from
Sep 19, 2022
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 mypy/message_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def with_additional_msg(self, info: str) -> ErrorMessage:
TYPEVAR_UNEXPECTED_ARGUMENT: Final = 'Unexpected argument to "TypeVar()"'
UNBOUND_TYPEVAR: Final = (
"A function returning TypeVar should receive at least "
"one argument containing the same Typevar"
"one argument containing the same TypeVar"
)

# Super
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -3232,7 +3232,7 @@ def error(u_c: Type[U]) -> P: # Error here, see below
return new_pro(u_c) # Error here, see below
[out]
main:11: note: Revealed type is "__main__.WizUser"
main:12: error: A function returning TypeVar should receive at least one argument containing the same Typevar
main:12: error: A function returning TypeVar should receive at least one argument containing the same TypeVar
main:13: error: Value of type variable "P" of "new_pro" cannot be "U"
main:13: error: Incompatible return value type (got "U", expected "P")

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 @@ -254,7 +254,7 @@ z: y # E: Variable "__main__.y" is not valid as a type [valid-type] \
from typing import TypeVar

T = TypeVar('T')
def f() -> T: pass # E: A function returning TypeVar should receive at least one argument containing the same Typevar [type-var]
def f() -> T: pass # E: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]
x = f() # E: Need type annotation for "x" [var-annotated]
y = [] # E: Need type annotation for "y" (hint: "y: List[<type>] = ...") [var-annotated]
[builtins fixtures/list.pyi]
Expand Down
10 changes: 5 additions & 5 deletions test-data/unit/check-generics.test
Original file line number Diff line number Diff line change
Expand Up @@ -1557,9 +1557,9 @@ A = TypeVar('A')
B = TypeVar('B')

def f1(x: A) -> A: ...
def f2(x: A) -> B: ... # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f2(x: A) -> B: ... # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
def f3(x: B) -> B: ...
def f4(x: int) -> A: ... # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f4(x: int) -> A: ... # E: A function returning TypeVar should receive at least one argument containing the same TypeVar

y1 = f1
if int():
Expand Down Expand Up @@ -1608,8 +1608,8 @@ B = TypeVar('B')
T = TypeVar('T')
def outer(t: T) -> None:
def f1(x: A) -> A: ...
def f2(x: A) -> B: ... # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f3(x: T) -> A: ... # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f2(x: A) -> B: ... # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
def f3(x: T) -> A: ... # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
def f4(x: A) -> T: ...
def f5(x: T) -> T: ...

Expand Down Expand Up @@ -1778,7 +1778,7 @@ from typing import TypeVar
A = TypeVar('A')
B = TypeVar('B')
def f1(x: int, y: A) -> A: ...
def f2(x: int, y: A) -> B: ... # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f2(x: int, y: A) -> B: ... # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
def f3(x: A, y: B) -> B: ...
g = f1
g = f2
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-inference.test
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ g(None) # Ok
f() # Ok because not used to infer local variable type
g(a)

def f() -> T: pass # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f() -> T: pass # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
def g(a: T) -> None: pass
[out]

Expand Down Expand Up @@ -2355,7 +2355,7 @@ def main() -> None:
[case testDontMarkUnreachableAfterInferenceUninhabited]
from typing import TypeVar
T = TypeVar('T')
def f() -> T: pass # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f() -> T: pass # E: A function returning TypeVar should receive at least one argument containing the same TypeVar

class C:
x = f() # E: Need type annotation for "x"
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-parameter-specification.test
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ def callback(func: Callable[[Any], Any]) -> None: ...
class Job(Generic[P]): ...

@callback
def run_job(job: Job[...]) -> T: ... # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def run_job(job: Job[...]) -> T: ... # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
[builtins fixtures/tuple.pyi]

[case testTupleAndDictOperationsOnParamSpecArgsAndKwargs]
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-typevar-unbound.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from typing import TypeVar

T = TypeVar('T')

def f() -> T: # E: A function returning TypeVar should receive at least one argument containing the same Typevar
def f() -> T: # E: A function returning TypeVar should receive at least one argument containing the same TypeVar
...

f()
Expand Down