Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
249d70f
Implement Callable[[Arg('name', Type)], ret] syntax
sixolet Nov 11, 2016
7ecdcc1
General cleanup
sixolet Dec 24, 2016
066bd5e
Change tests back to match old behavior
sixolet Dec 24, 2016
213944b
lots of lint
sixolet Dec 24, 2016
0e19070
Oh god I am tired of writing parsers
sixolet Dec 25, 2016
3f2f617
Tighten fastparse a little
sixolet Dec 25, 2016
0b69630
make all tests pass now
sixolet Dec 25, 2016
f4ccf92
go back to master version of typeshed I guess
sixolet Dec 25, 2016
967bb5a
Meged master, but tests fail again now.
sixolet Apr 12, 2017
bb5134e
Tests all pass again after merge
sixolet Apr 18, 2017
d4a83e1
Merged master again
sixolet Apr 18, 2017
54a5da9
Big refactor. Wait until semanal to get arg kinds, switch order again…
sixolet Apr 20, 2017
e79c527
Change back to TypeList
sixolet Apr 20, 2017
52ffe5c
Cleanups. Preparing to split into two diffs maybe?
sixolet Apr 20, 2017
06416f7
update typeshed to master version
sixolet Apr 20, 2017
398fbad
more cleanups
sixolet Apr 20, 2017
2c9ce02
should not have changed these test files
sixolet Apr 20, 2017
51c6f56
Semanal needs to be a SyntheticTypeVisitor
sixolet Apr 20, 2017
5e679a3
Annot
sixolet Apr 20, 2017
0926fe9
Oops
sixolet Apr 20, 2017
288a8be
Add testing for exprtotype Arg constructors in wierd places
sixolet Apr 20, 2017
6e67ab2
Remove some ill-modified modifications to tests
sixolet Apr 20, 2017
97a859b
Merge master, no longer depend on other PR
sixolet Apr 20, 2017
1c7d4c6
Jukka comments
sixolet Apr 21, 2017
f153850
Synthetic types don't serialize
sixolet Apr 21, 2017
be954f5
Remove unused instance var
sixolet Apr 21, 2017
07ae917
Merge master
sixolet Apr 22, 2017
1b97362
Revert "Remove unused instance var"
sixolet Apr 22, 2017
552f49e
Accessing TypeList types directly is not required
sixolet Apr 22, 2017
f2e3663
Undo changes to this file they were not required
sixolet Apr 22, 2017
27e2a9d
lint
sixolet Apr 22, 2017
793a663
Merge master again
sixolet Apr 22, 2017
3d212b3
Merge master
sixolet May 1, 2017
0780149
Disallow CallableArgument in exprtotype outside a TypeList
sixolet May 1, 2017
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
Prev Previous commit
Next Next commit
Tighten fastparse a little
  • Loading branch information
sixolet committed Dec 25, 2016
commit 3f2f617a56fed3d730f355b54ff6ec4291f52391
24 changes: 13 additions & 11 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,13 +887,7 @@ def translate_argument_list(self, l: Sequence[ast35.AST]) -> ArgumentList:
typ = AnyType(implicit=True) # type: Type
for i, arg in enumerate(e.args):
if i == 0 and not star:
if isinstance(arg, ast35.Name) and arg.id == 'None':
name = None
elif isinstance(arg, ast35.Str):
name = arg.s
else:
raise FastParserError("Bad type for name of argument",
value.lineno, value.col_offset)
name = _extract_str(arg)
elif i == 1 and not star or i == 0 and star:
try:
typ = self.visit(arg)
Expand All @@ -906,10 +900,7 @@ def translate_argument_list(self, l: Sequence[ast35.AST]) -> ArgumentList:
for k in e.keywords:
value = k.value
if k.arg == "name" and not star:
if isinstance(value, ast35.Name) and value.id == 'None':
name = None
elif isinstance(value, ast35.Str):
name = value.s
name = _extract_str(value)
elif k.arg == "typ":
try:
typ = self.visit(value)
Expand Down Expand Up @@ -992,3 +983,14 @@ def __init__(self, msg: str, lineno: int, offset: int) -> None:

class FastParserError(TypeCommentParseError):
pass

def _extract_str(arg: ast35.AST) -> Optional[str]:
if isinstance(arg, ast35.Name) and arg.id == 'None':
return None
elif isinstance(arg, ast35.NameConstant) and arg.value is None:
return None
elif isinstance(arg, ast35.Str):
return arg.s
else:
raise FastParserError("Bad type for name of argument",
arg.lineno, arg.col_offset)