facebook / facebook/pyrefly

Incorrect value for "infer-with-first-use" from pyrefly init on strict pyright config

Open
#3,393 2 comments 0 reactions 0 assignees View on GitHub
configuration question
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

I have the following pyright config:

```
[tool.pyright]
include = ["src"]
exclude = ["tests"]
typeCheckingMode = "strict"
deprecateTypingAliases = true
reportCallInDefaultInitializer = "error"
reportDeprecated = "error"
reportImplicitOverride = "error"
reportImportCycles = "error"
reportPropertyTypeMismatch = "error"
reportUnreachable = "error"
reportUnnecessaryTypeIgnoreComment = "error"
reportMissingSuperCall = "none"
reportUninitializedInstanceVariable = "none"
reportImplicitStringConcatenation = "none"

```

and ran `pyrefly init` and it produced this config

```
[tool.pyrefly]
project-includes = ["src"]
project-excludes = ["tests"]
infer-with-first-use = false

[tool.pyrefly.errors]
implicitly-defined-attribute = "ignore"
deprecated = "error"

```

(note that additionally the tool.pyrefly section was at the very bottom of the pyproject.toml while the error one was somewhere in the middle in a fairly random place)

I think that is not correct, specifically the `infer-with-first-use` because pyright does not infer that as `list[Any]` but `list[Unknown]` and if `reportUnknownMemberType ` is enabled we get errors there.

https://pyright-play.net/?pythonVersion=3.12&locale=en-us&reportUnknownMemberType=true&code=B4AgvCDaC6CwBQwB0BDADmgpgOwCYAoBGASgWXSz3wCIAma4oA

### Sandbox Link

_No response_

### (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.