pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Strict mode

Open nth10sd opened this issue 7 months ago • 1 comments

Describe the Bug

mypy has strict mode, and pyright / basedpyright also have various modes (e.g. "strict", "standard"). Will pyrefly consider having this as well?

This is to account for different preferences in the level of strictness for type checkers.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

nth10sd avatar May 28 '25 00:05 nth10sd

Yes! We plan to have a strict mode.

We're still figuring out exactly what it should do. But my broad thinking is:

  • Gradual: Everything gets inferred to be Any. You rarely get a type error without an annotation.
  • Standard: We infer return types and list types.
  • Strict: We error if we can't infer with reasonable precision (e.g. if we infer an Any).

ndmitchell avatar May 28 '25 08:05 ndmitchell

Merging https://github.com/facebook/pyrefly/issues/1295 into this issue. Some things we'll likely want in strict mode:

  • implicit-any (see https://github.com/facebook/pyrefly/commit/a01efe55997c6ec89417c367b58ab337725fd133 and https://github.com/facebook/pyrefly/commit/e6eaf1f06df0c908ae3b9bfac9fd4c908e74fe70).
  • Error on unpacking an open TypedDict into another TypedDict (see https://github.com/facebook/pyrefly/issues/1351#issuecomment-3464392546).

rchen152 avatar Oct 29 '25 22:10 rchen152