facebook / pyre-check

Performant type-checking for python.
https://pyre-check.org/
MIT License
6.79k stars 432 forks source link

[pysa][MLH] Hide warnings about high number of overrides #870

Open arthaud opened 3 months ago

arthaud commented 3 months ago

When going through the pysa tutorial, users currently get these warnings:

ƛ  `libcst._nodes.base.CSTNode._codegen_impl` has 102 overrides, this might slow down the analysis considerably.
ƛ  `libcst._nodes.base.CSTNode._visit_and_replace_children` has 119 overrides, this might slow down the analysis considerably.
ƛ  `object.__eq__` has 371 overrides, this might slow down the analysis considerably.
ƛ  `object.__hash__` has 204 overrides, this might slow down the analysis considerably.
ƛ  `object.__init__` has 1811 overrides, this might slow down the analysis considerably.
ƛ  `object.__ne__` has 83 overrides, this might slow down the analysis considerably.
ƛ  `object.__repr__` has 340 overrides, this might slow down the analysis considerably.
ƛ  `object.__setattr__` has 59 overrides, this might slow down the analysis considerably.
ƛ  `object.__str__` has 110 overrides, this might slow down the analysis considerably.
ƛ  `type.__call__` has 289 overrides, this might slow down the analysis considerably.
ƛ  `type.__init__` has 1468 overrides, this might slow down the analysis considerably.
ƛ  `type.__new__` has 259 overrides, this might slow down the analysis considerably.
ƛ  `type.__or__` has 84 overrides, this might slow down the analysis considerably.
ƛ  `type.__ror__` has 52 overrides, this might slow down the analysis considerably.
ƛ  `typing.Collection.__len__` has 89 overrides, this might slow down the analysis considerably.
ƛ  `typing.GenericMeta.__getitem__` has 56 overrides, this might slow down the analysis considerably.
ƛ  `typing.Iterable.__iter__` has 82 overrides, this might slow down the analysis considerably.
ƛ  `typing.Iterator.__iter__` has 58 overrides, this might slow down the analysis considerably.
ƛ  `typing.Iterator.__next__` has 62 overrides, this might slow down the analysis considerably.
ƛ  `typing.Mapping.__getitem__` has 54 overrides, this might slow down the analysis considerably.
ƛ  `typing.NamedTuple.__init__` has 165 overrides, this might slow down the analysis considerably.

This is because classes with a lot of overrides can lead to slow down of the analysis, since Pysa needs to analyze each override. To avoid this, we usually set the "maximum_overrides_to_analyze" option: https://pyre-check.org/docs/pysa-advanced/#ignoring-overrides

Anyway, this can be pretty confusing to a new user. Here is what we should do: