diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index afdc0a2..e263a98 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-24.04 strategy: matrix: - python-version: ["3.11", "3.12", "3.13", "3.14"] + python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"] steps: - name: Checkout repository diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c89ddbb..a031ad5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-24.04 strategy: matrix: - python-version: ["3.11", "3.12", "3.13", "3.14"] + python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"] steps: - name: Checkout repository diff --git a/github_backup/github_backup.py b/github_backup/github_backup.py index fdf2e22..305f1ba 100644 --- a/github_backup/github_backup.py +++ b/github_backup/github_backup.py @@ -5,7 +5,6 @@ import argparse import base64 import calendar -import codecs import json import logging import os @@ -2304,7 +2303,7 @@ def gist_backup_is_current(repository, repo_cwd, repo_dir): if not updated_at: return False try: - with codecs.open(os.path.join(repo_cwd, "gist.json"), encoding="utf-8") as f: + with open(os.path.join(repo_cwd, "gist.json"), encoding="utf-8", newline="") as f: stored = json.load(f) except (OSError, ValueError): return False @@ -2377,7 +2376,7 @@ def backup_repositories(args, output_directory, repositories): # DMCA-blocked or empty gist), so make sure the directory exists mkdir_p(repo_cwd) output_file = "{0}/gist.json".format(repo_cwd) - with codecs.open(output_file, "w", encoding="utf-8") as f: + with open(output_file, "w", encoding="utf-8", newline="") as f: json_dump(repository, f) continue # don't try to back anything else for a gist; it doesn't exist @@ -3021,7 +3020,7 @@ def backup_issues(args, repo_cwd, repository, repos_template): args, issue_cwd, issues[number], number, repository, item_type="issue" ) - with codecs.open(issue_file + ".temp", "w", encoding="utf-8") as f: + with open(issue_file + ".temp", "w", encoding="utf-8", newline="") as f: json_dump(issue, f) os.replace(issue_file + ".temp", issue_file) # Atomic write @@ -3040,7 +3039,7 @@ def read_json_file_if_exists(path): return None try: - with codecs.open(path, "r", encoding="utf-8") as f: + with open(path, "r", encoding="utf-8", newline="") as f: return json.load(f) except (OSError, UnicodeDecodeError, json.decoder.JSONDecodeError) as e: logger.debug("Error reading existing JSON file {0}: {1}".format(path, e)) @@ -3230,7 +3229,7 @@ def pull_is_due_for_repository_checkpoint(pull): restore_existing_pull_optional_data(pull, existing_pull) - with codecs.open(pull_file + ".temp", "w", encoding="utf-8") as f: + with open(pull_file + ".temp", "w", encoding="utf-8", newline="") as f: json_dump(pull, f) os.replace(pull_file + ".temp", pull_file) # Atomic write @@ -3646,7 +3645,7 @@ def json_dump_if_changed(data, output_file_path): # Check if file exists and compare content if os.path.exists(output_file_path): try: - with codecs.open(output_file_path, "r", encoding="utf-8") as f: + with open(output_file_path, "r", encoding="utf-8", newline="") as f: existing_content = f.read() if existing_content == new_content: logger.debug( @@ -3663,7 +3662,7 @@ def json_dump_if_changed(data, output_file_path): # Write the file atomically using temp file + rename temp_file = output_file_path + ".temp" - with codecs.open(temp_file, "w", encoding="utf-8") as f: + with open(temp_file, "w", encoding="utf-8", newline="") as f: f.write(new_content) os.replace(temp_file, output_file_path) # Atomic write return True diff --git a/setup.py b/setup.py index 6f9d0e7..93a68ce 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ def open_file(fname): "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", ], description="backup a github user or organization", long_description=open_file("README.rst").read(), diff --git a/tests/test_json_dump_if_changed.py b/tests/test_json_dump_if_changed.py index 426baee..356533c 100644 --- a/tests/test_json_dump_if_changed.py +++ b/tests/test_json_dump_if_changed.py @@ -1,6 +1,5 @@ """Tests for json_dump_if_changed functionality.""" -import codecs import json import os import tempfile @@ -25,7 +24,7 @@ def test_writes_new_file(self): assert os.path.exists(output_file) # Verify content matches expected format - with codecs.open(output_file, "r", encoding="utf-8") as f: + with open(output_file, "r", encoding="utf-8", newline="") as f: content = f.read() loaded = json.loads(content) assert loaded == test_data @@ -67,7 +66,7 @@ def test_writes_when_content_changed(self): assert result2 is True # Verify new content - with codecs.open(output_file, "r", encoding="utf-8") as f: + with open(output_file, "r", encoding="utf-8", newline="") as f: loaded = json.load(f) assert loaded == test_data2 @@ -79,7 +78,7 @@ def test_uses_consistent_formatting(self): github_backup.json_dump_if_changed(test_data, output_file) - with codecs.open(output_file, "r", encoding="utf-8") as f: + with open(output_file, "r", encoding="utf-8", newline="") as f: content = f.read() # Check for consistent formatting: @@ -111,7 +110,7 @@ def test_atomic_write_always_used(self): assert not os.path.exists(temp_file) # Verify content - with codecs.open(output_file, "r", encoding="utf-8") as f: + with open(output_file, "r", encoding="utf-8", newline="") as f: loaded = json.load(f) assert loaded == test_data @@ -130,7 +129,7 @@ def test_handles_unicode_content(self): assert result is True # Verify Unicode is preserved - with codecs.open(output_file, "r", encoding="utf-8") as f: + with open(output_file, "r", encoding="utf-8", newline="") as f: loaded = json.load(f) assert loaded == test_data @@ -154,7 +153,7 @@ def test_handles_complex_nested_data(self): assert result is True # Verify structure is preserved - with codecs.open(output_file, "r", encoding="utf-8") as f: + with open(output_file, "r", encoding="utf-8", newline="") as f: loaded = json.load(f) assert loaded == test_data @@ -173,7 +172,7 @@ def test_overwrites_on_unicode_decode_error(self): assert result is True # Verify new content was written - with codecs.open(output_file, "r", encoding="utf-8") as f: + with open(output_file, "r", encoding="utf-8", newline="") as f: loaded = json.load(f) assert loaded == test_data