Skip to content

Commit f84137e

Browse files
authored
Remove '+' on write mode (#1426)
Not required throughout the examples and docs Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
1 parent 33d7b96 commit f84137e

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

docs/examples/workflows/artifacts/artifact_with_fanout.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def writer():
1616
import json
1717

18-
with open("/tmp/file", "w+") as f:
18+
with open("/tmp/file", "w") as f:
1919
for i in range(10):
2020
f.write(json.dumps(i) + "\n")
2121

@@ -89,7 +89,7 @@
8989
import sys
9090
sys.path.append(os.getcwd())
9191
import json
92-
with open('/tmp/file', 'w+') as f:
92+
with open('/tmp/file', 'w') as f:
9393
for i in range(10):
9494
f.write(json.dumps(i) + '\n')
9595
command:

docs/examples/workflows/artifacts/basic_artifacts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ task, consumer, takes this artifact, places it at its own `/file` path, and prin
1515

1616
@script(outputs=Artifact(name="out-art", path="/tmp/file", archive=NoneArchiveStrategy()))
1717
def writer():
18-
with open("/tmp/file", "w+") as f:
18+
with open("/tmp/file", "w") as f:
1919
f.write("Hello, world!")
2020

2121

@@ -64,7 +64,7 @@ task, consumer, takes this artifact, places it at its own `/file` path, and prin
6464
import os
6565
import sys
6666
sys.path.append(os.getcwd())
67-
with open('/tmp/file', 'w+') as f:
67+
with open('/tmp/file', 'w') as f:
6868
f.write('Hello, world!')
6969
command:
7070
- python

docs/walk-through/artifacts.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ from hera.workflows import Artifact, NoneArchiveStrategy, Steps, Workflow, scrip
7878

7979
@script(outputs=Artifact(name="out-art", path="/tmp/file", archive=NoneArchiveStrategy()))
8080
def writer():
81-
with open("/tmp/file", "w+") as f:
81+
with open("/tmp/file", "w") as f:
8282
f.write("Hello, world!")
8383

8484

@@ -112,7 +112,7 @@ We then write to the specified path within the function:
112112
```py
113113
@script(outputs=Artifact(name="out-art", path="/tmp/file", archive=NoneArchiveStrategy()))
114114
def writer():
115-
with open("/tmp/file", "w+") as f:
115+
with open("/tmp/file", "w") as f:
116116
f.write("Hello, world!")
117117
```
118118

@@ -159,7 +159,7 @@ We can then call the function in a Steps context. Compare to the YAML workflow a
159159
import os
160160
import sys
161161
sys.path.append(os.getcwd())
162-
with open('/tmp/file', 'w+') as f:
162+
with open('/tmp/file', 'w') as f:
163163
f.write('Hello, world!')
164164
command:
165165
- python
@@ -242,7 +242,7 @@ output artifact to the `in-art` input artifact:
242242
import os
243243
import sys
244244
sys.path.append(os.getcwd())
245-
with open('/tmp/file', 'w+') as f:
245+
with open('/tmp/file', 'w') as f:
246246
f.write('Hello, world!')
247247
command:
248248
- python

examples/workflows/artifacts/artifact-with-fanout.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ spec:
3939
import sys
4040
sys.path.append(os.getcwd())
4141
import json
42-
with open('/tmp/file', 'w+') as f:
42+
with open('/tmp/file', 'w') as f:
4343
for i in range(10):
4444
f.write(json.dumps(i) + '\n')
4545
command:

examples/workflows/artifacts/artifact_with_fanout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def writer():
66
import json
77

8-
with open("/tmp/file", "w+") as f:
8+
with open("/tmp/file", "w") as f:
99
for i in range(10):
1010
f.write(json.dumps(i) + "\n")
1111

examples/workflows/artifacts/basic-artifacts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
import os
2929
import sys
3030
sys.path.append(os.getcwd())
31-
with open('/tmp/file', 'w+') as f:
31+
with open('/tmp/file', 'w') as f:
3232
f.write('Hello, world!')
3333
command:
3434
- python

examples/workflows/artifacts/basic_artifacts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@script(outputs=Artifact(name="out-art", path="/tmp/file", archive=NoneArchiveStrategy()))
1010
def writer():
11-
with open("/tmp/file", "w+") as f:
11+
with open("/tmp/file", "w") as f:
1212
f.write("Hello, world!")
1313

1414

scripts/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def get_import_paths_from_refs(refs: list, root_path: str) -> List[ImportReferen
119119
def write_imports(references: List[ImportReference], models_type: str, openapi_spec_url: str) -> None:
120120
"""Writes the given imports to the `root_path` models."""
121121
path = Path(__name__).parent.parent / "src" / "hera" / models_type / "models" / "__init__.py"
122-
with open(str(path), "w+") as f:
122+
with open(str(path), "w") as f:
123123
f.write(
124124
f'"""[DO NOT EDIT MANUALLY] Auto-generated model classes.\n\n'
125125
f"Auto-generated by Hera via `make {models_type}-models`.\n"

scripts/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def make_service(service_def: str, endpoints: List[ServiceEndpoint], models_type
503503

504504
def write_service(service: str, path: Path) -> None:
505505
"""Writes the service code to the specified path."""
506-
with open(str(path), "w+") as f:
506+
with open(str(path), "w") as f:
507507
f.write(service)
508508

509509

scripts/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@
165165

166166
# finally, we write the spec to the output file that is passed to use assuming the client wants to perform
167167
# something with this file
168-
with open(output_file, "w+") as f:
168+
with open(output_file, "w") as f:
169169
json.dump(spec, f, indent=2)

0 commit comments

Comments
 (0)