Skip to content

Commit

Permalink
fix(deps): update rust crate pyo3 to 0.22.0 (#741)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
renovate[bot] and mkniewallner authored Jul 3, 2024
1 parent 452ceef commit cbf93d1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 84 deletions.
80 changes: 13 additions & 67 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ encoding_rs = "0.8.34"
ignore = "0.4.22"
log = "0.4.22"
path-slash = "0.2.1"
pyo3 = { version = "0.21.2", features = ["abi3-py38"] }
pyo3 = { version = "0.22.0", features = ["abi3-py38"] }
pyo3-log = "0.11.0"
rayon = "1.10.0"
regex = "1.10.5"
Expand Down
10 changes: 2 additions & 8 deletions src/imports/ipynb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use file_utils::read_file;
use location::Location;
use pyo3::exceptions::PySyntaxError;
use pyo3::prelude::*;
use pyo3::types::PyString;
use rayon::prelude::*;
use std::collections::HashMap;

Expand All @@ -14,13 +13,8 @@ use super::shared;
/// Processes multiple Python files in parallel to extract import statements and their locations.
/// Accepts a list of file paths and returns a dictionary mapping module names to their import locations.
#[pyfunction]
pub fn get_imports_from_ipynb_files(py: Python, file_paths: Vec<&PyString>) -> PyResult<PyObject> {
let rust_file_paths: Vec<String> = file_paths
.iter()
.map(|py_str| py_str.to_str().unwrap().to_owned())
.collect();

let results: Vec<_> = rust_file_paths
pub fn get_imports_from_ipynb_files(py: Python, file_paths: Vec<String>) -> PyResult<PyObject> {
let results: Vec<_> = file_paths
.par_iter()
.map(|path_str| {
let result = _get_imports_from_ipynb_file(path_str);
Expand Down
10 changes: 2 additions & 8 deletions src/imports/py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::location;
use file_utils::read_file;
use location::Location;
use pyo3::prelude::*;
use pyo3::types::PyString;
use rayon::prelude::*;
use std::collections::HashMap;

Expand All @@ -13,13 +12,8 @@ use super::shared;
/// Processes multiple Python files in parallel to extract import statements and their locations.
/// Accepts a list of file paths and returns a dictionary mapping module names to their import locations.
#[pyfunction]
pub fn get_imports_from_py_files(py: Python, file_paths: Vec<&PyString>) -> PyResult<PyObject> {
let rust_file_paths: Vec<String> = file_paths
.iter()
.map(|py_str| py_str.to_str().unwrap().to_owned())
.collect();

let results: Vec<_> = rust_file_paths
pub fn get_imports_from_py_files(py: Python, file_paths: Vec<String>) -> PyResult<PyObject> {
let results: Vec<_> = file_paths
.par_iter()
.map(|path_str| {
let result = _get_imports_from_py_file(path_str);
Expand Down
1 change: 1 addition & 0 deletions src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Location {
#[pymethods]
impl Location {
#[new]
#[pyo3(signature = (file, line=None, column=None))]
fn new(file: String, line: Option<usize>, column: Option<usize>) -> Self {
Self { file, line, column }
}
Expand Down

0 comments on commit cbf93d1

Please sign in to comment.