Skip to content

Commit 4cd88c6

Browse files
jnnsbrrjnnsbrr
authored andcommitted
fix linting
1 parent 1393a6f commit 4cd88c6

2 files changed

Lines changed: 55 additions & 27 deletions

File tree

pycoupler/release.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def main():
267267
print(f" - Major increment: {major + 1}.0.0")
268268
else:
269269
print(
270-
"No current version found. Any valid semantic version (X.Y.Z) is allowed."
270+
"No current version found. Any valid semantic version (X.Y.Z) is allowed." # noqa: E501
271271
)
272272
print("")
273273
print("Examples of valid semantic versioning:")
@@ -276,18 +276,24 @@ def main():
276276
print(" - 1.0.0 -> 2.0.0 (major)")
277277
print(" - 1.0.0 -> 1.0.0 (re-release)")
278278
sys.exit(1)
279-
279+
280280
# Check if this is a re-release and ask for confirmation
281-
if current_version and parse_version(current_version) == parse_version(version):
282-
print(f"⚠️ WARNING: You are attempting to re-release version {version}")
283-
print(f"This will delete the existing tag and create a new one with recent changes.")
281+
if current_version and parse_version(current_version) == parse_version(version): # noqa: E501
282+
print(f"⚠️ WARNING: You are attempting to re-release version {version}") # noqa: E501
283+
print(
284+
f"This will delete the existing tag and create a new one with recent changes." # noqa: E501
285+
)
284286
print("")
285287
while True:
286-
response = input("Are you certain you want to re-release this version? [y/N]: ").strip().lower()
287-
if response in ['y', 'yes']:
288+
response = (
289+
input("Are you certain you want to re-release this version? [y/N]: ") # noqa: E501
290+
.strip()
291+
.lower()
292+
)
293+
if response in ["y", "yes"]:
288294
print("✅ Re-release confirmed. Proceeding...")
289295
break
290-
elif response in ['n', 'no', '']:
296+
elif response in ["n", "no", ""]:
291297
print("❌ Re-release cancelled.")
292298
sys.exit(0)
293299
else:

tests/test_release.py

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,12 @@ def test_get_current_version(self):
443443

444444
# Test with valid tag
445445
with patch("subprocess.run") as mock_run:
446-
mock_run.return_value = MagicMock(
447-
stdout="v1.5.0\n", returncode=0
448-
)
446+
mock_run.return_value = MagicMock(stdout="v1.5.0\n", returncode=0)
449447
assert get_current_version() == "1.5.0"
450448

451449
# Test with tag without 'v' prefix
452450
with patch("subprocess.run") as mock_run:
453-
mock_run.return_value = MagicMock(
454-
stdout="1.5.0\n", returncode=0
455-
)
451+
mock_run.return_value = MagicMock(stdout="1.5.0\n", returncode=0)
456452
assert get_current_version() == "1.5.0"
457453

458454
# Test with no tags
@@ -470,9 +466,15 @@ class TestReReleaseConfirmation:
470466
@patch("pycoupler.release.get_current_branch")
471467
@patch("pycoupler.release.get_current_version")
472468
@patch("subprocess.run")
473-
def test_release_confirmation_yes(self, mock_subprocess, mock_current_version,
474-
mock_branch, mock_package, mock_update_citation,
475-
mock_run_command):
469+
def test_release_confirmation_yes(
470+
self,
471+
mock_subprocess,
472+
mock_current_version,
473+
mock_branch,
474+
mock_package,
475+
mock_update_citation,
476+
mock_run_command,
477+
):
476478
"""Test re-release confirmation with 'yes' response."""
477479
# Setup mocks
478480
mock_package.return_value = "test-package"
@@ -497,9 +499,15 @@ def test_release_confirmation_yes(self, mock_subprocess, mock_current_version,
497499
@patch("pycoupler.release.get_current_branch")
498500
@patch("pycoupler.release.get_current_version")
499501
@patch("subprocess.run")
500-
def test_release_confirmation_no(self, mock_subprocess, mock_current_version,
501-
mock_branch, mock_package, mock_update_citation,
502-
mock_run_command):
502+
def test_release_confirmation_no(
503+
self,
504+
mock_subprocess,
505+
mock_current_version,
506+
mock_branch,
507+
mock_package,
508+
mock_update_citation,
509+
mock_run_command,
510+
):
503511
"""Test re-release confirmation with 'no' response."""
504512
# Setup mocks
505513
mock_package.return_value = "test-package"
@@ -523,9 +531,15 @@ def test_release_confirmation_no(self, mock_subprocess, mock_current_version,
523531
@patch("pycoupler.release.get_current_branch")
524532
@patch("pycoupler.release.get_current_version")
525533
@patch("subprocess.run")
526-
def test_release_confirmation_invalid_then_valid(self, mock_subprocess, mock_current_version,
527-
mock_branch, mock_package, mock_update_citation,
528-
mock_run_command):
534+
def test_release_confirmation_invalid_then_valid(
535+
self,
536+
mock_subprocess,
537+
mock_current_version,
538+
mock_branch,
539+
mock_package,
540+
mock_update_citation,
541+
mock_run_command,
542+
):
529543
"""Test re-release confirmation with invalid then valid response."""
530544
# Setup mocks
531545
mock_package.return_value = "test-package"
@@ -550,9 +564,15 @@ def test_release_confirmation_invalid_then_valid(self, mock_subprocess, mock_cur
550564
@patch("pycoupler.release.get_current_branch")
551565
@patch("pycoupler.release.get_current_version")
552566
@patch("subprocess.run")
553-
def test_no_confirmation_for_new_version(self, mock_subprocess, mock_current_version,
554-
mock_branch, mock_package, mock_update_citation,
555-
mock_run_command):
567+
def test_no_confirmation_for_new_version(
568+
self,
569+
mock_subprocess,
570+
mock_current_version,
571+
mock_branch,
572+
mock_package,
573+
mock_update_citation,
574+
mock_run_command,
575+
):
556576
"""Test that no confirmation is needed for new versions."""
557577
# Setup mocks
558578
mock_package.return_value = "test-package"
@@ -612,7 +632,9 @@ def test_full_release_workflow_mock(self):
612632

613633
mock_run_command.return_value = True
614634
mock_subprocess.return_value = MagicMock(returncode=0)
615-
mock_current_version.return_value = "1.0.0" # Valid previous version
635+
mock_current_version.return_value = (
636+
"1.0.0" # Valid previous version
637+
)
616638

617639
# Test the main function
618640
with patch.object(sys, "argv", ["release.py", "2.0.0"]):

0 commit comments

Comments
 (0)