facebook / facebook/pyrefly

`Unfinished Variable::Quantified: T` in factory-boy's LazyAttribute

Open
#4,547 1 comment 0 reactions 1 assignee Claimed by @rchen152 View on GitHub
django stale
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

I have code like this, using django and factory-boy. The specific django model has two FKs, which both have the identical attr. In the example below that obviously complains about SomeModel not existing as well, but in my real world case those imports are fine.

```
import factory.django

class SomeFactory(factory.django.DjangoModelFactory[SomeModel]):
attr_match = factory.LazyAttribute(
lambda obj: (
obj.fk_1.attr == obj.fk_2.attr
if obj.fk_1 is not None and obj.fk_2 is not None
else False
)
)

class Meta:
model = SomeModel
```

When I run pyrefly check on 1.2.0, I get the following error:
```
ERROR Unfinished Variable::Quantified: T [internal-error]
--> src/min_rep.py:7:32
|
7 | if obj.fk_1 is not None and obj.fk_2 is not None
| ^^^^
|
Sorry, Pyrefly encountered an internal error, this is always a bug in Pyrefly itself
Please report the bug at https://github.com/facebook/pyrefly/issues/new
```

### Sandbox Link

Sandbox doesn't have factory-boy installed

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