Skip to content

Commit 7c1eb21

Browse files
authored
Merge pull request #81 from homebysix/1.16.2
1.16.2 merge to main
2 parents ccf1629 + 9d1bb63 commit 7c1eb21

21 files changed

+71
-73
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ repos:
1010
- id: check-merge-conflict
1111
- id: check-yaml
1212
- id: end-of-file-fixer
13-
- id: fix-encoding-pragma
1413
- id: mixed-line-ending
1514
- id: no-commit-to-branch
1615
args: [--branch, main]
1716
- id: trailing-whitespace
1817
args: [--markdown-linebreak-ext=md]
18+
- repo: https://github.com/asottile/pyupgrade
19+
rev: v3.16.0
20+
hooks:
21+
- id: pyupgrade
22+
args: ['--py36-plus']
1923
- repo: https://github.com/python/black
2024
rev: 24.4.2
2125
hooks:

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ All notable changes to this project will be documented in this file. This projec
1414

1515
Nothing yet.
1616

17+
## [1.16.2] - 2024-06-10
18+
19+
### Fixed
20+
21+
- Fixed two bugs in shebang validation that would result in ModuleNotFoundError when running check-munki-pkgsinfo hook.
22+
23+
### Removed
24+
25+
- Dropped Python 2 string instance validation. No further support will be provided for Python 2.
26+
27+
### Changed
28+
29+
- Added PyUpgrade hook to this repo's own pre-commit linting, in order to ensure modern Python syntax.
30+
- Don't specify `"r"` mode when using `open()`, as this is the default behavior.
31+
1732
## [1.16.1] - 2024-06-08
1833

1934
### Added

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ For any hook in this repo you wish to use, add the following to your pre-commit
1515

1616
```yaml
1717
- repo: https://github.com/homebysix/pre-commit-macadmin
18-
rev: v1.16.1
18+
rev: v1.16.2
1919
hooks:
2020
- id: check-plists
2121
# - id: ...
@@ -141,7 +141,7 @@ When combining arguments that take lists (for example: `--required-keys`, `--cat
141141

142142
```yaml
143143
- repo: https://github.com/homebysix/pre-commit-macadmin
144-
rev: v1.16.1
144+
rev: v1.16.2
145145
hooks:
146146
- id: check-munki-pkgsinfo
147147
args: ['--catalogs', 'testing', 'stable', '--']
@@ -151,7 +151,7 @@ But if you also use the `--categories` argument, you would move the trailing `--
151151

152152
```yaml
153153
- repo: https://github.com/homebysix/pre-commit-macadmin
154-
rev: v1.16.1
154+
rev: v1.16.2
155155
hooks:
156156
- id: check-munki-pkgsinfo
157157
args: ['--catalogs', 'testing', 'stable', '--categories', 'Design', 'Engineering', 'Web Browsers', '--']
@@ -163,7 +163,7 @@ If it looks better to your eye, feel free to use a multi-line list for long argu
163163

164164
```yaml
165165
- repo: https://github.com/homebysix/pre-commit-macadmin
166-
rev: v1.16.1
166+
rev: v1.16.2
167167
hooks:
168168
- id: check-munki-pkgsinfo
169169
args: [

pre_commit_hooks/check_autopkg_recipe_list.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32
"""This hook checks AutoPkg recipe lists (in txt, plist, yaml, or json format)
43
for common issues.
54
@@ -37,7 +36,7 @@ def main(argv=None):
3736
for filename in args.filenames:
3837
recipe_list = None
3938
if filename.endswith(".txt"):
40-
with open(filename, "r", encoding="utf-8") as openfile:
39+
with open(filename, encoding="utf-8") as openfile:
4140
recipe_list = [
4241
line
4342
for line in openfile.read().splitlines()
@@ -54,7 +53,7 @@ def main(argv=None):
5453
# AutoPkg does not support YAML recipe lists, but AutoPkg users
5554
# may have developed custom tooling for this.
5655
try:
57-
with open(filename, "r", encoding="utf-8") as openfile:
56+
with open(filename, encoding="utf-8") as openfile:
5857
recipe_list = yaml.load(openfile)
5958
except Exception as err:
6059
print(f"{filename}: yaml parsing error: {err}")
@@ -63,7 +62,7 @@ def main(argv=None):
6362
# AutoPkg does not support JSON recipe lists, but AutoPkg users
6463
# may have developed custom tooling for this.
6564
try:
66-
with open(filename, "r", encoding="utf-8") as openfile:
65+
with open(filename, encoding="utf-8") as openfile:
6766
recipe_list = json.load(openfile)
6867
except Exception as err:
6968
print(f"{filename}: json parsing error: {err}")
@@ -73,7 +72,7 @@ def main(argv=None):
7372
print(f"{filename}: invalid recipe list")
7473
retval = 1
7574
else:
76-
if any((".munki" in recipe for recipe in recipe_list)):
75+
if any(".munki" in recipe for recipe in recipe_list):
7776
if "MakeCatalogs" not in recipe_list[-1]:
7877
print("{}: MakeCatalogs should be the last item in the list")
7978
retval = 1

pre_commit_hooks/check_autopkg_recipes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32
"""This hook checks AutoPkg recipes to ensure they meet various
43
requirements."""
54

@@ -100,7 +99,7 @@ def validate_comments(filename, strict):
10099
plutil -convert xml1."""
101100

102101
passed = True
103-
with open(filename, "r", encoding="utf-8") as openfile:
102+
with open(filename, encoding="utf-8") as openfile:
104103
recipe_text = openfile.read()
105104
if "<!--" in recipe_text and "-->" in recipe_text:
106105
if strict:

pre_commit_hooks/check_git_config_email.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32
"""This hook checks to ensure the Git config email matches one of the specified domains."""
43

54
import argparse
@@ -43,7 +42,7 @@ def main(argv=None):
4342
print("Git config email does not look like an email address.")
4443
print("Git config email: " + user_email)
4544
retval = 1
46-
elif not any((user_email.endswith("@" + x) for x in args.domains)):
45+
elif not any(user_email.endswith("@" + x) for x in args.domains):
4746
print("Git config email is from an unexpected domain.")
4847
print("Git config email: " + user_email)
4948
print("Expected domains: " + str(args.domains))

pre_commit_hooks/check_jamf_extension_attributes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32
"""Check Jamf extension attributes for common issues."""
43

54
import argparse
65
import re
76

8-
from util import validate_shebangs
7+
from pre_commit_hooks.util import validate_shebangs
98

109

1110
def build_argument_parser():
@@ -33,7 +32,7 @@ def main(argv=None):
3332

3433
retval = 0
3534
for filename in args.filenames:
36-
with open(filename, "r", encoding="utf-8") as openfile:
35+
with open(filename, encoding="utf-8") as openfile:
3736
ea_content = openfile.read()
3837

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

pre_commit_hooks/check_jamf_json_manifests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32
"""This hook checks Jamf JSON schema custom app manifests for inconsistencies and common issues."""
43

54
# References:

pre_commit_hooks/check_jamf_profiles.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32
"""Check Jamf scripts for common issues."""
43

54
import argparse

pre_commit_hooks/check_jamf_scripts.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/python
2-
# -*- coding: utf-8 -*-
32
"""Check Jamf scripts for common issues."""
43

54
import argparse
65

7-
from util import validate_shebangs
6+
from pre_commit_hooks.util import validate_shebangs
87

98

109
def build_argument_parser():
@@ -32,7 +31,7 @@ def main(argv=None):
3231

3332
retval = 0
3433
for filename in args.filenames:
35-
with open(filename, "r", encoding="utf-8") as openfile:
34+
with open(filename, encoding="utf-8") as openfile:
3635
script_content = openfile.read()
3736

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

0 commit comments

Comments
 (0)