facebook / facebook/pyrefly

No attribute error when writing to a builtin defined in builtins.pyi

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

Description

### Describe the Bug

With the following files:
```
~/t/pyrefly_builtins $ cat test.py
import builtins
print(globalVar)
builtins.globalVar=1

~/t/pyrefly_builtins $ cat __builtins__.pyi
globalVar: int
```

`globalVar` is correctly inferred as an int in the second line, but the third line emits an error

### Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pZRBDoQgDEWv0sQFOzuz9RRzgNngjEESIkbQ8_spYqKJbtwWWsp_7b-yzG3z2tm6iDlJsmd5jfOtdnAtQVHO6z2MLt8v6e-kTkWfHKDtIfgCZDUz3Ady1d-hgvF01Mc4hoa5pPvJcDfw3_8CHzKY0iDoRVvxtGM58kIzoOwTLCpTUXdQVGKCG0KhCCIkLL69C9NgXOMtixU

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