Skip to content

Commit

Permalink
Update the FAQ with more tips about what to do when pytype is slow.
Browse files Browse the repository at this point in the history
I've repeated these tips a few times now, so might as well put them in the faq.

PiperOrigin-RevId: 331240749
  • Loading branch information
rchen152 committed Sep 14, 2020
1 parent 66d160c commit 702b8c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* [How do I disable all pytype checks for a particular import?](#how-do-i-disable-all-pytype-checks-for-a-particular-import)
* [How do I write code that is seen by pytype but ignored at runtime?](#how-do-i-write-code-that-is-seen-by-pytype-but-ignored-at-runtime)

<!-- Added by: mdemello, at: 2020-08-10T13:15-07:00 -->
<!-- Added by: rechen, at: 2020-09-11T15:57-07:00 -->

<!--te-->

Expand Down Expand Up @@ -140,12 +140,17 @@ that `LoggerMixin` should only be mixed into classes that implement `name`.

If pytype is taking a long time on a file, the easiest workaround is to
[disable][how-do-i-disable-all-pytype-checks-for-a-particular-file] it with a
`skip-file` directive. Otherwise, there are two things you can try to speed up
`skip-file` directive. Otherwise, there are a few things you can try to speed up
the analysis:

* Split up the file. Anecdotally, pytype gets noticeable slower once a file
grows past ~1500 lines.
* Annotate the return types of functions to speed up inference.
* Simplify function inputs (e.g., by reducing the number of types in unions) to
speed up checking.
* Avoid large concrete data structures (e.g., a module-level dict of a hundred
constants). pytype tracks individual values for some builtin data structures,
which can quickly get unwieldy.

## How do I disable all pytype checks for a particular file?

Expand Down

0 comments on commit 702b8c9

Please sign in to comment.