Skip to content

Commit

Permalink
Use type hints in code from uv init (#7225)
Browse files Browse the repository at this point in the history
Let's promote type hints!

<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
The generated script now annotates the return type of the dummy function
`hello()`.

## Test Plan

<!-- How was it tested? -->
All existing tests have been synced with this update.
  • Loading branch information
bswck committed Sep 9, 2024
1 parent 74c6e53 commit 5905f40
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ impl InitProjectKind {
fs_err::write(
init_py,
indoc::formatdoc! {r#"
def hello():
def hello() -> None:
print("Hello from {name}!")
"#},
)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn init_application_package() -> Result<()> {
}, {
assert_snapshot!(
init, @r###"
def hello():
def hello() -> None:
print("Hello from foo!")
"###
);
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ example-packaged-app
But the module defines a CLI function:

```python title="__init__.py"
def hello():
def hello() -> None:
print("Hello from example-packaged-app!")
```

Expand Down

0 comments on commit 5905f40

Please sign in to comment.