Skip to content

Commit 75118f8

Browse files
committed
open() defaults to "r"
1 parent 1821240 commit 75118f8

7 files changed

Lines changed: 10 additions & 10 deletions

pre_commit_hooks/check_autopkg_recipe_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def main(argv=None):
3636
for filename in args.filenames:
3737
recipe_list = None
3838
if filename.endswith(".txt"):
39-
with open(filename, "r", encoding="utf-8") as openfile:
39+
with open(filename, encoding="utf-8") as openfile:
4040
recipe_list = [
4141
line
4242
for line in openfile.read().splitlines()
@@ -53,7 +53,7 @@ def main(argv=None):
5353
# AutoPkg does not support YAML recipe lists, but AutoPkg users
5454
# may have developed custom tooling for this.
5555
try:
56-
with open(filename, "r", encoding="utf-8") as openfile:
56+
with open(filename, encoding="utf-8") as openfile:
5757
recipe_list = yaml.load(openfile)
5858
except Exception as err:
5959
print(f"{filename}: yaml parsing error: {err}")
@@ -62,7 +62,7 @@ def main(argv=None):
6262
# AutoPkg does not support JSON recipe lists, but AutoPkg users
6363
# may have developed custom tooling for this.
6464
try:
65-
with open(filename, "r", encoding="utf-8") as openfile:
65+
with open(filename, encoding="utf-8") as openfile:
6666
recipe_list = json.load(openfile)
6767
except Exception as err:
6868
print(f"{filename}: json parsing error: {err}")

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def validate_comments(filename, strict):
9999
plutil -convert xml1."""
100100

101101
passed = True
102-
with open(filename, "r", encoding="utf-8") as openfile:
102+
with open(filename, encoding="utf-8") as openfile:
103103
recipe_text = openfile.read()
104104
if "<!--" in recipe_text and "-->" in recipe_text:
105105
if strict:

pre_commit_hooks/check_jamf_extension_attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main(argv=None):
3232

3333
retval = 0
3434
for filename in args.filenames:
35-
with open(filename, "r", encoding="utf-8") as openfile:
35+
with open(filename, encoding="utf-8") as openfile:
3636
ea_content = openfile.read()
3737

3838
# Ensure script contains both <result> and </result> tags

pre_commit_hooks/check_jamf_scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def main(argv=None):
3131

3232
retval = 0
3333
for filename in args.filenames:
34-
with open(filename, "r", encoding="utf-8") as openfile:
34+
with open(filename, encoding="utf-8") as openfile:
3535
script_content = openfile.read()
3636

3737
# Ensure script starts with a shebang of some sort.

pre_commit_hooks/check_munkiadmin_scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def main(argv=None):
3333
retval = 1
3434

3535
# Ensure scripts have a proper shebang
36-
with open(filename, "r", encoding="utf-8") as openfile:
36+
with open(filename, encoding="utf-8") as openfile:
3737
script_content = openfile.read()
3838
if not validate_shebangs(script_content, filename):
3939
print(f"{filename}: does not start with a valid shebang")

pre_commit_hooks/check_munkipkg_buildinfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def main(argv=None):
8585
break # no need to continue testing this file
8686
elif filename.endswith((".yaml", ".yml")):
8787
try:
88-
with open(filename, "r", encoding="utf-8") as openfile:
88+
with open(filename, encoding="utf-8") as openfile:
8989
buildinfo = yaml.load(openfile)
9090
except Exception as err:
9191
print(f"{filename}: yaml parsing error: {err}")
9292
retval = 1
9393
break # no need to continue testing this file
9494
elif filename.endswith(".json"):
9595
try:
96-
with open(filename, "r", encoding="utf-8") as openfile:
96+
with open(filename, encoding="utf-8") as openfile:
9797
buildinfo = json.load(openfile)
9898
except Exception as err:
9999
print(f"{filename}: json parsing error: {err}")

pre_commit_hooks/check_outset_scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def main(argv=None):
3131
retval = 1
3232

3333
# Ensure scripts have a proper shebang
34-
with open(filename, "r", encoding="utf-8") as openfile:
34+
with open(filename, encoding="utf-8") as openfile:
3535
script_content = openfile.read()
3636
if not validate_shebangs(script_content, filename):
3737
print(f"{filename}: does not start with a valid shebang")

0 commit comments

Comments
 (0)