Skip to content

Commit

Permalink
Merge pull request #276 from WorksApplications/feature/update-pyo3-v022
Browse files Browse the repository at this point in the history
Update pyo3 to v0.22
  • Loading branch information
mh-northlander authored Nov 19, 2024
2 parents e158aeb + 387a582 commit ea794e3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 75 deletions.
79 changes: 13 additions & 66 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ name = "sudachipy"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.21", features = ["extension-module"] }
pyo3 = { version = "0.22", features = ["extension-module"] }
scopeguard = "1" # Apache 2.0/MIT
thread_local = "1.1" # Apache 2.0/MIT

Expand Down
10 changes: 8 additions & 2 deletions python/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ fn create_file(p: &Path) -> std::io::Result<File> {
/// :type output: pathlib.Path | str
/// :type description: str
#[pyfunction]
#[pyo3(text_signature = "(matrix, lex, output, description=None) -> list[tuple[str, int, float]]")]
#[pyo3(
signature = (matrix, lex, output, description=None),
text_signature = "(matrix, lex, output, description=None) -> list[tuple[str, int, float]]",
)]
fn build_system_dic<'py>(
py: Python<'py>,
matrix: &Bound<'py, PyAny>,
Expand Down Expand Up @@ -120,7 +123,10 @@ fn build_system_dic<'py>(
/// :type output: pathlib.Path | str
/// :type description: str
#[pyfunction]
#[pyo3(text_signature = "(system, lex, output, description=None) -> list[tuple[str, int, float]]")]
#[pyo3(
signature = (system, lex, output, description=None),
text_signature = "(system, lex, output, description=None) -> list[tuple[str, int, float]]",
)]
fn build_user_dic<'py>(
py: Python<'py>,
system: &Bound<'py, PyAny>,
Expand Down
5 changes: 4 additions & 1 deletion python/src/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ impl PyDictionary {
///
/// :type surface: str
/// :type out: MorphemeList | None
#[pyo3(text_signature = "(self, /, surface, out=None) -> MorphemeList")]
#[pyo3(
signature = (surface, out=None),
text_signature = "(self, /, surface, out=None) -> MorphemeList",
)]
fn lookup<'py>(
&'py self,
py: Python<'py>,
Expand Down
7 changes: 5 additions & 2 deletions python/src/morpheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl PyMorphemeIter {
}

let morpheme = PyMorpheme {
list: self.list.clone(),
list: self.list.clone_ref(py),
index: self.index,
};

Expand Down Expand Up @@ -364,7 +364,10 @@ impl PyMorpheme {
/// :type mode: SplitMode | None
/// :type out: MorphemeList | None
/// :type add_single: bool
#[pyo3(text_signature = "(self, /, mode, out=None, add_single=False) -> MorphemeList")]
#[pyo3(
signature = (mode, out=None, add_single=false),
text_signature = "(self, /, mode, out=None, add_single=False) -> MorphemeList",
)]
fn split<'py>(
&'py self,
py: Python<'py>,
Expand Down
6 changes: 3 additions & 3 deletions python/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::morpheme::{PyMorphemeListWrapper, PyProjector};
/// If None, returns SplitMode.C.
///
/// :type mode: str | None
#[pyclass(module = "sudachipy.tokenizer", name = "SplitMode", frozen)]
#[pyclass(module = "sudachipy.tokenizer", name = "SplitMode", eq, eq_int, frozen)]
#[derive(Clone, PartialEq, Eq, Copy, Debug)]
#[repr(u8)]
pub enum PySplitMode {
Expand Down Expand Up @@ -79,8 +79,8 @@ impl PySplitMode {
/// :type mode: str | None
#[new]
#[pyo3(
text_signature="(mode=None) -> SplitMode",
signature=(mode=None)
signature = (mode=None),
text_signature = "(mode=None) -> SplitMode"
)]
fn new(mode: Option<&str>) -> PyResult<PySplitMode> {
let mode = match mode {
Expand Down

0 comments on commit ea794e3

Please sign in to comment.