diff --git a/borgmatic/actions/pattern.py b/borgmatic/actions/pattern.py index 52aad34d..6c2ced3f 100644 --- a/borgmatic/actions/pattern.py +++ b/borgmatic/actions/pattern.py @@ -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() ) diff --git a/borgmatic/config/generate.py b/borgmatic/config/generate.py index e22c452c..43227590 100644 --- a/borgmatic/config/generate.py +++ b/borgmatic/config/generate.py @@ -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() diff --git a/tests/integration/config/test_schema.py b/tests/integration/config/test_schema.py index 4d12bb33..dc04cecd 100644 --- a/tests/integration/config/test_schema.py +++ b/tests/integration/config/test_schema.py @@ -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