Skip to content

Commit

Permalink
post-merge updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chadrik committed Dec 16, 2017
1 parent d3fea7e commit 2a920c5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def parse(source: Union[str, bytes],
module: Optional[str],
errors: Optional[Errors] = None,
options: Optional[Options] = None,
plugin: Plugin = None ) -> MypyFile:
plugin: Optional[Plugin] = None) -> MypyFile:

"""Parse a source file, without doing any semantic analysis.
Expand All @@ -87,6 +87,8 @@ def parse(source: Union[str, bytes],
raise_on_error = True
if options is None:
options = Options()
if plugin is None:
plugin = Plugin(options)
errors.set_file(fnam, module)
is_stub_file = fnam.endswith('.pyi')
try:
Expand Down Expand Up @@ -137,8 +139,9 @@ def parse_docstring(hook: Callable[[DocstringParserContext], TypeMap], docstring
"""
type_map = hook(DocstringParserContext(docstring, line, errors))
if type_map:
arg_types = [type_map.pop(name, AnyType()) for name in arg_names]
return_type = type_map.pop('return', AnyType())
arg_types = [type_map.pop(name, AnyType(TypeOfAny.unannotated))
for name in arg_names]
return_type = type_map.pop('return', AnyType(TypeOfAny.unannotated))
if type_map:
errors.report(line, 0,
TYPE_COMMENT_DOCSTRING_ERROR.format(list(type_map)))
Expand Down
4 changes: 3 additions & 1 deletion mypy/fastparse2.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def parse(source: Union[str, bytes],
module: Optional[str],
errors: Optional[Errors] = None,
options: Optional[Options] = None,
plugin: Plugin = None) -> MypyFile:
plugin: Optional[Plugin] = None) -> MypyFile:
"""Parse a source file, without doing any semantic analysis.
Return the parse tree. If errors is not provided, raise ParseError
Expand All @@ -95,6 +95,8 @@ def parse(source: Union[str, bytes],
raise_on_error = True
if options is None:
options = Options()
if plugin is None:
plugin = Plugin(options)
errors.set_file(fnam, module)
is_stub_file = fnam.endswith('.pyi')
try:
Expand Down
2 changes: 1 addition & 1 deletion mypy/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def parse(source: Union[str, bytes],
module: Optional[str],
errors: Optional[Errors],
options: Options,
plugin: Plugin) -> MypyFile:
plugin: Optional[Plugin]) -> MypyFile:
"""Parse a source file, without doing any semantic analysis.
Return the parse tree. If errors is not provided, raise ParseError
Expand Down
1 change: 1 addition & 0 deletions mypy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def fail(self, msg: str, ctx: Context, serious: bool = False, *,
('cls', ClassDef), # The class definition
('reason', Expression), # The expression being applied (decorator, metaclass, base class)
('api', SemanticAnalyzerPluginInterface)
])

# A context for a hook that extracts type annotations from docstrings.
#
Expand Down

0 comments on commit 2a920c5

Please sign in to comment.