Skip to content

Support bare factory-boy factory calls returning the model type#3961

Open
ak4-sh wants to merge 1 commit into
facebook:mainfrom
ak4-sh:factory-boy-bare-generic-err
Open

Support bare factory-boy factory calls returning the model type#3961
ak4-sh wants to merge 1 commit into
facebook:mainfrom
ak4-sh:factory-boy-bare-generic-err

Conversation

@ak4-sh

@ak4-sh ak4-sh commented Jun 27, 2026

Copy link
Copy Markdown

Calling a DjangoModelFactory subclass directly (UserFactory()) is equivalent to UserFactory.create() at runtime via FactoryMetaClass, but Pyrefly typed it as an instance of the factory rather than the model, producing false missing-attribute errors on every field access.

Add tests to confirim correct behaviour

Fixes #3934

Test Plan

Add 2 tests:

  • test_bare_call_attribute_access
  • test_bare_call_returns_model
Calling a DjangoModelFactory subclass directly (`UserFactory()`) is
equivalent to `UserFactory.create()` at runtime via FactoryMetaClass,
but Pyrefly typed it as an instance of the factory rather than the
model, producing false missing-attribute errors on every field access.

Add tests to confirim correct behaviour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant