chore: take Python<'_>
as a parameter instead of &Python
This commit is contained in:
@@ -19,25 +19,25 @@ impl<'source> FromPyObject<'source> for HomeAssistant {
|
||||
|
||||
impl HomeAssistant {
|
||||
/// Return the representation
|
||||
pub fn repr(&self, py: &Python) -> Result<String, PyErr> {
|
||||
let bound = self.0.bind(*py);
|
||||
pub fn repr(&self, py: Python<'_>) -> Result<String, PyErr> {
|
||||
let bound = self.0.bind(py);
|
||||
let repr = bound.repr()?;
|
||||
repr.extract()
|
||||
}
|
||||
|
||||
/// Return if Home Assistant is running.
|
||||
pub fn is_running(&self, py: &Python) -> Result<bool, PyErr> {
|
||||
let is_running = self.0.getattr(*py, "is_running")?;
|
||||
is_running.extract(*py)
|
||||
pub fn is_running(&self, py: Python<'_>) -> Result<bool, PyErr> {
|
||||
let is_running = self.0.getattr(py, "is_running")?;
|
||||
is_running.extract(py)
|
||||
}
|
||||
/// Return if Home Assistant is stopping.
|
||||
pub fn is_stopping(&self, py: &Python) -> Result<bool, PyErr> {
|
||||
let is_stopping = self.0.getattr(*py, "is_stopping")?;
|
||||
is_stopping.extract(*py)
|
||||
pub fn is_stopping(&self, py: Python<'_>) -> Result<bool, PyErr> {
|
||||
let is_stopping = self.0.getattr(py, "is_stopping")?;
|
||||
is_stopping.extract(py)
|
||||
}
|
||||
|
||||
pub fn states(&self, py: &Python) -> Result<StateMachine, PyErr> {
|
||||
let states = self.0.getattr(*py, "states")?;
|
||||
states.extract(*py)
|
||||
pub fn states(&self, py: Python<'_>) -> Result<StateMachine, PyErr> {
|
||||
let states = self.0.getattr(py, "states")?;
|
||||
states.extract(py)
|
||||
}
|
||||
}
|
||||
|
@@ -23,11 +23,11 @@ impl<'py> FromPyObject<'py> for StateMachine {
|
||||
impl StateMachine {
|
||||
pub fn get<Attributes: for<'py> FromPyObject<'py>, ContextEvent: for<'py> FromPyObject<'py>>(
|
||||
&self,
|
||||
py: &Python,
|
||||
py: Python<'_>,
|
||||
entity_id: EntityId,
|
||||
) -> Result<Option<State<Attributes, ContextEvent>>, PyErr> {
|
||||
) -> PyResult<Option<State<Attributes, ContextEvent>>> {
|
||||
let args = (entity_id.to_string(),);
|
||||
let state = self.0.call_method1(*py, "get", args)?;
|
||||
state.extract(*py)
|
||||
let state = self.0.call_method1(py, "get", args)?;
|
||||
state.extract(py)
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ async fn real_main(home_assistant: HomeAssistant) -> ! {
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
fn main<'p>(py: Python<'p>, home_assistant: HomeAssistant) -> PyResult<Bound<'p, PyAny>> {
|
||||
fn main<'py>(py: Python<'py>, home_assistant: HomeAssistant) -> PyResult<Bound<'py, PyAny>> {
|
||||
pyo3_async_runtimes::tokio::future_into_py::<_, ()>(py, async {
|
||||
real_main(home_assistant).await;
|
||||
})
|
||||
|
Reference in New Issue
Block a user