Skip to content

Commit c02a85c

Browse files
authored
Merge pull request #399 from sanders41/future-annotations
Add __future__ annotations to the main files
2 parents 9b0459b + e6d17e6 commit c02a85c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/python_files.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::project_info::{ProjectInfo, ProjectManager};
77

88
fn create_dunder_main_file(module: &str) -> String {
99
format!(
10-
r#"from {module}.main import main # pragma: no cover
10+
r#"from __future__ import annotations
11+
12+
from {module}.main import main # pragma: no cover
1113
1214
if __name__ == "__main__":
1315
raise SystemExit(main())
@@ -16,7 +18,10 @@ if __name__ == "__main__":
1618
}
1719

1820
fn create_main_file() -> String {
19-
r#"def main() -> int:
21+
r#"from __future__ import annotations
22+
23+
24+
def main() -> int:
2025
print("Hello world!") # noqa: T201
2126
2227
return 0

src/snapshots/python_project__python_files__tests__save_main_files-2.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
source: src/python_files.rs
33
expression: main_content
44
---
5-
"def main() -> int:\n print(\"Hello world!\") # noqa: T201\n\n return 0\n\n\nif __name__ == \"__main__\":\n raise SystemExit(main())\n"
5+
"from __future__ import annotations\n\n\ndef main() -> int:\n print(\"Hello world!\") # noqa: T201\n\n return 0\n\n\nif __name__ == \"__main__\":\n raise SystemExit(main())\n"

src/snapshots/python_project__python_files__tests__save_main_files.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
source: src/python_files.rs
33
expression: dunder_main_content
44
---
5-
"from my_project.main import main # pragma: no cover\n\nif __name__ == \"__main__\":\n raise SystemExit(main())\n"
5+
"from __future__ import annotations\n\nfrom my_project.main import main # pragma: no cover\n\nif __name__ == \"__main__\":\n raise SystemExit(main())\n"

0 commit comments

Comments
 (0)