facebook / facebook/pyrefly

Different results depending on how `pyrefly` is called

Open
#1,226 4 comments 1 reaction 0 assignees View on GitHub
needs-discussion pydantic
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

I used the following to set up an environment:

```
python3 -m venv .venv
. .venv/bin/activate
pip install pyrefly pydantic
touch test.py
```

Into the `test.py` I put the following content:

```python
from pydantic import BaseModel, Field
from pydantic.config import ConfigDict

class Example(BaseModel):
id: str
some_attribute: str = Field("", alias="someAttribute")
optional_attribute: str | None = Field(None, alias="optionalAttribute")

model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)

entry1 = Example(id="1", some_attribute="value")
entry2 = Example(id="1", someAttribute="value")
```

The behavior of pyrefly seems a bit different depending on how it is called:
- With `pyrefly check test.py` I get `INFO 0 errors`
- With `pyrefly check .` I get `INFO 0 errors`
- With `pyrefly check` I get:

```
ERROR Missing argument `someAttribute` in function `Example.__init__` [missing-argument]
--> test.py:12:17
|
12 | entry1 = Example(id="1", some_attribute="value")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
```

Shouldn't all three versions return the same result, namely `INFO 0 errors`?

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