Skip to content

Commit 1bd9997

Browse files
authored
Switch to ruff (#156)
1 parent 003a1fc commit 1bd9997

31 files changed

+2368
-2196
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
13+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
1414

1515
steps:
1616
- uses: actions/checkout@v4

config.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
# Path of the Zope instance configuration to use to instantiate the application
22
# object
3-
conf_path = '/var/lib/zope4/ema/etc/zope.conf'
3+
conf_path = "/var/lib/zope4/ema/etc/zope.conf"
44

55
# Path to Data.fs which is needed for lookup of object IDs from transaction IDs
66
# with zodbsync watch
7-
datafs_path = '/var/lib/zope4/zeo/var/Data.fs'
7+
datafs_path = "/var/lib/zope4/zeo/var/Data.fs"
88

99
# user that is used to create commits
10-
manager_user = 'perfact'
10+
manager_user = "perfact"
1111

1212
# create the manager user with a default password if not present
1313
create_manager_user = True
1414

1515
# sets the default owner for objects that have no owner in the file system
1616
# representation
17-
default_owner = 'perfact'
17+
default_owner = "perfact"
1818

1919
# use default owner even if we're told otherwise by meta file
2020
force_default_owner = False
2121

2222
# Base directory of the repository
23-
base_dir = '/opt/perfact/dbutils-zoperepo'
23+
base_dir = "/opt/perfact/dbutils-zoperepo"
2424

2525
# default settings for git repos
2626
commit_name = "Zope Developer"
2727
commit_email = "zope-devel@example.de"
2828
commit_message = "Generic commit message."
2929

3030
# email address to send commit summaries of default commits to
31-
#codechange_mail = "zope-devel@example.de"
32-
#codechange_sender = "no-reply-zodbsync-changes@example.de"
31+
# codechange_mail = "zope-devel@example.de"
32+
# codechange_sender = "no-reply-zodbsync-changes@example.de"
3333

3434
# Path to script which is called to define the phases of playback to be
3535
# executed.

perfact/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
from pkgutil import extend_path
2+
23
__path__ = extend_path(__path__, __name__)

perfact/zodbsync/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from .zodbsync import mod_read, mod_write
21
from .extedit import launch as extedit_launch
3-
from .helpers import obj_modtime, db_modtime
2+
from .helpers import db_modtime, obj_modtime
3+
from .zodbsync import mod_read, mod_write
44

55
__all__ = [
6-
'mod_read',
7-
'mod_write',
8-
'obj_modtime',
9-
'db_modtime',
10-
'extedit_launch',
6+
"mod_read",
7+
"mod_write",
8+
"obj_modtime",
9+
"db_modtime",
10+
"extedit_launch",
1111
]

perfact/zodbsync/commands/checkout.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,54 @@
44

55

66
class Checkout(SubCommand):
7-
'''Switch to another branch'''
7+
"""Switch to another branch"""
8+
89
@staticmethod
910
def add_args(parser):
1011
parser.add_argument(
11-
'--skip-errors', action='store_true', default=False,
12-
help='Skip failed objects and continue',
13-
)
14-
parser.add_argument(
15-
'--dry-run', action='store_true', default=False,
16-
help='Only check for conflicts and roll back at the end.',
12+
"--skip-errors",
13+
action="store_true",
14+
default=False,
15+
help="Skip failed objects and continue",
1716
)
1817
parser.add_argument(
19-
'-b', action='store_true', default=False,
20-
help='Create branch.',
18+
"--dry-run",
19+
action="store_true",
20+
default=False,
21+
help="Only check for conflicts and roll back at the end.",
2122
)
2223
parser.add_argument(
23-
'-t', '--track', type=str, help='Set up upstream configuration.'
24+
"-b",
25+
action="store_true",
26+
default=False,
27+
help="Create branch.",
2428
)
2529
parser.add_argument(
26-
'--reset', type=str,
27-
help='Reset branch onto given commit.',
30+
"-t", "--track", type=str, help="Set up upstream configuration."
2831
)
2932
parser.add_argument(
30-
'--rebase', type=str,
31-
help='Rebase branch onto given commit.',
33+
"--reset",
34+
type=str,
35+
help="Reset branch onto given commit.",
3236
)
3337
parser.add_argument(
34-
'branch', type=str,
35-
help='''Branch name'''
38+
"--rebase",
39+
type=str,
40+
help="Rebase branch onto given commit.",
3641
)
42+
parser.add_argument("branch", type=str, help="""Branch name""")
3743

3844
@SubCommand.gitexec
3945
def run(self):
40-
self.logger.info('Checking out %s.' % self.args.branch)
41-
cmd = ['checkout']
46+
self.logger.info("Checking out %s." % self.args.branch)
47+
cmd = ["checkout"]
4248
if self.args.b:
43-
cmd.append('-b')
49+
cmd.append("-b")
4450
cmd.append(self.args.branch)
4551
if self.args.b and self.args.track:
46-
cmd.extend(['--track', self.args.track])
52+
cmd.extend(["--track", self.args.track])
4753
self.gitcmd_run(*cmd)
4854
if self.args.reset:
49-
self.gitcmd_run('reset', '--hard', self.args.reset)
55+
self.gitcmd_run("reset", "--hard", self.args.reset)
5056
if self.args.rebase:
51-
self.gitcmd_run('rebase', self.args.rebase)
57+
self.gitcmd_run("rebase", self.args.rebase)

perfact/zodbsync/commands/execute.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,30 @@
66

77

88
class Exec(SubCommand):
9-
'''Execute a command and play back any paths changed between old and new
10-
HEAD'''
9+
"""Execute a command and play back any paths changed between old and new
10+
HEAD"""
11+
1112
@staticmethod
1213
def add_args(parser):
1314
parser.add_argument(
14-
'--skip-errors', action='store_true', default=False,
15-
help='Skip failed objects and continue',
16-
)
17-
parser.add_argument(
18-
'--dry-run', action='store_true', default=False,
19-
help='Only check for conflicts and roll back at the end.',
15+
"--skip-errors",
16+
action="store_true",
17+
default=False,
18+
help="Skip failed objects and continue",
2019
)
2120
parser.add_argument(
22-
'--nocd', action='store_true', default=False,
23-
help='Do not cd to git repo for command',
21+
"--dry-run",
22+
action="store_true",
23+
default=False,
24+
help="Only check for conflicts and roll back at the end.",
2425
)
2526
parser.add_argument(
26-
'cmd', type=str, help='''command to be executed'''
27+
"--nocd",
28+
action="store_true",
29+
default=False,
30+
help="Do not cd to git repo for command",
2731
)
32+
parser.add_argument("cmd", type=str, help="""command to be executed""")
2833

2934
@SubCommand.gitexec
3035
def run(self):

perfact/zodbsync/commands/fastforward.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,28 @@
44

55

66
class FF(SubCommand):
7-
'''
7+
"""
88
Perform a fast-forward merge to the target commit and apply changed paths
9-
'''
9+
"""
10+
1011
@staticmethod
1112
def add_args(parser):
1213
parser.add_argument(
13-
'--skip-errors', action='store_true', default=False,
14-
help='Skip failed objects and continue',
15-
)
16-
parser.add_argument(
17-
'--dry-run', action='store_true', default=False,
18-
help='Only check for conflicts and roll back at the end.',
14+
"--skip-errors",
15+
action="store_true",
16+
default=False,
17+
help="Skip failed objects and continue",
1918
)
2019
parser.add_argument(
21-
'commit', type=str,
22-
help='''Target commit'''
20+
"--dry-run",
21+
action="store_true",
22+
default=False,
23+
help="Only check for conflicts and roll back at the end.",
2324
)
25+
parser.add_argument("commit", type=str, help="""Target commit""")
2426

2527
@SubCommand.gitexec
2628
def run(self):
2729
target = self.args.commit
28-
self.logger.info('Attempting fast-forward merge to %s.' % target)
29-
self.gitcmd_run('merge', '--ff-only', target)
30+
self.logger.info("Attempting fast-forward merge to %s." % target)
31+
self.gitcmd_run("merge", "--ff-only", target)

perfact/zodbsync/commands/freeze.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55

66

77
class Freeze(SubCommand):
8-
'''Mark paths as frozen and record them'''
8+
"""Mark paths as frozen and record them"""
9+
910
@staticmethod
1011
def add_args(parser):
1112
parser.add_argument(
12-
'path', type=str, nargs='*',
13-
help='Sub-Path in Data.fs to be frozen',
13+
"path",
14+
type=str,
15+
nargs="*",
16+
help="Sub-Path in Data.fs to be frozen",
1417
)
1518

1619
@SubCommand.with_lock
1720
def run(self):
1821
for path in self.args.path:
1922
fullpath = self.sync.fs_path(path)
2023
os.makedirs(fullpath, exist_ok=True)
21-
with open('{}/__frozen__'.format(fullpath), 'w'):
24+
with open("{}/__frozen__".format(fullpath), "w"):
2225
pass
2326
self.sync.record(paths=self.args.path, recurse=True)

perfact/zodbsync/commands/layer_init.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@
88
class LayerInit(SubCommand):
99
"""Register layers from source to work_dir, assuming objects are already in
1010
the Data.FS, but are now to be provided by a new layer."""
11-
subcommand = 'layer-init'
11+
12+
subcommand = "layer-init"
1213

1314
@staticmethod
1415
def add_args(parser):
1516
parser.add_argument(
16-
'ident', type=str, nargs='*',
17-
help='Layer identifier(s). May be * for all',
17+
"ident",
18+
type=str,
19+
nargs="*",
20+
help="Layer identifier(s). May be * for all",
1821
)
1922

2023
@SubCommand.with_lock
2124
def run(self):
22-
layers = {layer['ident']: layer
23-
for layer in self.sync.layers
24-
if layer['ident']}
25+
layers = {layer["ident"]: layer for layer in self.sync.layers if layer["ident"]}
2526
idents = self.args.ident
26-
if idents == ['*']:
27+
if idents == ["*"]:
2728
idents = layers.keys()
2829
for ident in idents:
2930
assert ident in layers, "Invalid ident"
3031
for ident in idents:
3132
layer = layers[ident]
32-
source = layer['source']
33-
target = layer['workdir']
33+
source = layer["source"]
34+
target = layer["workdir"]
3435
self.unpack_source(source, target)
35-
sp.run(['git', 'add', '.'], cwd=target)
36-
sp.run(['git', 'commit', '-m', 'zodbsync layer-init'], cwd=target)
36+
sp.run(["git", "add", "."], cwd=target)
37+
sp.run(["git", "commit", "-m", "zodbsync layer-init"], cwd=target)

0 commit comments

Comments
 (0)