bump pyo3 from 0.20 to 0.21
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
use pyo3::{exceptions::PyTypeError, pyclass, pymethods, types::PyDict, PyRef, PyResult};
|
||||
use pyo3::{
|
||||
exceptions::PyTypeError,
|
||||
pyclass, pymethods,
|
||||
types::{PyAnyMethods, PyDict},
|
||||
Bound, PyRef, PyResult,
|
||||
};
|
||||
use rosu_pp::model::beatmap::{BeatmapAttributes, BeatmapAttributesBuilder, HitWindows};
|
||||
|
||||
use crate::{beatmap::PyBeatmap, error::ArgsError, mode::PyGameMode};
|
||||
@@ -24,14 +29,14 @@ pub struct PyBeatmapAttributesBuilder {
|
||||
impl PyBeatmapAttributesBuilder {
|
||||
#[new]
|
||||
#[pyo3(signature = (**kwargs))]
|
||||
fn new(kwargs: Option<&PyDict>) -> PyResult<Self> {
|
||||
fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
|
||||
let mut this = Self::default();
|
||||
|
||||
let Some(kwargs) = kwargs else {
|
||||
return Ok(this);
|
||||
};
|
||||
|
||||
for (key, value) in kwargs.iter() {
|
||||
for (key, value) in kwargs {
|
||||
match key.extract()? {
|
||||
"map" => {
|
||||
let map = value
|
||||
|
||||
+8
-3
@@ -1,6 +1,11 @@
|
||||
use std::{error::Error as StdError, fmt::Write};
|
||||
|
||||
use pyo3::{exceptions::PyTypeError, pyclass, pymethods, types::PyDict, PyResult};
|
||||
use pyo3::{
|
||||
exceptions::PyTypeError,
|
||||
pyclass, pymethods,
|
||||
types::{PyAnyMethods, PyDict},
|
||||
Bound, PyResult,
|
||||
};
|
||||
use rosu_pp::{
|
||||
model::{
|
||||
hit_object::HitObjectKind,
|
||||
@@ -23,7 +28,7 @@ pub struct PyBeatmap {
|
||||
impl PyBeatmap {
|
||||
#[new]
|
||||
#[pyo3(signature = (**kwargs))]
|
||||
fn new(kwargs: Option<&PyDict>) -> PyResult<Self> {
|
||||
fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
|
||||
let Some(kwargs) = kwargs else {
|
||||
return Err(ArgsError::new_err(
|
||||
"kwarg 'path', 'bytes', or 'content' must be specified",
|
||||
@@ -32,7 +37,7 @@ impl PyBeatmap {
|
||||
|
||||
let mut map_res = None;
|
||||
|
||||
for (key, value) in kwargs.iter() {
|
||||
for (key, value) in kwargs {
|
||||
match key.extract()? {
|
||||
"path" => {
|
||||
let path = value
|
||||
|
||||
+8
-3
@@ -1,4 +1,9 @@
|
||||
use pyo3::{exceptions::PyTypeError, pyclass, pymethods, types::PyDict, PyResult};
|
||||
use pyo3::{
|
||||
exceptions::PyTypeError,
|
||||
pyclass, pymethods,
|
||||
types::{PyAnyMethods, PyDict},
|
||||
Bound, PyResult,
|
||||
};
|
||||
use rosu_pp::Difficulty;
|
||||
|
||||
use crate::{
|
||||
@@ -31,14 +36,14 @@ pub struct PyDifficulty {
|
||||
impl PyDifficulty {
|
||||
#[new]
|
||||
#[pyo3(signature = (**kwargs))]
|
||||
fn new(kwargs: Option<&PyDict>) -> PyResult<Self> {
|
||||
fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
|
||||
let mut this = Self::default();
|
||||
|
||||
let Some(kwargs) = kwargs else {
|
||||
return Ok(this);
|
||||
};
|
||||
|
||||
for (key, value) in kwargs.iter() {
|
||||
for (key, value) in kwargs {
|
||||
match key.extract()? {
|
||||
"mods" => {
|
||||
this.mods = value
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
use error::ConvertError;
|
||||
use performance::PyHitResultPriority;
|
||||
use pyo3::{pymodule, types::PyModule, PyResult, Python};
|
||||
use pyo3::{pymodule, types::PyModule, Bound, PyResult, Python};
|
||||
|
||||
use self::{
|
||||
attributes::{
|
||||
@@ -32,7 +32,7 @@ mod score_state;
|
||||
mod strains;
|
||||
|
||||
#[pymodule]
|
||||
fn rosu_pp_py(py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||
fn rosu_pp_py(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_class::<PyBeatmap>()?;
|
||||
m.add_class::<PyDifficulty>()?;
|
||||
m.add_class::<PyPerformance>()?;
|
||||
@@ -49,9 +49,9 @@ fn rosu_pp_py(py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||
m.add_class::<PyPerformanceAttributes>()?;
|
||||
m.add_class::<PyStrains>()?;
|
||||
|
||||
m.add("ParseError", py.get_type::<ParseError>())?;
|
||||
m.add("ArgsError", py.get_type::<ArgsError>())?;
|
||||
m.add("ConvertError", py.get_type::<ConvertError>())?;
|
||||
m.add("ParseError", py.get_type_bound::<ParseError>())?;
|
||||
m.add("ArgsError", py.get_type_bound::<ArgsError>())?;
|
||||
m.add("ConvertError", py.get_type_bound::<ConvertError>())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+10
-7
@@ -1,4 +1,9 @@
|
||||
use pyo3::{exceptions::PyTypeError, pyclass, pymethods, types::PyDict, PyAny, PyRef, PyResult};
|
||||
use pyo3::{
|
||||
exceptions::PyTypeError,
|
||||
pyclass, pymethods,
|
||||
types::{PyAnyMethods, PyDict},
|
||||
Bound, PyAny, PyRef, PyResult,
|
||||
};
|
||||
use rosu_pp::{
|
||||
any::{DifficultyAttributes, HitResultPriority},
|
||||
Difficulty, Performance,
|
||||
@@ -41,14 +46,14 @@ pub struct PyPerformance {
|
||||
impl PyPerformance {
|
||||
#[new]
|
||||
#[pyo3(signature = (**kwargs))]
|
||||
fn new(kwargs: Option<&PyDict>) -> PyResult<Self> {
|
||||
fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
|
||||
let mut this = Self::default();
|
||||
|
||||
let Some(kwargs) = kwargs else {
|
||||
return Ok(this);
|
||||
};
|
||||
|
||||
for (key, value) in kwargs.iter() {
|
||||
for (key, value) in kwargs {
|
||||
match key.extract()? {
|
||||
"mods" => {
|
||||
this.mods = value
|
||||
@@ -175,13 +180,11 @@ impl PyPerformance {
|
||||
)
|
||||
}
|
||||
"hitresult_priority" => {
|
||||
let priority: PyHitResultPriority = value.extract().map_err(|_| {
|
||||
this.hitresult_priority = value.extract().map_err(|_| {
|
||||
PyTypeError::new_err(
|
||||
"kwarg 'hitresult_priority': must be a HitResultPriority",
|
||||
)
|
||||
})?;
|
||||
|
||||
this.hitresult_priority = priority.into()
|
||||
}
|
||||
kwarg => {
|
||||
let err = format!(
|
||||
@@ -201,7 +204,7 @@ impl PyPerformance {
|
||||
Ok(this)
|
||||
}
|
||||
|
||||
fn calculate(&self, args: &PyAny) -> PyResult<PyPerformanceAttributes> {
|
||||
fn calculate(&self, args: &Bound<'_, PyAny>) -> PyResult<PyPerformanceAttributes> {
|
||||
let _map;
|
||||
|
||||
let mut perf = if let Ok(attrs) = args.extract::<PyPerformanceAttributes>() {
|
||||
|
||||
+7
-2
@@ -1,6 +1,11 @@
|
||||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
||||
use pyo3::{exceptions::PyTypeError, pyclass, types::PyDict, PyResult};
|
||||
use pyo3::{
|
||||
exceptions::PyTypeError,
|
||||
pyclass,
|
||||
types::{PyAnyMethods, PyDict},
|
||||
Bound, PyResult,
|
||||
};
|
||||
use rosu_pp::any::ScoreState;
|
||||
|
||||
use crate::error::ArgsError;
|
||||
@@ -28,7 +33,7 @@ pub struct PyScoreState {
|
||||
impl PyScoreState {
|
||||
#[new]
|
||||
#[pyo3(signature = (**kwargs))]
|
||||
fn new(kwargs: Option<&PyDict>) -> PyResult<Self> {
|
||||
fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
|
||||
let mut this = Self::default();
|
||||
|
||||
let Some(kwargs) = kwargs else {
|
||||
|
||||
Reference in New Issue
Block a user