Skip to content

Commit 643e777

Browse files
committed
Fix incompatibility with python < 3.12 and factory-boy < 3.3
1 parent d8bdab5 commit 643e777

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Removed
2424

2525
Fixed
2626
+++++
27+
* Fix incompatibility when using the combination of python < 3.12 and factory-boy < 3.3
2728

2829
Security
2930
++++++++

src/pytest_factoryboy/fixture.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,14 @@ def model_fixture(request: SubRequest, factory_name: str) -> object:
368368

369369
factory_class: type[Factory[object]] = request.getfixturevalue(factory_name)
370370

371-
# Create model fixture instance
372-
NewFactory: type[Factory[object]] = cast(type[Factory[object]], type("Factory", (factory_class,), {}))
371+
# create Factory override for the model fixture
372+
NewFactory: type[Factory[object]] = type("Factory", (factory_class,), {})
373373
# equivalent to:
374374
# class Factory(factory_class):
375375
# pass
376+
# NewFactory = Factory
377+
# del Factory
378+
376379
# it just makes mypy understand it.
377380

378381
NewFactory._meta.base_declarations = {

0 commit comments

Comments
 (0)