Skip to content

Commit 185ff89

Browse files
committed
bump versions and modernize
1 parent 37b02f5 commit 185ff89

File tree

16 files changed

+43
-62
lines changed

16 files changed

+43
-62
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix: # https://github.com/actions/runner-images#available-images
13-
os: [macos-10.15, macos-11, macos-12]
13+
os: [macos-14, macos-15, macos-26]
1414
runs-on: ${{ matrix.os }}
1515
steps:
16-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
16+
- uses: actions/checkout@v6
1717
- name: Install dependencies
1818
run: |
1919
python3 --version

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
---
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v6.0.0
55
hooks:
66
- id: check-ast
7-
- id: check-byte-order-marker
7+
- id: fix-byte-order-marker
88
- id: check-case-conflict
99
- id: check-docstring-first
1010
- id: check-merge-conflict
1111
- id: detect-private-key
1212
- id: end-of-file-fixer
13-
- id: fix-encoding-pragma
1413
- id: mixed-line-ending
1514
- id: trailing-whitespace
15+
- repo: https://github.com/asottile/pyupgrade
16+
rev: v3.21.2
17+
hooks:
18+
- id: pyupgrade
19+
args: [--py310-plus]

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Release history
22
---------------
33

4+
unreleased
5+
+++++++++++++++++
6+
- Remover old python2 compatibility remnants (six, unicode)
7+
- Modernize code style for python 3.10+
8+
- Bump requirements of macOS (14+) as well as Python (3.10+)
9+
410
0.3.0 (June 2021)
511
+++++++++++++++++
612
- changed: create directory hierarchy for plist file if not present. issue #6

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ or, if you want to work using the source tarball:
107107
Requirements
108108
============
109109
* OS X >= 10.6
110-
* Python 3.4+
110+
* Python 3.10+

example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Example script showing how to install and remove plist based launchd jobs.
43
"""
@@ -58,7 +57,7 @@ def main():
5857
if job.pid is None:
5958
print("'%s' is loaded but not currently running" % (job.label)) # noqa: T201
6059
else:
61-
print("'%s' is loaded and currently running: PID = %s" % (job.label, job.pid)) # noqa: T201
60+
print(f"'{job.label}' is loaded and currently running: PID = {job.pid}") # noqa: T201
6261
while job.pid is not None:
6362
print("Alive! PID = %s" % job.pid) # noqa: T201
6463
job.refresh()

launchd/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
31
__author__ = "Paul Kremer"
42
__email__ = "paul@spurious.biz"
5-
__version__ = "0.3.0"
3+
__version__ = "1.0.0"
64

75
from .launchctl import jobs, LaunchdJob, load, unload # noqa: F401
86
from . import plist # noqa: F401

launchd/cmd.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
# -*- coding: utf-8 -*-
2-
31
import subprocess # noqa: S404
42

5-
import six
6-
73

84
def launchctl(subcommand, *args):
95
"""
106
Call the launchctl binary and capture the output.
117
128
:param subcommand: string
139
"""
14-
if not isinstance(subcommand, six.string_types):
10+
if not isinstance(subcommand, str):
1511
raise ValueError("Argument is invalid: %r" % repr(subcommand))
16-
if isinstance(subcommand, six.text_type):
12+
if isinstance(subcommand, str):
1713
subcommand = subcommand.encode("utf-8")
1814

1915
cmd = ["launchctl", subcommand]
2016
for arg in args:
21-
if isinstance(arg, six.string_types):
22-
if isinstance(arg, six.text_type):
17+
if isinstance(arg, str):
18+
if isinstance(arg, str):
2319
cmd.append(arg.encode("utf-8"))
2420
else:
2521
cmd.append(arg)

launchd/launchctl.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
# -*- coding: utf-8 -*-
2-
31
import ServiceManagement
42

53
from .cmd import launchctl
64
from .plist import discover_filename
75
from .util import convert_NSDictionary_to_dict
86

97

10-
class LaunchdJob(object):
8+
class LaunchdJob:
119
"""
1210
Class to lazily query the properties of the LaunchdJob when accessed.
1311
"""
14-
def __init__(self, label, pid=-1, laststatus=""):
12+
def __init__(self, label: str, pid: int = -1, laststatus=""):
1513
"""
1614
Instantiate a LaunchdJob instance. Only the label is required.
1715
If no pid or laststatus are specified, they will be queried when
@@ -88,7 +86,7 @@ def refresh(self):
8886
self._laststatus = None
8987

9088
@property
91-
def plistfilename(self):
89+
def plistfilename(self) -> str | None:
9290
"""
9391
Lazily detect absolute filename of the property list file.
9492

launchd/plist.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import os
42
import plistlib
53

@@ -18,15 +16,15 @@
1816
}
1917

2018

21-
def compute_directory(scope):
19+
def compute_directory(scope: int) -> str:
2220
return os.path.expanduser(PLIST_LOCATIONS[scope])
2321

2422

25-
def compute_filename(label, scope):
23+
def compute_filename(label: str, scope: int) -> str:
2624
return os.path.join(compute_directory(scope), label + ".plist")
2725

2826

29-
def discover_filename(label, scopes=None):
27+
def discover_filename(label: str, scopes: None | tuple[int] | list[int] = None) -> str | None:
3028
"""
3129
Check the filesystem for the existence of a .plist file matching the job label.
3230
Optionally specify one or more scopes to search (default all).
@@ -45,12 +43,12 @@ def discover_filename(label, scopes=None):
4543
return None
4644

4745

48-
def read(label, scope=None):
46+
def read(label: str, scope: int | None = None):
4947
with open(discover_filename(label, scope), "rb") as f:
5048
return plistlib.load(f)
5149

5250

53-
def write(label, plist, scope=USER):
51+
def write(label: str, plist, scope=USER) -> str:
5452
"""
5553
Write the property list to file on disk and return filename.
5654
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
# -*- coding: utf-8 -*-
2-
31
import unittest
42

5-
import six
6-
73
from launchd import cmd
84

95

@@ -20,9 +16,9 @@ def testlaunchctl_invalid_args(self):
2016

2117
def testlaunchctl_list(self):
2218
stdout = cmd.launchctl("list").decode("utf-8")
23-
self.assertTrue(isinstance(stdout, six.string_types))
19+
self.assertTrue(isinstance(stdout, str))
2420

2521
def testlaunchctl_list_x(self):
2622
label = "com.apple.Finder"
2723
stdout = cmd.launchctl("list", label).decode("utf-8")
28-
self.assertTrue(isinstance(stdout, six.string_types))
24+
self.assertTrue(isinstance(stdout, str))

0 commit comments

Comments
 (0)