Minor Python modernization fixes.
All checks were successful
build / test (push) Successful in 11m6s
build / docs (push) Successful in 2m8s

This commit is contained in:
Dan Helfman 2026-03-02 20:47:11 -08:00
commit e693e42b9e
3 changed files with 4 additions and 8 deletions

View file

@ -68,7 +68,7 @@ def collect_patterns(config):
+ tuple(
parse_pattern(pattern_line.strip())
for filename in config.get('patterns_from', ())
for pattern_line in open(filename, encoding='utf-8').readlines()
for pattern_line in open(filename, encoding='utf-8')
if not pattern_line.lstrip().startswith('#')
if pattern_line.strip()
)
@ -78,7 +78,7 @@ def collect_patterns(config):
borgmatic.borg.pattern.Pattern_style.FNMATCH,
)
for filename in config.get('exclude_from', ())
for exclude_line in open(filename, encoding='utf-8').readlines()
for exclude_line in open(filename, encoding='utf-8')
if not exclude_line.lstrip().startswith('#')
if exclude_line.strip()
)

View file

@ -168,11 +168,7 @@ def render_configuration(config):
rendered,
# Dumping certain values (integers, for instance) causes ruamel.yaml to append an
# end-of-document "..." marker. Strip it.
transform=lambda dumped: (
dumped[: -len(RUAMEL_YAML_END_OF_DOCUMENT_MARKER)]
if dumped.endswith(RUAMEL_YAML_END_OF_DOCUMENT_MARKER)
else dumped
),
transform=lambda dumped: dumped.removesuffix(RUAMEL_YAML_END_OF_DOCUMENT_MARKER),
)
return rendered.getvalue()

View file

@ -10,7 +10,7 @@ MAXIMUM_LINE_LENGTH = 80
def test_schema_line_length_stays_under_limit():
schema_file = open(borgmatic.config.validate.schema_filename())
for line in schema_file.readlines():
for line in schema_file:
assert len(line.rstrip('\n')) <= MAXIMUM_LINE_LENGTH