Skip to content

Fix ruff linting warnings from generated template files for extension modules #10371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,22 +1055,22 @@ fn generate_package_scripts(
indoc::formatdoc! {r#"
from {module_name}._core import hello_from_bin


def hello() -> str:
return hello_from_bin()
"#}
} else {
indoc::formatdoc! {r#"
from {module_name}._core import hello_from_bin


def main() -> None:
print(hello_from_bin())
"#}
};

// .pyi file for binary script
let pyi_contents = indoc::indoc! {r"
from __future__ import annotations

def hello_from_bin() -> str: ...
"};

Expand Down
12 changes: 4 additions & 8 deletions crates/uv/tests/it/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
"###
Expand All @@ -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: ...
"###
);
Expand Down Expand Up @@ -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())
"###
Expand All @@ -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: ...
"###
);
Expand Down Expand Up @@ -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()
"###
Expand All @@ -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: ...
"###
);
Expand Down Expand Up @@ -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()
"###
Expand All @@ -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: ...
"###
);
Expand Down
1 change: 1 addition & 0 deletions docs/concepts/projects/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -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())
```
Expand Down
Loading