facebook / facebook/pyrefly

deprecated warning is too noisy

Open
#2,042 3 comments 0 reactions 0 assignees View on GitHub
needs-discussion typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```py
from warnings import deprecated

@deprecated("use baz instead")
def foo() -> None:
pass

@deprecated("use qux instead")
def bar() -> None:
foo()
```

Pyrefly reports:
```
WARN sandbox.py:9:5-8: `foo` is deprecated [[deprecated](https://pyrefly.org/en/docs/error-kinds/#deprecated)]
use baz instead
```

This warning is actively harmful. When working with deprecated APIs, a number of common patterns emerge:
- _Tests of_ the deprecated API need to continue to use it, so that it doesn't just bit-rot and stop working while end users are not yet fully migrated.
- _Other deprecated APIs_ may need to make calls to the deprecated API: for example, if a core function is deprecated, it will still need to be called by deprecated convenience functions that wrap it.

Warning for these kinds of usage actively contributes to [alarm fatigue](https://en.wikipedia.org/wiki/Alarm_fatigue).

Instead, Pyrefly should only warn about:
- _cross-module uses_ of deprecated APIs, and
- _non-test_ uses of deprecated APIs in implementations of _non-deprecated_ APIs.

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEA7qpehOgOZx0Q3G6UAXOphjFKMAMaoBMTAB10CgAIixk6bIAUckAFc4MOtlQAvbujgzU8kAEoFIsHTC5cm23QC0APjoA5XHQYRAU6MLpiVDg4BWVVcSkZTG09AzoAR118c0sYax17LBgnY0p3L18AoJD0cOdXdwUQABo9AWg4EnJEEABiOgBVdqgIAVJnXXQJdsCYxSKnF0oaaQB9dF0abBgy-ERzAQ8fOktKGrrxAV0WZx0-Te2zumB8AF8dJtaycTAoUkIBLQoBR%2BgAFUg-P4nDA4Ah0CSBSDsa7SCCBQgKfoAZRghgAFgIBMQ4IgAPSk77FP6EfjsUkwdCkzC4CRwUkI9BIlEzRn1Sh0VAAN1Q0FQ2Fg8MREGRlFRgTouGIPM6CjIAjxgU8gp2cDRtQAvHQdABmQgARmNH3QIFerVQ0wg2oAYtAYBQ0Fg8EQyDagA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.