From 40ae054e3ccdb3b6763ff0298c67a121769de724 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 03:13:45 +0000 Subject: [PATCH 1/2] Initial plan From 9634348127ba37dc48a8acf843e62b05bea46b19 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 03:37:50 +0000 Subject: [PATCH 2/2] refactor(parsers)!: remove default_bump_level from three commit parsers Remove the default_bump_level setting from conventional-commit, scipy, and emoji parsers. - Removed default_bump_level field from ConventionalCommitParserOptions - Removed default_level_bump and default_bump_level from ScipyParserOptions - Removed default_bump_level field from EmojiParserOptions - Updated code to use LevelBump.NO_RELEASE directly instead of self.options.default_bump_level - Updated tag_to_level dict construction to use LevelBump.NO_RELEASE instead of default_bump_level - Updated tests to remove references to default_bump_level - Added new tests to verify parsers work correctly with other_allowed_tags BREAKING CHANGE: The `default_bump_level` configuration option has been removed from the conventional-commit, scipy, and emoji commit parsers. This option was redundant as the parser already maps commit types to bump levels. If you were using this option in your configuration, you can remove it. The parsers will now use LevelBump.NO_RELEASE for commit types not explicitly mapped to a bump level, which is the same behavior as the previous default. Co-authored-by: codejedi365 <17354856+codejedi365@users.noreply.github.com> --- .../commit_parser/conventional/options.py | 5 +---- .../commit_parser/conventional/parser.py | 4 +--- src/semantic_release/commit_parser/emoji.py | 9 ++------- src/semantic_release/commit_parser/scipy.py | 12 ++---------- tests/unit/semantic_release/cli/test_config.py | 2 -- .../commit_parser/test_conventional.py | 7 ++++--- .../semantic_release/commit_parser/test_emoji.py | 14 ++++++++++++++ .../semantic_release/commit_parser/test_scipy.py | 14 ++++++++++++++ 8 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/semantic_release/commit_parser/conventional/options.py b/src/semantic_release/commit_parser/conventional/options.py index 6bdb9739c..2cb4c2045 100644 --- a/src/semantic_release/commit_parser/conventional/options.py +++ b/src/semantic_release/commit_parser/conventional/options.py @@ -42,9 +42,6 @@ class ConventionalCommitParserOptions(ParserOptions): one of these prefixes, it will not be considered a valid commit message. """ - default_bump_level: LevelBump = LevelBump.NO_RELEASE - """The minimum bump level to apply to valid commit message.""" - parse_squash_commits: bool = True """Toggle flag for whether or not to parse squash commits""" @@ -64,7 +61,7 @@ def __post_init__(self) -> None: # for our expected output. Due to the empty second array, we know the first is always longest # and that means no values in the first entry of the tuples will ever be a LevelBump. We # apply a str() to make mypy happy although it will never happen. - *zip_longest(self.allowed_tags, (), fillvalue=self.default_bump_level), + *zip_longest(self.allowed_tags, (), fillvalue=LevelBump.NO_RELEASE), *zip_longest(self.patch_tags, (), fillvalue=LevelBump.PATCH), *zip_longest(self.minor_tags, (), fillvalue=LevelBump.MINOR), ] diff --git a/src/semantic_release/commit_parser/conventional/parser.py b/src/semantic_release/commit_parser/conventional/parser.py index 5cab34c56..cd2c3312e 100644 --- a/src/semantic_release/commit_parser/conventional/parser.py +++ b/src/semantic_release/commit_parser/conventional/parser.py @@ -257,9 +257,7 @@ def create_parsed_message_result( level_bump = ( LevelBump.MAJOR if body_components["breaking_descriptions"] or parsed_break - else self.options.tag_to_level.get( - parsed_type, self.options.default_bump_level - ) + else self.options.tag_to_level.get(parsed_type, LevelBump.NO_RELEASE) ) return ParsedMessageResult( diff --git a/src/semantic_release/commit_parser/emoji.py b/src/semantic_release/commit_parser/emoji.py index 801160208..fc8386ac3 100644 --- a/src/semantic_release/commit_parser/emoji.py +++ b/src/semantic_release/commit_parser/emoji.py @@ -76,9 +76,6 @@ class EmojiParserOptions(ParserOptions): ) """All commit-type prefixes that are allowed.""" - default_bump_level: LevelBump = LevelBump.NO_RELEASE - """The minimum bump level to apply to valid commit message.""" - parse_linked_issues: bool = False """ Whether to parse linked issues from the commit message. @@ -111,7 +108,7 @@ def __post_init__(self) -> None: # for our expected output. Due to the empty second array, we know the first is always longest # and that means no values in the first entry of the tuples will ever be a LevelBump. We # apply a str() to make mypy happy although it will never happen. - *zip_longest(self.allowed_tags, (), fillvalue=self.default_bump_level), + *zip_longest(self.allowed_tags, (), fillvalue=LevelBump.NO_RELEASE), *zip_longest(self.patch_tags, (), fillvalue=LevelBump.PATCH), *zip_longest(self.minor_tags, (), fillvalue=LevelBump.MINOR), *zip_longest(self.major_tags, (), fillvalue=LevelBump.MAJOR), @@ -280,9 +277,7 @@ def parse_message(self, message: str) -> ParsedMessageResult: primary_emoji = match.group("type") if match else "Other" parsed_scope = (match.group("scope") if match else None) or "" - level_bump = self.options.tag_to_level.get( - primary_emoji, self.options.default_bump_level - ) + level_bump = self.options.tag_to_level.get(primary_emoji, LevelBump.NO_RELEASE) # All emojis will remain part of the returned description body_components: dict[str, list[str]] = reduce( diff --git a/src/semantic_release/commit_parser/scipy.py b/src/semantic_release/commit_parser/scipy.py index e6988ea83..6fef82a58 100644 --- a/src/semantic_release/commit_parser/scipy.py +++ b/src/semantic_release/commit_parser/scipy.py @@ -145,10 +145,6 @@ class ScipyParserOptions(ParserOptions): one of these prefixes, it will not be considered a valid commit message. """ - # TODO: breaking v11, make consistent with AngularParserOptions - default_level_bump: LevelBump = LevelBump.NO_RELEASE - """The minimum bump level to apply to valid commit message.""" - parse_squash_commits: bool = True """Toggle flag for whether or not to parse squash commits""" @@ -161,8 +157,6 @@ def tag_to_level(self) -> dict[str, LevelBump]: return self._tag_to_level def __post_init__(self) -> None: - # TODO: breaking v11, remove as the name is now consistent - self.default_bump_level = self.default_level_bump self._tag_to_level: dict[str, LevelBump] = { str(tag): level for tag, level in [ @@ -170,7 +164,7 @@ def __post_init__(self) -> None: # for our expected output. Due to the empty second array, we know the first is always longest # and that means no values in the first entry of the tuples will ever be a LevelBump. We # apply a str() to make mypy happy although it will never happen. - *zip_longest(self.allowed_tags, (), fillvalue=self.default_bump_level), + *zip_longest(self.allowed_tags, (), fillvalue=LevelBump.NO_RELEASE), *zip_longest(self.patch_tags, (), fillvalue=LevelBump.PATCH), *zip_longest(self.minor_tags, (), fillvalue=LevelBump.MINOR), *zip_longest(self.major_tags, (), fillvalue=LevelBump.MAJOR), @@ -347,9 +341,7 @@ def parse_message(self, message: str) -> ParsedMessageResult | None: }, ) - level_bump = self.options.tag_to_level.get( - parsed_type, self.options.default_bump_level - ) + level_bump = self.options.tag_to_level.get(parsed_type, LevelBump.NO_RELEASE) return ParsedMessageResult( bump=level_bump, diff --git a/tests/unit/semantic_release/cli/test_config.py b/tests/unit/semantic_release/cli/test_config.py index 343748187..972cb0a34 100644 --- a/tests/unit/semantic_release/cli/test_config.py +++ b/tests/unit/semantic_release/cli/test_config.py @@ -30,7 +30,6 @@ from semantic_release.commit_parser.scipy import ScipyParserOptions from semantic_release.commit_parser.tag import TagParserOptions from semantic_release.const import DEFAULT_COMMIT_AUTHOR -from semantic_release.enums import LevelBump from semantic_release.errors import ParserLoadError from tests.fixtures.repos import repo_w_no_tags_conventional_commits @@ -138,7 +137,6 @@ def test_load_user_defined_parser_opts(): "allowed_tags": ["foo", "bar", "baz"], "minor_tags": ["bar"], "patch_tags": ["baz"], - "default_bump_level": LevelBump.PATCH.value, } raw_config = RawConfig.model_validate( { diff --git a/tests/unit/semantic_release/commit_parser/test_conventional.py b/tests/unit/semantic_release/commit_parser/test_conventional.py index 9298c1f24..0f7f20169 100644 --- a/tests/unit/semantic_release/commit_parser/test_conventional.py +++ b/tests/unit/semantic_release/commit_parser/test_conventional.py @@ -1116,8 +1116,9 @@ def test_parser_return_release_notices_from_commit_message( ############################## # test custom parser options # ############################## -def test_parser_custom_default_level(make_commit_obj: MakeCommitObjFn): - options = ConventionalCommitParserOptions(default_bump_level=LevelBump.MINOR) +def test_parser_other_allowed_tags_no_bump(make_commit_obj: MakeCommitObjFn): + """Test that commits with other_allowed_tags get NO_RELEASE bump level.""" + options = ConventionalCommitParserOptions() parsed_results = ConventionalCommitParser(options).parse( make_commit_obj("test(parser): add a test for conventional parser") ) @@ -1126,7 +1127,7 @@ def test_parser_custom_default_level(make_commit_obj: MakeCommitObjFn): result = next(iter(parsed_results)) assert isinstance(result, ParsedCommit) - assert result.bump is LevelBump.MINOR + assert result.bump is LevelBump.NO_RELEASE def test_parser_custom_allowed_types( diff --git a/tests/unit/semantic_release/commit_parser/test_emoji.py b/tests/unit/semantic_release/commit_parser/test_emoji.py index c477579ec..558dba01a 100644 --- a/tests/unit/semantic_release/commit_parser/test_emoji.py +++ b/tests/unit/semantic_release/commit_parser/test_emoji.py @@ -1073,3 +1073,17 @@ def test_parser_ignore_merge_commit( assert isinstance(parsed_result, ParseError) assert "Ignoring merge commit" in parsed_result.error + + +def test_parser_other_allowed_tags_no_bump(make_commit_obj: MakeCommitObjFn): + """Test that commits with other_allowed_tags get NO_RELEASE bump level.""" + options = EmojiParserOptions() + parsed_results = EmojiCommitParser(options).parse( + make_commit_obj(":memo: add documentation for emoji parser") + ) + + assert isinstance(parsed_results, Iterable) + + result = next(iter(parsed_results)) + assert isinstance(result, ParsedCommit) + assert result.bump is LevelBump.NO_RELEASE diff --git a/tests/unit/semantic_release/commit_parser/test_scipy.py b/tests/unit/semantic_release/commit_parser/test_scipy.py index ce714c0bc..49313c014 100644 --- a/tests/unit/semantic_release/commit_parser/test_scipy.py +++ b/tests/unit/semantic_release/commit_parser/test_scipy.py @@ -1361,3 +1361,17 @@ def test_parser_ignore_merge_commit( assert isinstance(parsed_result, ParseError) assert "Ignoring merge commit" in parsed_result.error + + +def test_parser_other_allowed_tags_no_bump(make_commit_obj: MakeCommitObjFn): + """Test that commits with other_allowed_tags get NO_RELEASE bump level.""" + options = ScipyParserOptions() + parsed_results = ScipyCommitParser(options).parse( + make_commit_obj("TST: add a test for scipy parser") + ) + + assert isinstance(parsed_results, Iterable) + + result = next(iter(parsed_results)) + assert isinstance(result, ParsedCommit) + assert result.bump is LevelBump.NO_RELEASE