Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-specfile for openSUSE:Factory checked in at 2023-11-08 22:18:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-specfile (Old) and /work/SRC/openSUSE:Factory/.python-specfile.new.17445 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-specfile" Wed Nov 8 22:18:47 2023 rev:17 rq:1124208 version:0.24.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-specfile/python-specfile.changes 2023-10-30 22:11:39.226138880 +0100 +++ /work/SRC/openSUSE:Factory/.python-specfile.new.17445/python-specfile.changes 2023-11-08 22:20:06.744429080 +0100 @@ -1,0 +2,13 @@ +Wed Nov 8 10:08:44 UTC 2023 - Matej Cepl <mc...@suse.com> + +- Update to 0.24.0: + - Improved type annotations for UserList subclasses. (#299) + - Macro definitions gained a new commented_out property + indicating that a macro definition is commented out. Another + new property, comment_out_style, determines if it is achieved + by using a %dnl (discard next line) directive (e.g. %dnl + %global prerelease beta2) or by replacing the starting % with + # (e.g. #global prerelease beta2). (#298) +- Fix a bad Requires: %{python_module typing_extensions} + +------------------------------------------------------------------- Old: ---- specfile-0.23.0.tar.gz New: ---- specfile-0.24.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-specfile.spec ++++++ --- /var/tmp/diff_new_pack.Zk9ogp/_old 2023-11-08 22:20:07.256447889 +0100 +++ /var/tmp/diff_new_pack.Zk9ogp/_new 2023-11-08 22:20:07.256447889 +0100 @@ -17,7 +17,7 @@ Name: python-specfile -Version: 0.23.0 +Version: 0.24.0 Release: 0 Summary: A library for parsing and manipulating RPM spec files License: MIT @@ -29,8 +29,8 @@ BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: %{python_module typing_extensions} Requires: python-rpm +Requires: python-typing_extensions BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module flexmock} ++++++ specfile-0.23.0.tar.gz -> specfile-0.24.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/.pre-commit-config.yaml new/specfile-0.24.0/.pre-commit-config.yaml --- old/specfile-0.23.0/.pre-commit-config.yaml 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/.pre-commit-config.yaml 2023-11-06 18:15:33.000000000 +0100 @@ -4,11 +4,11 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.14.0 + rev: v3.15.0 hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier @@ -16,7 +16,7 @@ hooks: - id: prettier - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files - id: check-ast @@ -44,14 +44,14 @@ - id: isort args: [--profile, black] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 + rev: v1.6.1 hooks: - id: mypy args: [--show-error-codes, --ignore-missing-imports] additional_dependencies: [types-pkg_resources, types-requests, types-python-dateutil] - repo: https://github.com/teemtee/tmt.git - rev: 1.27.0 + rev: 1.28.2 hooks: - id: tmt-lint # linting of the reverse-dependency tests requires internet access diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/CHANGELOG.md new/specfile-0.24.0/CHANGELOG.md --- old/specfile-0.23.0/CHANGELOG.md 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/CHANGELOG.md 2023-11-06 18:15:33.000000000 +0100 @@ -1,3 +1,8 @@ +# 0.24.0 + +- Improved type annotations for `UserList` subclasses. (#299) +- Macro definitions gained a new `commented_out` property indicating that a macro definition is commented out. Another new property, `comment_out_style`, determines if it is achieved by using a `%dnl` (discard next line) directive (e.g. `%dnl %global prerelease beta2`) or by replacing the starting `%` with `#` (e.g. `#global prerelease beta2`). (#298) + # 0.23.0 - Sources now have a `valid` property that indicates whether a source is valid in the current context, meaning it is not present in a false branch of any condition. (#295) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/PKG-INFO new/specfile-0.24.0/PKG-INFO --- old/specfile-0.23.0/PKG-INFO 2023-10-30 10:13:11.669105000 +0100 +++ new/specfile-0.24.0/PKG-INFO 2023-11-06 18:15:41.694350700 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: specfile -Version: 0.23.0 +Version: 0.24.0 Summary: A library for parsing and manipulating RPM spec files. Home-page: https://github.com/packit/specfile Author: Red Hat @@ -49,9 +49,9 @@ Section is a spec file section, it has a well-defined name that starts with _%_ character and that can optionally be followed by arguments. -In this library, the starting _%_ of section name is ommited for convenience. +In this library, the starting _%_ of section name is omitted for convenience. -There is a special section internally called `%package`, often also referred to as preamble, and it represents the content of the spec file that preceeds the first named section (usually `%description`). This section contains the main package metadata (tags). Metadata of subpackages are defined in subsequent `%package` sections, that are not anonymous and are always followed by arguments specifying the name of the subpackage (e.g. `%package doc` or `%package -n completely-different-subpackage-name`). +There is a special section internally called `%package`, often also referred to as preamble, and it represents the content of the spec file that precedes the first named section (usually `%description`). This section contains the main package metadata (tags). Metadata of subpackages are defined in subsequent `%package` sections, that are not anonymous and are always followed by arguments specifying the name of the subpackage (e.g. `%package doc` or `%package -n completely-different-subpackage-name`). ### Tag diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/README.md new/specfile-0.24.0/README.md --- old/specfile-0.23.0/README.md 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/README.md 2023-11-06 18:15:33.000000000 +0100 @@ -12,9 +12,9 @@ Section is a spec file section, it has a well-defined name that starts with _%_ character and that can optionally be followed by arguments. -In this library, the starting _%_ of section name is ommited for convenience. +In this library, the starting _%_ of section name is omitted for convenience. -There is a special section internally called `%package`, often also referred to as preamble, and it represents the content of the spec file that preceeds the first named section (usually `%description`). This section contains the main package metadata (tags). Metadata of subpackages are defined in subsequent `%package` sections, that are not anonymous and are always followed by arguments specifying the name of the subpackage (e.g. `%package doc` or `%package -n completely-different-subpackage-name`). +There is a special section internally called `%package`, often also referred to as preamble, and it represents the content of the spec file that precedes the first named section (usually `%description`). This section contains the main package metadata (tags). Metadata of subpackages are defined in subsequent `%package` sections, that are not anonymous and are always followed by arguments specifying the name of the subpackage (e.g. `%package doc` or `%package -n completely-different-subpackage-name`). ### Tag diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/epel8/python-specfile.spec new/specfile-0.24.0/epel8/python-specfile.spec --- old/specfile-0.23.0/epel8/python-specfile.spec 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/epel8/python-specfile.spec 2023-11-06 18:15:33.000000000 +0100 @@ -5,7 +5,7 @@ Name: python-specfile -Version: 0.23.0 +Version: 0.24.0 Release: 1%{?dist} Summary: A library for parsing and manipulating RPM spec files @@ -61,6 +61,9 @@ %changelog +* Mon Nov 06 2023 Packit Team <he...@packit.dev> - 0.24.0-1 +- New upstream release 0.24.0 + * Sun Oct 29 2023 Packit Team <he...@packit.dev> - 0.23.0-1 - New upstream release 0.23.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/fedora/python-specfile.spec new/specfile-0.24.0/fedora/python-specfile.spec --- old/specfile-0.23.0/fedora/python-specfile.spec 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/fedora/python-specfile.spec 2023-11-06 18:15:33.000000000 +0100 @@ -8,7 +8,7 @@ Name: python-specfile -Version: 0.23.0 +Version: 0.24.0 Release: 1%{?dist} Summary: A library for parsing and manipulating RPM spec files @@ -70,6 +70,9 @@ %changelog +* Mon Nov 06 2023 Packit Team <he...@packit.dev> - 0.24.0-1 +- New upstream release 0.24.0 + * Sun Oct 29 2023 Packit Team <he...@packit.dev> - 0.23.0-1 - New upstream release 0.23.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/changelog.py new/specfile-0.24.0/specfile/changelog.py --- old/specfile-0.23.0/specfile/changelog.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/changelog.py 2023-11-06 18:15:33.000000000 +0100 @@ -1,7 +1,6 @@ # Copyright Contributors to the Packit project. # SPDX-License-Identifier: MIT -import collections import copy import datetime import getpass @@ -19,7 +18,7 @@ from specfile.macros import Macros from specfile.sections import Section from specfile.types import SupportsIndex -from specfile.utils import EVR +from specfile.utils import EVR, UserList WEEKDAYS = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") MONTHS = ( @@ -199,7 +198,7 @@ return cls(header, content, [""] if append_newline else None) -class Changelog(collections.UserList): +class Changelog(UserList[ChangelogEntry]): """ Class that represents a changelog. @@ -326,7 +325,7 @@ Constructed instance of `Changelog` class. """ - def extract_following_lines(content): + def extract_following_lines(content: List[str]) -> List[str]: following_lines: List[str] = [] while content and not content[-1].strip(): following_lines.insert(0, content.pop()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/conditions.py new/specfile-0.24.0/specfile/conditions.py --- old/specfile-0.23.0/specfile/conditions.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/conditions.py 2023-11-06 18:15:33.000000000 +0100 @@ -79,9 +79,10 @@ List of tuples in the form of (line, validity). """ excluded_lines = [] - for md in macro_definitions or []: - position = md.get_position(macro_definitions) - excluded_lines.append(range(position, position + len(md.body.splitlines()))) + if macro_definitions: + for md in macro_definitions: + position = md.get_position(macro_definitions) + excluded_lines.append(range(position, position + len(md.body.splitlines()))) condition_regex = re.compile( r""" ^ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/macro_definitions.py new/specfile-0.24.0/specfile/macro_definitions.py --- old/specfile-0.23.0/specfile/macro_definitions.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/macro_definitions.py 2023-11-06 18:15:33.000000000 +0100 @@ -1,33 +1,45 @@ # Copyright Contributors to the Packit project. # SPDX-License-Identifier: MIT -import collections import copy import re +from enum import Enum, auto from typing import TYPE_CHECKING, List, Optional, Tuple, Union, overload from specfile.conditions import process_conditions from specfile.formatter import formatted from specfile.types import SupportsIndex +from specfile.utils import UserList if TYPE_CHECKING: from specfile.specfile import Specfile +class CommentOutStyle(Enum): + DNL = auto() + HASH = auto() + + class MacroDefinition: def __init__( self, name: str, body: str, is_global: bool, + commented_out: bool, + comment_out_style: CommentOutStyle, whitespace: Tuple[str, str, str, str], + dnl_whitespace: str = "", valid: bool = True, preceding_lines: Optional[List[str]] = None, ) -> None: self.name = name self.body = body self.is_global = is_global + self.commented_out = commented_out + self.comment_out_style = comment_out_style self._whitespace = whitespace + self._dnl_whitespace = dnl_whitespace self.valid = valid self._preceding_lines = ( preceding_lines.copy() if preceding_lines is not None else [] @@ -40,7 +52,10 @@ self.name == other.name and self.body == other.body and self.is_global == other.is_global + and self.commented_out == other.commented_out + and self.comment_out_style == other.comment_out_style and self._whitespace == other._whitespace + and self._dnl_whitespace == other._dnl_whitespace and self._preceding_lines == other._preceding_lines ) @@ -48,13 +63,21 @@ def __repr__(self) -> str: return ( f"MacroDefinition({self.name!r}, {self.body!r}, {self.is_global!r}, " - f"{self._whitespace!r}, {self.valid!r}, {self._preceding_lines!r})" + f"{self.commented_out!r}, {self.comment_out_style!r}, {self._whitespace!r}, " + f"{self.valid!r}, {self._preceding_lines!r})" ) def __str__(self) -> str: ws = self._whitespace - macro = "%global" if self.is_global else "%define" - return f"{ws[0]}{macro}{ws[1]}{self.name}{ws[2]}{self.body}{ws[3]}" + dnl = "" + sc = "%" + if self.commented_out: + if self.comment_out_style is CommentOutStyle.DNL: + dnl = f"%dnl{self._dnl_whitespace}" + elif self.comment_out_style is CommentOutStyle.HASH: + sc = "#" + macro = "global" if self.is_global else "define" + return f"{ws[0]}{dnl}{sc}{macro}{ws[1]}{self.name}{ws[2]}{self.body}{ws[3]}" def get_position(self, container: "MacroDefinitions") -> int: """ @@ -73,18 +96,25 @@ def get_raw_data(self) -> List[str]: result = self._preceding_lines.copy() ws = self._whitespace - macro = "%global" if self.is_global else "%define" + dnl = "" + sc = "%" + if self.commented_out: + if self.comment_out_style is CommentOutStyle.DNL: + dnl = f"%dnl{self._dnl_whitespace}" + elif self.comment_out_style is CommentOutStyle.HASH: + sc = "#" + macro = "global" if self.is_global else "define" body = self.body.splitlines() if body: body[-1] += ws[3] else: body = [ws[3]] - result.append(f"{ws[0]}{macro}{ws[1]}{self.name}{ws[2]}{body[0]}") + result.append(f"{ws[0]}{dnl}{sc}{macro}{ws[1]}{self.name}{ws[2]}{body[0]}") result.extend(body[1:]) return result -class MacroDefinitions(collections.UserList): +class MacroDefinitions(UserList[MacroDefinition]): """ Class that represents all macro definitions. @@ -132,7 +162,7 @@ except ValueError: raise AttributeError(name) - def __setattr__(self, name: str, value: Union[MacroDefinition, List[str]]) -> None: + def __setattr__(self, name: str, value: Union[MacroDefinition, str]) -> None: if name not in self: return super().__setattr__(name, value) try: @@ -249,7 +279,9 @@ r""" ^ (\s*) # optional preceding whitespace - (%(?:global|define)) # scope-defining macro definition + (%dnl\s+)? # optional DNL prefix + ((?(2)%|(?:%|\#))) # starting character + (global|define) # scope-defining macro definition (\s+) (\w+(?:\(.*?\))?) # macro name with optional arguments in parentheses (\s+) @@ -267,15 +299,16 @@ line, valid = pop(lines) m = md_regex.match(line) if m: - ws0, macro, ws1, name, ws2, body, ws3 = m.groups() - if ws3 == "\\": - body += ws3 - ws3 = "" - bc, pc = count_brackets(body) - while (bc > 0 or pc > 0 or body.endswith("\\")) and lines: - line, _ = pop(lines) - body += "\n" + line + ws0, dnl, sc, macro, ws1, name, ws2, body, ws3 = m.groups() + if not dnl and sc == "%": + if ws3 == "\\": + body += ws3 + ws3 = "" bc, pc = count_brackets(body) + while (bc > 0 or pc > 0 or body.endswith("\\")) and lines: + line, _ = pop(lines) + body += "\n" + line + bc, pc = count_brackets(body) tokens = re.split(r"(\s+)$", body, maxsplit=1) if len(tokens) == 1: body = tokens[0] @@ -286,8 +319,11 @@ MacroDefinition( name, body, - macro == "%global", + macro == "global", + bool(dnl or sc == "#"), + CommentOutStyle.HASH if sc == "#" else CommentOutStyle.DNL, (ws0, ws1, ws2, ws3), + dnl[4:] if dnl else "", valid, buffer, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/prep.py new/specfile-0.24.0/specfile/prep.py --- old/specfile-0.23.0/specfile/prep.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/prep.py 2023-11-06 18:15:33.000000000 +0100 @@ -11,7 +11,7 @@ from specfile.options import Options from specfile.sections import Section from specfile.types import SupportsIndex -from specfile.utils import split_conditional_macro_expansion +from specfile.utils import UserList, split_conditional_macro_expansion def valid_prep_macro(name: str) -> bool: @@ -149,7 +149,7 @@ DEFAULTS: Dict[str, Union[bool, int, str]] = {} -class PrepMacros(collections.UserList): +class PrepMacros(UserList[PrepMacro]): """ Class that represents a list of %prep macros. @@ -185,7 +185,7 @@ if isinstance(item, type): return any(isinstance(m, item) for m in self.data) return any( - m.name.startswith(item) if item == "%patch" else m.name == item + m.name.startswith(cast(str, item)) if item == "%patch" else m.name == item for m in self.data ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/sections.py new/specfile-0.24.0/specfile/sections.py --- old/specfile-0.23.0/specfile/sections.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/sections.py 2023-11-06 18:15:33.000000000 +0100 @@ -18,6 +18,7 @@ from specfile.macros import Macros from specfile.options import Options from specfile.types import SupportsIndex +from specfile.utils import UserList if TYPE_CHECKING: from specfile.specfile import Specfile @@ -139,7 +140,7 @@ return str(self).splitlines() -class Sections(collections.UserList): +class Sections(UserList[Section]): """ Class that represents all spec file sections, hence the entire spec file. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/sourcelist.py new/specfile-0.24.0/specfile/sourcelist.py --- old/specfile-0.23.0/specfile/sourcelist.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/sourcelist.py 2023-11-06 18:15:33.000000000 +0100 @@ -1,7 +1,6 @@ # Copyright Contributors to the Packit project. # SPDX-License-Identifier: MIT -import collections import copy from typing import TYPE_CHECKING, Any, Dict, List, Optional, overload @@ -12,6 +11,7 @@ from specfile.sections import Section from specfile.tags import Comments from specfile.types import SupportsIndex +from specfile.utils import UserList if TYPE_CHECKING: from specfile.specfile import Specfile @@ -81,7 +81,7 @@ return Macros.expand(self.location) -class Sourcelist(collections.UserList): +class Sourcelist(UserList[SourcelistEntry]): """ Class that represents entries in a %sourcelist/%patchlist section. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/sources.py new/specfile-0.24.0/specfile/sources.py --- old/specfile-0.23.0/specfile/sources.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/sources.py 2023-11-06 18:15:33.000000000 +0100 @@ -539,7 +539,7 @@ valid = self._get_tag_validity(cast(TagSource, source)) container.insert( index, - Tag( + Tag( # type: ignore[arg-type] name, location, separator, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/specfile.py new/specfile-0.24.0/specfile/specfile.py --- old/specfile-0.23.0/specfile/specfile.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/specfile.py 2023-11-06 18:15:33.000000000 +0100 @@ -730,6 +730,7 @@ ) for md in macro_definitions if md.valid + and not md.commented_out and not protected_regex.match(md.name) and not md.name.endswith(")") # skip macro definitions with options ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/tags.py new/specfile-0.24.0/specfile/tags.py --- old/specfile-0.23.0/specfile/tags.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/tags.py 2023-11-06 18:15:33.000000000 +0100 @@ -1,7 +1,6 @@ # Copyright Contributors to the Packit project. # SPDX-License-Identifier: MIT -import collections import copy import itertools import re @@ -24,7 +23,7 @@ from specfile.macros import Macros from specfile.sections import Section from specfile.types import SupportsIndex -from specfile.utils import split_conditional_macro_expansion +from specfile.utils import UserList, split_conditional_macro_expansion if TYPE_CHECKING: from specfile.specfile import Specfile @@ -66,7 +65,7 @@ return f"Comment({self.text!r}, {self.prefix!r})" -class Comments(collections.UserList): +class Comments(UserList[Comment]): """ Class that represents comments associated with a tag, that is consecutive comment lines located directly above a tag definition. @@ -312,7 +311,7 @@ ) + len(self.comments.get_raw_data()) -class Tags(collections.UserList): +class Tags(UserList[Tag]): """ Class that represents all tags in a certain %package section. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile/utils.py new/specfile-0.24.0/specfile/utils.py --- old/specfile-0.23.0/specfile/utils.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/specfile/utils.py 2023-11-06 18:15:33.000000000 +0100 @@ -3,7 +3,8 @@ import collections import re -from typing import Tuple +import sys +from typing import TYPE_CHECKING, Tuple from specfile.constants import ARCH_NAMES from specfile.exceptions import SpecfileException, UnterminatedMacroException @@ -160,3 +161,13 @@ if not isinstance(node, ConditionalMacroExpansion): return value, "", "" return "".join(str(n) for n in node.body), f"%{{{node.prefix}{node.name}:", "}" + + +# Python 3.6-3.8 do not allow creating a generic UserList at runtime. +# This hack allows type checkers to determine the UserList dunder method return +# types while still working at runtime. +if TYPE_CHECKING or sys.version_info >= (3, 9): + UserList = collections.UserList +else: + # UserList[...] always returns a UserList + UserList = collections.defaultdict(lambda: collections.UserList) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/specfile.egg-info/PKG-INFO new/specfile-0.24.0/specfile.egg-info/PKG-INFO --- old/specfile-0.23.0/specfile.egg-info/PKG-INFO 2023-10-30 10:13:11.000000000 +0100 +++ new/specfile-0.24.0/specfile.egg-info/PKG-INFO 2023-11-06 18:15:41.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: specfile -Version: 0.23.0 +Version: 0.24.0 Summary: A library for parsing and manipulating RPM spec files. Home-page: https://github.com/packit/specfile Author: Red Hat @@ -49,9 +49,9 @@ Section is a spec file section, it has a well-defined name that starts with _%_ character and that can optionally be followed by arguments. -In this library, the starting _%_ of section name is ommited for convenience. +In this library, the starting _%_ of section name is omitted for convenience. -There is a special section internally called `%package`, often also referred to as preamble, and it represents the content of the spec file that preceeds the first named section (usually `%description`). This section contains the main package metadata (tags). Metadata of subpackages are defined in subsequent `%package` sections, that are not anonymous and are always followed by arguments specifying the name of the subpackage (e.g. `%package doc` or `%package -n completely-different-subpackage-name`). +There is a special section internally called `%package`, often also referred to as preamble, and it represents the content of the spec file that precedes the first named section (usually `%description`). This section contains the main package metadata (tags). Metadata of subpackages are defined in subsequent `%package` sections, that are not anonymous and are always followed by arguments specifying the name of the subpackage (e.g. `%package doc` or `%package -n completely-different-subpackage-name`). ### Tag diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/specfile-0.23.0/tests/unit/test_macro_definitions.py new/specfile-0.24.0/tests/unit/test_macro_definitions.py --- old/specfile-0.23.0/tests/unit/test_macro_definitions.py 2023-10-30 10:13:03.000000000 +0100 +++ new/specfile-0.24.0/tests/unit/test_macro_definitions.py 2023-11-06 18:15:33.000000000 +0100 @@ -5,21 +5,39 @@ import pytest -from specfile.macro_definitions import MacroDefinition, MacroDefinitions +from specfile.macro_definitions import ( + CommentOutStyle, + MacroDefinition, + MacroDefinitions, +) def test_find(): macro_definitions = MacroDefinitions( [ - MacroDefinition("gitdate", "20160901", True, ("", " ", " ", "")), + MacroDefinition( + "gitdate", + "20160901", + True, + False, + CommentOutStyle.DNL, + ("", " ", " ", ""), + ), MacroDefinition( "commit", "9ab9717cf7d1be1a85b165a8eacb71b9e5831113", True, + False, + CommentOutStyle.DNL, ("", " ", " ", ""), ), MacroDefinition( - "shortcommit", "%(c=%{commit}; echo ${c:0:7})", True, ("", " ", " ", "") + "shortcommit", + "%(c=%{commit}; echo ${c:0:7})", + True, + False, + CommentOutStyle.DNL, + ("", " ", " ", ""), ), ] ) @@ -32,15 +50,29 @@ def test_get(): macro_definitions = MacroDefinitions( [ - MacroDefinition("gitdate", "20160901", True, ("", " ", " ", "")), + MacroDefinition( + "gitdate", + "20160901", + True, + False, + CommentOutStyle.DNL, + ("", " ", " ", ""), + ), MacroDefinition( "commit", "9ab9717cf7d1be1a85b165a8eacb71b9e5831113", True, + False, + CommentOutStyle.DNL, ("", " ", " ", ""), ), MacroDefinition( - "shortcommit", "%(c=%{commit}; echo ${c:0:7})", True, ("", " ", " ", "") + "shortcommit", + "%(c=%{commit}; echo ${c:0:7})", + True, + False, + CommentOutStyle.DNL, + ("", " ", " ", ""), ), ] ) @@ -59,6 +91,9 @@ "%global commit 9ab9717cf7d1be1a85b165a8eacb71b9e5831113", "%global shortcommit %(c=%{commit}; echo ${c:0:7})", "", + "%dnl %global pre a1", + "#global prerel beta2", + "", "Name: test", "Version: 0.1.0", "", @@ -74,8 +109,14 @@ assert macro_definitions[1].name == "commit" assert macro_definitions.commit.body == "9ab9717cf7d1be1a85b165a8eacb71b9e5831113" assert macro_definitions[2].name == "shortcommit" - assert macro_definitions[3].name == "desc(x)" - assert macro_definitions[3].body == ( + assert macro_definitions[3].name == "pre" + assert macro_definitions[3].commented_out + assert macro_definitions[3].comment_out_style is CommentOutStyle.DNL + assert macro_definitions[4].name == "prerel" + assert macro_definitions[4].commented_out + assert macro_definitions[4].comment_out_style is CommentOutStyle.HASH + assert macro_definitions[5].name == "desc(x)" + assert macro_definitions[5].body == ( "Test spec file containing several \\\n" "macro definitions in various formats (%?1)" ) @@ -90,21 +131,57 @@ def test_get_raw_data(): macro_definitions = MacroDefinitions( [ - MacroDefinition("gitdate", "20160901", True, ("", " ", " ", "")), + MacroDefinition( + "gitdate", + "20160901", + True, + False, + CommentOutStyle.DNL, + ("", " ", " ", ""), + ), MacroDefinition( "commit", "9ab9717cf7d1be1a85b165a8eacb71b9e5831113", True, + False, + CommentOutStyle.DNL, ("", " ", " ", ""), ), MacroDefinition( - "shortcommit", "%(c=%{commit}; echo ${c:0:7})", True, ("", " ", " ", "") + "shortcommit", + "%(c=%{commit}; echo ${c:0:7})", + True, + False, + CommentOutStyle.DNL, + ("", " ", " ", ""), + ), + MacroDefinition( + "pre", + "a1", + True, + True, + CommentOutStyle.DNL, + ("", " ", " ", ""), + " ", + True, + [""], + ), + MacroDefinition( + "prerel", + "beta2", + True, + True, + CommentOutStyle.HASH, + ("", " ", " ", ""), ), MacroDefinition( "desc(x)", "Test spec file containing several \\\nmacro definitions in various formats (%?1)", False, + False, + CommentOutStyle.DNL, ("", " ", " ", ""), + "", True, [ "", @@ -119,7 +196,10 @@ "This an example of a macro definition with body \n" "spawning across mutiple lines}", False, + False, + CommentOutStyle.DNL, ("", " ", " ", ""), + "", True, [""], ), @@ -130,6 +210,9 @@ "%global commit 9ab9717cf7d1be1a85b165a8eacb71b9e5831113", "%global shortcommit %(c=%{commit}; echo ${c:0:7})", "", + "%dnl %global pre a1", + "#global prerel beta2", + "", "Name: test", "Version: 0.1.0", "", @@ -149,6 +232,8 @@ "commit", "9ab9717cf7d1be1a85b165a8eacb71b9e5831113", True, + False, + CommentOutStyle.DNL, ("", " ", " ", ""), ), ],