Skip to content

Commit 69eb6fe

Browse files
authored
Sync typeshed (#8653)
Handle None line numbers (which can happen according to typeshed).
1 parent b8bdc26 commit 69eb6fe

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

mypy/fastparse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ def parse(source: Union[str, bytes],
167167
tree.path = fnam
168168
tree.is_stub = is_stub_file
169169
except SyntaxError as e:
170-
errors.report(e.lineno, e.offset, e.msg, blocker=True, code=codes.SYNTAX)
170+
errors.report(e.lineno if e.lineno is not None else -1, e.offset, e.msg, blocker=True,
171+
code=codes.SYNTAX)
171172
tree = MypyFile([], [], False, {})
172173

173174
if raise_on_error and errors.is_errors():

mypy/fastparse2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def parse(source: Union[str, bytes],
119119
tree.path = fnam
120120
tree.is_stub = is_stub_file
121121
except SyntaxError as e:
122-
errors.report(e.lineno, e.offset, e.msg, blocker=True, code=codes.SYNTAX)
122+
errors.report(e.lineno if e.lineno is not None else -1, e.offset, e.msg, blocker=True,
123+
code=codes.SYNTAX)
123124
tree = MypyFile([], [], False, {})
124125

125126
if raise_on_error and errors.is_errors():

mypy/typeshed

Submodule typeshed updated 62 files

0 commit comments

Comments
 (0)