Skip to content

Commit 2a920c5

Browse files
committed
post-merge updates
1 parent d3fea7e commit 2a920c5

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

mypy/fastparse.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def parse(source: Union[str, bytes],
7474
module: Optional[str],
7575
errors: Optional[Errors] = None,
7676
options: Optional[Options] = None,
77-
plugin: Plugin = None ) -> MypyFile:
77+
plugin: Optional[Plugin] = None) -> MypyFile:
7878

7979
"""Parse a source file, without doing any semantic analysis.
8080
@@ -87,6 +87,8 @@ def parse(source: Union[str, bytes],
8787
raise_on_error = True
8888
if options is None:
8989
options = Options()
90+
if plugin is None:
91+
plugin = Plugin(options)
9092
errors.set_file(fnam, module)
9193
is_stub_file = fnam.endswith('.pyi')
9294
try:
@@ -137,8 +139,9 @@ def parse_docstring(hook: Callable[[DocstringParserContext], TypeMap], docstring
137139
"""
138140
type_map = hook(DocstringParserContext(docstring, line, errors))
139141
if type_map:
140-
arg_types = [type_map.pop(name, AnyType()) for name in arg_names]
141-
return_type = type_map.pop('return', AnyType())
142+
arg_types = [type_map.pop(name, AnyType(TypeOfAny.unannotated))
143+
for name in arg_names]
144+
return_type = type_map.pop('return', AnyType(TypeOfAny.unannotated))
142145
if type_map:
143146
errors.report(line, 0,
144147
TYPE_COMMENT_DOCSTRING_ERROR.format(list(type_map)))

mypy/fastparse2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def parse(source: Union[str, bytes],
8383
module: Optional[str],
8484
errors: Optional[Errors] = None,
8585
options: Optional[Options] = None,
86-
plugin: Plugin = None) -> MypyFile:
86+
plugin: Optional[Plugin] = None) -> MypyFile:
8787
"""Parse a source file, without doing any semantic analysis.
8888
8989
Return the parse tree. If errors is not provided, raise ParseError
@@ -95,6 +95,8 @@ def parse(source: Union[str, bytes],
9595
raise_on_error = True
9696
if options is None:
9797
options = Options()
98+
if plugin is None:
99+
plugin = Plugin(options)
98100
errors.set_file(fnam, module)
99101
is_stub_file = fnam.endswith('.pyi')
100102
try:

mypy/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def parse(source: Union[str, bytes],
1111
module: Optional[str],
1212
errors: Optional[Errors],
1313
options: Options,
14-
plugin: Plugin) -> MypyFile:
14+
plugin: Optional[Plugin]) -> MypyFile:
1515
"""Parse a source file, without doing any semantic analysis.
1616
1717
Return the parse tree. If errors is not provided, raise ParseError

mypy/plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def fail(self, msg: str, ctx: Context, serious: bool = False, *,
125125
('cls', ClassDef), # The class definition
126126
('reason', Expression), # The expression being applied (decorator, metaclass, base class)
127127
('api', SemanticAnalyzerPluginInterface)
128+
])
128129

129130
# A context for a hook that extracts type annotations from docstrings.
130131
#

0 commit comments

Comments
 (0)