diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index 88e33a41b..faa330249 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -1055,6 +1055,7 @@ fn generate_package_scripts( indoc::formatdoc! {r#" from {module_name}._core import hello_from_bin + def hello() -> str: return hello_from_bin() "#} @@ -1062,6 +1063,7 @@ fn generate_package_scripts( indoc::formatdoc! {r#" from {module_name}._core import hello_from_bin + def main() -> None: print(hello_from_bin()) "#} @@ -1069,8 +1071,6 @@ fn generate_package_scripts( // .pyi file for binary script let pyi_contents = indoc::indoc! {r" - from __future__ import annotations - def hello_from_bin() -> str: ... "}; diff --git a/crates/uv/tests/it/init.rs b/crates/uv/tests/it/init.rs index 969aa8d3a..9157d2f67 100644 --- a/crates/uv/tests/it/init.rs +++ b/crates/uv/tests/it/init.rs @@ -2764,6 +2764,7 @@ fn init_app_build_backend_maturin() -> Result<()> { init, @r###" from foo._core import hello_from_bin + def main() -> None: print(hello_from_bin()) "### @@ -2776,8 +2777,6 @@ fn init_app_build_backend_maturin() -> Result<()> { }, { assert_snapshot!( pyi_contents, @r###" - from __future__ import annotations - def hello_from_bin() -> str: ... "### ); @@ -2894,6 +2893,7 @@ fn init_app_build_backend_scikit() -> Result<()> { init, @r###" from foo._core import hello_from_bin + def main() -> None: print(hello_from_bin()) "### @@ -2906,8 +2906,6 @@ fn init_app_build_backend_scikit() -> Result<()> { }, { assert_snapshot!( pyi_contents, @r###" - from __future__ import annotations - def hello_from_bin() -> str: ... "### ); @@ -3017,6 +3015,7 @@ fn init_lib_build_backend_maturin() -> Result<()> { init, @r###" from foo._core import hello_from_bin + def hello() -> str: return hello_from_bin() "### @@ -3029,8 +3028,6 @@ fn init_lib_build_backend_maturin() -> Result<()> { }, { assert_snapshot!( pyi_contents, @r###" - from __future__ import annotations - def hello_from_bin() -> str: ... "### ); @@ -3144,6 +3141,7 @@ fn init_lib_build_backend_scikit() -> Result<()> { init, @r###" from foo._core import hello_from_bin + def hello() -> str: return hello_from_bin() "### @@ -3156,8 +3154,6 @@ fn init_lib_build_backend_scikit() -> Result<()> { }, { assert_snapshot!( pyi_contents, @r###" - from __future__ import annotations - def hello_from_bin() -> str: ... "### ); diff --git a/docs/concepts/projects/init.md b/docs/concepts/projects/init.md index 30c4ee4ba..a237af7f5 100644 --- a/docs/concepts/projects/init.md +++ b/docs/concepts/projects/init.md @@ -279,6 +279,7 @@ And the Python module imports it: ```python title="src/example_ext/__init__.py" from example_ext._core import hello_from_bin + def main() -> None: print(hello_from_bin()) ```