You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Xoogler here, love this tool! I’m trying to write Bazel rules to run pytype which don’t seem to exist as open-source. My current solution effectively ends up running pytype from scratch on each py_library which scales poorly. Does anyone have a solution to this?
I’m imagining a way for the bazel rule impl to run pytype incrementally on one .py file plus the .pyi of the dependencies that bazel previously orchestrated inferring IOW skip analyze_project/ninja. The difficulty with using pytype-single is imports that we don’t want to infer e.g. because they are from @pypi, etc. analyze_project writes default.pyi entries for these in the imports file but with pytype-single these are just missing imports. pytype-single --disable=import-error seems to get around this but I’m not sure if this is actually doing what I want?
The text was updated successfully, but these errors were encountered:
pytype-single will need an imports info file with the paths to the pyi files for all dependencies of the target file. you will likely need to have your bazel file recursively analyse dependencies the same way analyze_project does, and supply a default pyi for any missing ones.
Thanks Martin! It seems like there are (at least) 2 ways this could work:
1: run pytype-single with --pythonpath pointed at the tree of .pyi files. pytype throws import-error on the missing imports but this doesn't seem to be fatal, it seems to still infer the input and write the .pyi and if you pass --disable=import-error, it will exit(0) if there aren't any other errors. I'm not familiar enough with the pytype internals to know if this is degrading it in some more subtle way. Possibly there could be a command-line option to provide a default.pyi to use for missing imports?
2: run pytype-single with --imports_info. I had hoped that I could write a ~1-liner with importlab to generate the imports file but it seems like there's a lot more code in analyze_project that you need. If I was going to go this route, I would want to just run PytypeRunner.run() up to setup_build() to generate the imports file rather than try to reproduce all of that logic.
Xoogler here, love this tool! I’m trying to write Bazel rules to run pytype which don’t seem to exist as open-source. My current solution effectively ends up running pytype from scratch on each py_library which scales poorly. Does anyone have a solution to this?
I’m imagining a way for the bazel rule impl to run pytype incrementally on one .py file plus the .pyi of the dependencies that bazel previously orchestrated inferring IOW skip analyze_project/ninja. The difficulty with using pytype-single is imports that we don’t want to infer e.g. because they are from @pypi, etc. analyze_project writes default.pyi entries for these in the imports file but with pytype-single these are just missing imports. pytype-single --disable=import-error seems to get around this but I’m not sure if this is actually doing what I want?
The text was updated successfully, but these errors were encountered: