Open jamesbraza opened 2 months ago
master
import asyncio from pydantic import BaseModel, Field class Foo(BaseModel): start_time: float = Field( default_factory=lambda: asyncio.get_running_loop().time() )
This code with refurb will want to be Field(default_factory=asyncio.get_running_loop().time) per FURB111.
refurb
Field(default_factory=asyncio.get_running_loop().time)
FURB111
The issue is that asyncio.get_running_loop can throw RuntimeError: no running event loop depending on when it's invoked.
asyncio.get_running_loop
RuntimeError: no running event loop
So the bug report is that if asyncio.get_running_loop is part of a factory, perhaps FURB111 should not be raised.
Refurb: v2.0.0 Mypy: v1.10.0
Python 3.12.3
# N/A
None
Has your issue already been fixed?
master
branch? See the docs for instructions on how to setup a local build of Refurb.The Bug
This code with
refurb
will want to beField(default_factory=asyncio.get_running_loop().time)
perFURB111
.The issue is that
asyncio.get_running_loop
can throwRuntimeError: no running event loop
depending on when it's invoked.So the bug report is that if
asyncio.get_running_loop
is part of a factory, perhapsFURB111
should not be raised.Version Info
Python Version
Python 3.12.3
Config File
Extra Info
None