Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not parse default values as types #1350

Closed
wants to merge 2 commits into from

Conversation

JelleZijlstra
Copy link
Contributor

@rchen152
Copy link
Contributor

@martindemello Could you take a look at this one? Based on the other usages of visit(), it looks like it has a return value, and I'm not sure if discarding that is okay or not.

@martindemello
Copy link
Contributor

you're right, annotation visitor methods should return a value because of this usage: https://github.com/google/pytype/blob/main/pytype/pyi/parser.py#L315

# Visit only the annotation, not the default (which may be a
# string but should not be interpreted as a type annotation).
if node.annotation is not None:
self.visit(node.annotation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return self.visit ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we'd return a different type which seems wrong, right? I imagine I'll have to construct a new ast.arg with the visited annotation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, i don't think so. if you look at convert_node_annotations it's only ever modifying the annotations field of the node, not the node itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then this code should be useless, because there cannot be an arg node inside an annotation (unless there's a lambda in the annotation I suppose). Indeed, I just checked and the test I added passes even without this change. I'll have to go back and figure out the real source of the crash.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes :) i did wonder why the change was needed in the first place but i figured you had found some odd corner case in the ast that we weren't handling well. if you can share the file the parser crashes on i can take a look as well.

Copy link
Contributor Author

@JelleZijlstra JelleZijlstra Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It's from python/typeshed#9501. There are a lot of crashes, but the one I posted below points to https://github.com/python/typeshed/blob/7f85a0cd903f51a63030620be8ac9e1b52a73d94/stdlib/email/header.pyi line 26 which has continuation_ws: str = " ", in a default.

Looking at the stack trace again I do think I am approximately in the right place here, but not sure why the test doesn't reproduce the crash.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, found the issue. here's the fix you need:

--- a/google3/third_party/py/pytype/pyi/parser.py
+++ b/google3/third_party/py/pytype/pyi/parser.py
@@ -129,6 +129,10 @@ def _attribute_to_name(node: ast3.Attrib
 class AnnotationVisitor(visitor.BaseVisitor):
   """Converts typed_ast annotations to pytd."""
 
+  def __init__(self, *args, **kwargs):
+    super().__init__(*args, **kwargs)
+    self._node_children[self._ast.arguments] = ["args", "kwonlyargs"]
+
   def show(self, node):

it will prevent iterating over the defaults.

Copy link
Contributor

@martindemello martindemello Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the crash was specifically due to the empty/whitespace-only string, btw, it was trying to read it as an annotation and failing to find one. your test passed because it used "y" as a default, which is a syntactically valid type annotation as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch! I think your proposed fix isn't quite right because it would exclude annotations on posonly args, *args, and **kwargs. I'll push a version that handles these.

@JelleZijlstra JelleZijlstra marked this pull request as draft January 12, 2023 21:21
@JelleZijlstra
Copy link
Contributor Author

Traceback I'm trying to fix for reference:

2023-01-12T18:23:44.5631648Z Traceback (most recent call last):
2023-01-12T18:23:44.5640236Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/visitor.py", line 36, in _call_visitor
2023-01-12T18:23:44.5640765Z     return super()._call_visitor(node)
2023-01-12T18:23:44.5641526Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 55, in _call_visitor
2023-01-12T18:23:44.5641927Z     return visitor(node)
2023-01-12T18:23:44.5642536Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/parser.py", line 162, in visit_Pyval
2023-01-12T18:23:44.5643008Z     return self.convert_late_annotation(node.value)
2023-01-12T18:23:44.5643714Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/parser.py", line 142, in convert_late_annotation
2023-01-12T18:23:44.5644283Z     typ = a.body[0].value  # pytype: disable=attribute-error
2023-01-12T18:23:44.5644633Z IndexError: list index out of range
2023-01-12T18:23:44.5644818Z 
2023-01-12T18:23:44.5645014Z During handling of the above exception, another exception occurred:
2023-01-12T18:23:44.5645249Z 
2023-01-12T18:23:44.5645380Z Traceback (most recent call last):
2023-01-12T18:23:44.5645809Z   File "/home/runner/work/typeshed/typeshed/./tests/pytype_test.py", line 74, in run_pytype
2023-01-12T18:23:44.5646231Z     ast = loader.load_file(_get_module_name(filename), filename)
2023-01-12T18:23:44.5646880Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 375, in load_file
2023-01-12T18:23:44.5647376Z     return self.load_module(ModuleInfo(module_name, filename), mod_ast=mod_ast)
2023-01-12T18:23:44.5648047Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5648839Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5649535Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5649956Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5650623Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5651055Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5651650Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5652034Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5652603Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5653010Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5653748Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5654144Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5654700Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5655092Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5655666Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5656086Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5656722Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5657157Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5657760Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5658143Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5658710Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5659104Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5659650Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5660034Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5660582Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5660969Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5661525Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5662373Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5663030Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5663448Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5664040Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5664435Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5665003Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5665399Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5666062Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5666491Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5667041Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5667430Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5667989Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5668414Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5669035Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5669462Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5670053Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5670447Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5671078Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5671477Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5672029Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5672414Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5672956Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5673341Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5673896Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5674307Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5674938Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5675370Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5675953Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5676345Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5676908Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5677299Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5677849Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5678235Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5678780Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5679162Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5679706Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5680122Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5680749Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5681176Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5681758Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5682214Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5682783Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5683179Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5683724Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5684109Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5684657Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5685025Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5685581Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5685996Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5686625Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5687127Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5687720Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 457, in _load_ast_dependencies
2023-01-12T18:23:44.5688108Z     dep_ast = self._try_import_prefix(name)
2023-01-12T18:23:44.5688658Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 437, in _try_import_prefix
2023-01-12T18:23:44.5689046Z     ast = self._import_module_by_name(prefix)
2023-01-12T18:23:44.5689607Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5690006Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5690538Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5690927Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5691465Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5691849Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5692401Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5692822Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5693450Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5693875Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5694458Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5694854Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5695424Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5695806Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5696348Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5696729Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5697267Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5697647Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5698198Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5698677Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5699314Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5699740Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5700319Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5700711Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5701264Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5701656Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5702368Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5702760Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5703303Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5703752Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5704316Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5704736Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5705359Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5705788Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5706375Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5706759Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5707326Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5707718Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5708265Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 630, in _load_builtin
2023-01-12T18:23:44.5708647Z     return self.load_module(mod, mod_ast=mod_ast)
2023-01-12T18:23:44.5709187Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 388, in load_module
2023-01-12T18:23:44.5709568Z     return self._process_module(mod_info, mod_ast)
2023-01-12T18:23:44.5710123Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 410, in _process_module
2023-01-12T18:23:44.5710540Z     module.ast = self._resolve_external_and_local_types(module.ast)
2023-01-12T18:23:44.5711164Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 363, in _resolve_external_and_local_types
2023-01-12T18:23:44.5711583Z     self._load_ast_dependencies(dependencies, lookup_ast)
2023-01-12T18:23:44.5712171Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 455, in _load_ast_dependencies
2023-01-12T18:23:44.5712560Z     dep_ast = self._import_module_by_name(name)
2023-01-12T18:23:44.5713122Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 680, in _import_module_by_name
2023-01-12T18:23:44.5713514Z     mod = self._load_builtin("stdlib", module_name)
2023-01-12T18:23:44.5714063Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/load_pytd.py", line 627, in _load_builtin
2023-01-12T18:23:44.5714480Z     filename, mod_ast = loader.load_module(namespace, module_name)
2023-01-12T18:23:44.5715065Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/imports/typeshed.py", line 454, in load_module
2023-01-12T18:23:44.5715578Z     ast = parser.parse_string(src, filename=filename, name=module_name,
2023-01-12T18:23:44.5716170Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/parser.py", line 792, in parse_string
2023-01-12T18:23:44.5716609Z     return parse_pyi(src, filename=filename, module_name=name, options=options)
2023-01-12T18:23:44.5717195Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/parser.py", line 807, in parse_pyi
2023-01-12T18:23:44.5717547Z     root = gen_pytd.visit(root)
2023-01-12T18:23:44.5718056Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 31, in visit
2023-01-12T18:23:44.5718400Z     ret = self.visit(v)
2023-01-12T18:23:44.5718895Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 40, in visit
2023-01-12T18:23:44.5719233Z     ret = self.visit(v)
2023-01-12T18:23:44.5719722Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 34, in visit
2023-01-12T18:23:44.5720068Z     out = self._call_visitor(node)
2023-01-12T18:23:44.5720646Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/visitor.py", line 38, in _call_visitor
2023-01-12T18:23:44.5721119Z     raise ParseError.from_exc(e).at(node, self.filename, self.src_code)
2023-01-12T18:23:44.5721708Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/visitor.py", line 36, in _call_visitor
2023-01-12T18:23:44.5722066Z     return super()._call_visitor(node)
2023-01-12T18:23:44.5722600Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 55, in _call_visitor
2023-01-12T18:23:44.5722954Z     return visitor(node)
2023-01-12T18:23:44.5723490Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/parser.py", line 376, in visit_FunctionDef
2023-01-12T18:23:44.5723870Z     self._preprocess_function(node)
2023-01-12T18:23:44.5724429Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/parser.py", line 370, in _preprocess_function
2023-01-12T18:23:44.5724825Z     node.args = self.convert_node(node.args)
2023-01-12T18:23:44.5725367Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/parser.py", line 315, in convert_node
2023-01-12T18:23:44.5725755Z     ret = self.annotation_visitor.visit(node)
2023-01-12T18:23:44.5726283Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 31, in visit
2023-01-12T18:23:44.5726611Z     ret = self.visit(v)
2023-01-12T18:23:44.5727103Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 40, in visit
2023-01-12T18:23:44.5727443Z     ret = self.visit(v)
2023-01-12T18:23:44.5727932Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/ast/visitor.py", line 34, in visit
2023-01-12T18:23:44.5728284Z     out = self._call_visitor(node)
2023-01-12T18:23:44.5728809Z   File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pytype/pyi/visitor.py", line 38, in _call_visitor
2023-01-12T18:23:44.5729274Z     raise ParseError.from_exc(e).at(node, self.filename, self.src_code)
2023-01-12T18:23:44.5729713Z pytype.pyi.types.ParseError:   File: "/home/runner/work/typeshed/typeshed/stdlib/email/header.pyi", line 26
2023-01-12T18:23:44.5730073Z ParseError: list index out of range

@JelleZijlstra
Copy link
Contributor Author

The CI failure seems spurious, some package failed to download.

@JelleZijlstra JelleZijlstra marked this pull request as ready for review January 13, 2023 01:11
Copy link
Contributor

@martindemello martindemello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, looks good! we'll merge it internally and push back to github.

martindemello pushed a commit that referenced this pull request Jan 13, 2023
martindemello pushed a commit that referenced this pull request Jan 13, 2023
@JelleZijlstra JelleZijlstra deleted the strdefault branch January 13, 2023 17:01
@JelleZijlstra JelleZijlstra restored the strdefault branch September 10, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants