Skip to content
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
7 changes: 5 additions & 2 deletions mypy/nativeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def parse_to_binary_ast(
platform=options.platform,
always_true=options.always_true,
always_false=options.always_false,
cache_version=1,
cache_version=2,
)
return (
ast_bytes,
Expand Down Expand Up @@ -939,6 +939,7 @@ def read_type(state: State, data: ReadBuffer) -> Type:
elif tag == types.RAW_EXPRESSION_TYPE:
type_name = read_str(data)
value: types.LiteralValue | str | None
note: str | None = None
if type_name == "builtins.bool":
value = read_bool(data)
elif type_name == "builtins.int":
Expand All @@ -953,9 +954,11 @@ def read_type(state: State, data: ReadBuffer) -> Type:
tag = read_tag(data)
assert tag == LITERAL_NONE, f"Expected LITERAL_NONE for invalid type, got {tag}"
value = None
# Read optional note (cache_version >= 2)
note = read_str_opt(data)
else:
assert False, f"Unsupported RawExpressionType: {type_name}"
raw_type = RawExpressionType(value, type_name)
raw_type = RawExpressionType(value, type_name, note=note)
read_loc(data, raw_type)
expect_end_tag(data)
return raw_type
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-annotated.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ x: Annotated[int, THESE, ARE, IGNORED, FOR, NOW]
reveal_type(x) # N: Revealed type is "builtins.int"
[builtins fixtures/tuple.pyi]

[case testAnnotated3_no_native_parse]
[case testAnnotated3]
from typing_extensions import Annotated
x: Annotated[int, -+~12.3, "som"[e], more(anno+a+ions, that=[are]), (b"ignored",), 4, N.O.W, ...]
reveal_type(x) # N: Revealed type is "builtins.int"
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-fastparse.test
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def f(x, y): # E: Type signature has too few parameters
f(1, 2)
f(1) # E: Missing positional argument "y" in call to "f"

[case testFasterParseTypeErrorCustom_no_native_parse]
[case testFasterParseTypeErrorCustom]

from typing import TypeVar, Generic
T = TypeVar('T')
Expand All @@ -207,7 +207,7 @@ def f(a: Foo(int)) -> int:
main:7: error: Invalid type comment or annotation
main:7: note: Suggestion: use Foo[...] instead of Foo(...)

[case testFasterParseCallWithKeywordArgs_no_native_parse]
[case testFasterParseCallWithKeywordArgs]

def Foo(sort: bool) -> type:
return int
Expand Down
Loading