Skip to content

Commit cbf93d1

Browse files
fix(deps): update rust crate pyo3 to 0.22.0 (#741)
* fix(deps): update rust crate pyo3 to 0.22.0 * fix: define signature for `Option` See https://pyo3.rs/v0.22.0/function/signature#using-pyo3signature-- * fix: use `Vec<String>` in Python functions --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Mathieu Kniewallner <mathieu.kniewallner@gmail.com>
1 parent 452ceef commit cbf93d1

5 files changed

Lines changed: 19 additions & 84 deletions

File tree

Cargo.lock

Lines changed: 13 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ encoding_rs = "0.8.34"
1414
ignore = "0.4.22"
1515
log = "0.4.22"
1616
path-slash = "0.2.1"
17-
pyo3 = { version = "0.21.2", features = ["abi3-py38"] }
17+
pyo3 = { version = "0.22.0", features = ["abi3-py38"] }
1818
pyo3-log = "0.11.0"
1919
rayon = "1.10.0"
2020
regex = "1.10.5"

src/imports/ipynb.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use file_utils::read_file;
55
use location::Location;
66
use pyo3::exceptions::PySyntaxError;
77
use pyo3::prelude::*;
8-
use pyo3::types::PyString;
98
use rayon::prelude::*;
109
use std::collections::HashMap;
1110

@@ -14,13 +13,8 @@ use super::shared;
1413
/// Processes multiple Python files in parallel to extract import statements and their locations.
1514
/// Accepts a list of file paths and returns a dictionary mapping module names to their import locations.
1615
#[pyfunction]
17-
pub fn get_imports_from_ipynb_files(py: Python, file_paths: Vec<&PyString>) -> PyResult<PyObject> {
18-
let rust_file_paths: Vec<String> = file_paths
19-
.iter()
20-
.map(|py_str| py_str.to_str().unwrap().to_owned())
21-
.collect();
22-
23-
let results: Vec<_> = rust_file_paths
16+
pub fn get_imports_from_ipynb_files(py: Python, file_paths: Vec<String>) -> PyResult<PyObject> {
17+
let results: Vec<_> = file_paths
2418
.par_iter()
2519
.map(|path_str| {
2620
let result = _get_imports_from_ipynb_file(path_str);

src/imports/py.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::location;
44
use file_utils::read_file;
55
use location::Location;
66
use pyo3::prelude::*;
7-
use pyo3::types::PyString;
87
use rayon::prelude::*;
98
use std::collections::HashMap;
109

@@ -13,13 +12,8 @@ use super::shared;
1312
/// Processes multiple Python files in parallel to extract import statements and their locations.
1413
/// Accepts a list of file paths and returns a dictionary mapping module names to their import locations.
1514
#[pyfunction]
16-
pub fn get_imports_from_py_files(py: Python, file_paths: Vec<&PyString>) -> PyResult<PyObject> {
17-
let rust_file_paths: Vec<String> = file_paths
18-
.iter()
19-
.map(|py_str| py_str.to_str().unwrap().to_owned())
20-
.collect();
21-
22-
let results: Vec<_> = rust_file_paths
15+
pub fn get_imports_from_py_files(py: Python, file_paths: Vec<String>) -> PyResult<PyObject> {
16+
let results: Vec<_> = file_paths
2317
.par_iter()
2418
.map(|path_str| {
2519
let result = _get_imports_from_py_file(path_str);

src/location.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Location {
1414
#[pymethods]
1515
impl Location {
1616
#[new]
17+
#[pyo3(signature = (file, line=None, column=None))]
1718
fn new(file: String, line: Option<usize>, column: Option<usize>) -> Self {
1819
Self { file, line, column }
1920
}

0 commit comments

Comments
 (0)