Skip to content

Commit

Permalink
Fix the type annotation of the generated stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Jan 27, 2024
1 parent ef7118b commit 7b2f6a0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import final, Any, List, Dict
from enum import Enum, auto

def sum_as_string(a,b) -> str:
def sum_as_string(a:int,b:int) -> str:
r"""
Returns the sum of two numbers as a string.
"""
Expand Down
2 changes: 1 addition & 1 deletion pyo3-stub-gen-testing-mixed/tests/test_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_sum_as_string():
assert pyo3_stub_gen_testing_mixed.my_rust_pkg.sum_as_string(1, "a") == "3"
assert pyo3_stub_gen_testing_mixed.my_rust_pkg.sum_as_string(1, 2) == "3"
2 changes: 1 addition & 1 deletion pyo3-stub-gen-testing-pure/pyo3_stub_gen_testing_pure.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import final, Any, List, Dict
from enum import Enum, auto

def sum_as_string(a,b) -> str:
def sum_as_string(a:int,b:int) -> str:
r"""
Returns the sum of two numbers as a string.
"""
Expand Down
3 changes: 1 addition & 2 deletions pyo3-stub-gen/src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Arg {

impl fmt::Display for Arg {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.name)
write!(f, "{}:{}", self.name, self.r#type)
}
}

Expand Down Expand Up @@ -463,7 +463,6 @@ impl StubInfo {
let python_source = self.pyproject.python_source().unwrap();
for (name, module) in self.modules.iter() {
let path: Vec<&str> = name.split('.').collect();
dbg!(&path);
let dest = if path.len() > 1 {
python_source.join(format!("{}.pyi", path.join("/")))
} else {
Expand Down

0 comments on commit 7b2f6a0

Please sign in to comment.