Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-importlib-metadata for openSUSE:Factory checked in at 2023-05-09 13:06:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-importlib-metadata (Old) and /work/SRC/openSUSE:Factory/.python-importlib-metadata.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-importlib-metadata" Tue May 9 13:06:30 2023 rev:20 rq:1084915 version:6.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-importlib-metadata/python-importlib-metadata.changes 2023-04-22 22:01:18.505520637 +0200 +++ /work/SRC/openSUSE:Factory/.python-importlib-metadata.new.1533/python-importlib-metadata.changes 2023-05-09 13:06:39.924780845 +0200 @@ -1,0 +2,15 @@ +Thu May 4 21:32:41 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 6.6.0: + * Expanded type annotations. + * python/cpython#103661: Removed excess error suppression in + ``_read_files_egginfo_installed`` and fixed path handling + on Windows. + * #422: Removed ABC metaclass from ``Distribution`` and instead + deprecated construction of ``Distribution`` objects without + concrete methods. + * Updated docs with tweaks from upstream CPython. + * Consolidated some behaviors in tests around ``_path``. + * Added type annotation for ``Distribution.read_text``. + +------------------------------------------------------------------- Old: ---- importlib_metadata-6.3.0.tar.gz New: ---- importlib_metadata-6.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-importlib-metadata.spec ++++++ --- /var/tmp/diff_new_pack.gkPrPH/_old 2023-05-09 13:06:40.600784868 +0200 +++ /var/tmp/diff_new_pack.gkPrPH/_new 2023-05-09 13:06:40.604784892 +0200 @@ -28,7 +28,7 @@ %define skip_python2 1 %{?sle15_python_module_pythons} Name: python-importlib-metadata%{psuffix} -Version: 6.3.0 +Version: 6.6.0 Release: 0 Summary: Read metadata from Python packages License: Apache-2.0 ++++++ importlib_metadata-6.3.0.tar.gz -> importlib_metadata-6.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/CHANGES.rst new/importlib_metadata-6.6.0/CHANGES.rst --- old/importlib_metadata-6.3.0/CHANGES.rst 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/CHANGES.rst 2023-04-22 14:56:31.000000000 +0200 @@ -1,3 +1,33 @@ +v6.6.0 +====== + +* #449: Expanded type annotations. + +v6.5.1 +====== + +* python/cpython#103661: Removed excess error suppression in + ``_read_files_egginfo_installed`` and fixed path handling + on Windows. + +v6.5.0 +====== + +* #422: Removed ABC metaclass from ``Distribution`` and instead + deprecated construction of ``Distribution`` objects without + concrete methods. + +v6.4.1 +====== + +* Updated docs with tweaks from upstream CPython. + +v6.4.0 +====== + +* Consolidated some behaviors in tests around ``_path``. +* Added type annotation for ``Distribution.read_text``. + v6.3.0 ====== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/PKG-INFO new/importlib_metadata-6.6.0/PKG-INFO --- old/importlib_metadata-6.3.0/PKG-INFO 2023-04-10 04:27:32.096812500 +0200 +++ new/importlib_metadata-6.6.0/PKG-INFO 2023-04-22 14:56:52.094148400 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: importlib_metadata -Version: 6.3.0 +Version: 6.6.0 Summary: Read metadata from Python packages Home-page: https://github.com/python/importlib_metadata Author: Jason R. Coombs @@ -57,7 +57,7 @@ * - importlib_metadata - stdlib - * - 5.0 + * - 6.5 - 3.12 * - 4.13 - 3.11 @@ -70,7 +70,7 @@ Usage ===== -See the `online documentation <https://importlib_metadata.readthedocs.io/>`_ +See the `online documentation <https://importlib-metadata.readthedocs.io/>`_ for usage details. `Finder authors @@ -94,7 +94,7 @@ * Project home: https://github.com/python/importlib_metadata * Report bugs at: https://github.com/python/importlib_metadata/issues * Code hosting: https://github.com/python/importlib_metadata - * Documentation: https://importlib_metadata.readthedocs.io/ + * Documentation: https://importlib-metadata.readthedocs.io/ For Enterprise ============== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/README.rst new/importlib_metadata-6.6.0/README.rst --- old/importlib_metadata-6.3.0/README.rst 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/README.rst 2023-04-22 14:56:31.000000000 +0200 @@ -39,7 +39,7 @@ * - importlib_metadata - stdlib - * - 5.0 + * - 6.5 - 3.12 * - 4.13 - 3.11 @@ -52,7 +52,7 @@ Usage ===== -See the `online documentation <https://importlib_metadata.readthedocs.io/>`_ +See the `online documentation <https://importlib-metadata.readthedocs.io/>`_ for usage details. `Finder authors @@ -76,7 +76,7 @@ * Project home: https://github.com/python/importlib_metadata * Report bugs at: https://github.com/python/importlib_metadata/issues * Code hosting: https://github.com/python/importlib_metadata - * Documentation: https://importlib_metadata.readthedocs.io/ + * Documentation: https://importlib-metadata.readthedocs.io/ For Enterprise ============== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/docs/conf.py new/importlib_metadata-6.6.0/docs/conf.py --- old/importlib_metadata-6.3.0/docs/conf.py 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/docs/conf.py 2023-04-22 14:56:31.000000000 +0200 @@ -64,8 +64,11 @@ nitpick_ignore = [ # Workaround for #316 ('py:class', 'importlib_metadata.EntryPoints'), + ('py:class', 'importlib_metadata.PackagePath'), ('py:class', 'importlib_metadata.SelectableGroups'), ('py:class', 'importlib_metadata._meta._T'), # Workaround for #435 ('py:class', '_T'), + # Other workarounds + ('py:class', 'importlib_metadata.DeprecatedNonAbstract'), ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/docs/index.rst new/importlib_metadata-6.6.0/docs/index.rst --- old/importlib_metadata-6.3.0/docs/index.rst 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/docs/index.rst 2023-04-22 14:56:31.000000000 +0200 @@ -28,7 +28,7 @@ * Project home: https://github.com/python/importlib_metadata * Report bugs at: https://github.com/python/importlib_metadata/issues * Code hosting: https://github.com/python/importlib_metadata - * Documentation: https://importlib_metadata.readthedocs.io/ + * Documentation: https://importlib-metadata.readthedocs.io/ Indices and tables diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/docs/using.rst new/importlib_metadata-6.6.0/docs/using.rst --- old/importlib_metadata-6.3.0/docs/using.rst 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/docs/using.rst 2023-04-22 14:56:31.000000000 +0200 @@ -62,7 +62,7 @@ using ``pip``. We start by creating a virtual environment and installing something into it:: - $ python3 -m venv example + $ python -m venv example $ source example/bin/activate (example) $ python -m pip install importlib_metadata (example) $ python -m pip install wheel @@ -343,7 +343,7 @@ is not available through :data:`sys.path` searches, or package loaders directly, the metadata for a distribution is found through import -system `finders`_. To find a distribution package's metadata, +system :ref:`finders <finders-and-loaders>`. To find a distribution package's metadata, ``importlib.metadata`` queries the list of :term:`meta path finders <meta path finder>` on :data:`sys.meta_path`. @@ -379,4 +379,3 @@ .. _`entry point API`: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points .. _`metadata API`: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#metadata-api -.. _`finders`: https://docs.python.org/3/reference/import.html#finders-and-loaders diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/importlib_metadata/__init__.py new/importlib_metadata-6.6.0/importlib_metadata/__init__.py --- old/importlib_metadata-6.3.0/importlib_metadata/__init__.py 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/importlib_metadata/__init__.py 2023-04-22 14:56:31.000000000 +0200 @@ -5,6 +5,7 @@ import sys import zipp import email +import inspect import pathlib import operator import textwrap @@ -14,12 +15,12 @@ import posixpath import contextlib import collections -import inspect from . import _adapters, _meta, _py39compat from ._collections import FreezableDefaultDict, Pair from ._compat import ( NullFinder, + StrPath, install, pypy_partial, ) @@ -31,8 +32,7 @@ from importlib import import_module from importlib.abc import MetaPathFinder from itertools import starmap -from typing import List, Mapping, Optional - +from typing import Iterable, List, Mapping, Optional, Set, cast __all__ = [ 'Distribution', @@ -53,11 +53,11 @@ class PackageNotFoundError(ModuleNotFoundError): """The package was not found.""" - def __str__(self): + def __str__(self) -> str: return f"No package metadata was found for {self.name}" @property - def name(self): + def name(self) -> str: # type: ignore[override] (name,) = self.args return name @@ -123,7 +123,7 @@ yield Pair(name, value) @staticmethod - def valid(line): + def valid(line: str): return line and not line.startswith('#') @@ -198,7 +198,7 @@ dist: Optional['Distribution'] = None - def __init__(self, name, value, group): + def __init__(self, name: str, value: str, group: str) -> None: vars(self).update(name=name, value=value, group=group) def load(self): @@ -212,18 +212,21 @@ return functools.reduce(getattr, attrs, module) @property - def module(self): + def module(self) -> str: match = self.pattern.match(self.value) + assert match is not None return match.group('module') @property - def attr(self): + def attr(self) -> str: match = self.pattern.match(self.value) + assert match is not None return match.group('attr') @property - def extras(self): + def extras(self) -> List[str]: match = self.pattern.match(self.value) + assert match is not None return re.findall(r'\w+', match.group('extras') or '') def _for(self, dist): @@ -271,7 +274,7 @@ f'group={self.group!r})' ) - def __hash__(self): + def __hash__(self) -> int: return hash(self._key()) @@ -282,7 +285,7 @@ __slots__ = () - def __getitem__(self, name): # -> EntryPoint: + def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override] """ Get the EntryPoint in self matching name. """ @@ -299,14 +302,14 @@ return EntryPoints(ep for ep in self if _py39compat.ep_matches(ep, **params)) @property - def names(self): + def names(self) -> Set[str]: """ Return the set of all names of all entry points. """ return {ep.name for ep in self} @property - def groups(self): + def groups(self) -> Set[str]: """ Return the set of all groups of all entry points. """ @@ -327,32 +330,55 @@ class PackagePath(pathlib.PurePosixPath): """A reference to a path in a package""" - def read_text(self, encoding='utf-8'): + hash: Optional["FileHash"] + size: int + dist: "Distribution" + + def read_text(self, encoding: str = 'utf-8') -> str: # type: ignore[override] with self.locate().open(encoding=encoding) as stream: return stream.read() - def read_binary(self): + def read_binary(self) -> bytes: with self.locate().open('rb') as stream: return stream.read() - def locate(self): + def locate(self) -> pathlib.Path: """Return a path-like object for this path""" return self.dist.locate_file(self) class FileHash: - def __init__(self, spec): + def __init__(self, spec: str) -> None: self.mode, _, self.value = spec.partition('=') - def __repr__(self): + def __repr__(self) -> str: return f'<FileHash mode: {self.mode} value: {self.value}>' -class Distribution(metaclass=abc.ABCMeta): +class DeprecatedNonAbstract: + def __new__(cls, *args, **kwargs): + all_names = { + name for subclass in inspect.getmro(cls) for name in vars(subclass) + } + abstract = { + name + for name in all_names + if getattr(getattr(cls, name), '__isabstractmethod__', False) + } + if abstract: + warnings.warn( + f"Unimplemented abstract methods {abstract}", + DeprecationWarning, + stacklevel=2, + ) + return super().__new__(cls) + + +class Distribution(DeprecatedNonAbstract): """A Python distribution package.""" @abc.abstractmethod - def read_text(self, filename): + def read_text(self, filename) -> Optional[str]: """Attempt to load metadata file given by the name. :param filename: The name of the file in the distribution info. @@ -360,14 +386,14 @@ """ @abc.abstractmethod - def locate_file(self, path): + def locate_file(self, path: StrPath) -> pathlib.Path: """ Given a path to a file in this distribution, return a path to it. """ @classmethod - def from_name(cls, name: str): + def from_name(cls, name: str) -> "Distribution": """Return the Distribution for the given package name. :param name: The name of the distribution package to search for. @@ -380,12 +406,12 @@ if not name: raise ValueError("A distribution name is required.") try: - return next(cls.discover(name=name)) + return next(iter(cls.discover(name=name))) except StopIteration: raise PackageNotFoundError(name) @classmethod - def discover(cls, **kwargs): + def discover(cls, **kwargs) -> Iterable["Distribution"]: """Return an iterable of Distribution objects for all packages. Pass a ``context`` or pass keyword arguments for constructing @@ -403,7 +429,7 @@ ) @staticmethod - def at(path): + def at(path: StrPath) -> "Distribution": """Return a Distribution for the indicated metadata path :param path: a string or path-like object @@ -426,7 +452,7 @@ The returned object will have keys that name the various bits of metadata. See PEP 566 for details. """ - text = ( + opt_text = ( self.read_text('METADATA') or self.read_text('PKG-INFO') # This last clause is here to support old egg-info files. Its @@ -434,10 +460,11 @@ # (which points to the egg-info file) attribute unchanged. or self.read_text('') ) + text = cast(str, opt_text) return _adapters.Message(email.message_from_string(text)) @property - def name(self): + def name(self) -> str: """Return the 'Name' metadata for the distribution package.""" return self.metadata['Name'] @@ -447,16 +474,16 @@ return Prepared.normalize(self.name) @property - def version(self): + def version(self) -> str: """Return the 'Version' metadata for the distribution package.""" return self.metadata['Version'] @property - def entry_points(self): + def entry_points(self) -> EntryPoints: return EntryPoints._from_text_for(self.read_text('entry_points.txt'), self) @property - def files(self): + def files(self) -> Optional[List[PackagePath]]: """Files in this distribution. :return: List of PackagePath for this distribution or None @@ -501,27 +528,29 @@ """ Read installed-files.txt and return lines in a similar CSV-parsable format as RECORD: each file must be placed - relative to the site-packages directory, and must also be + relative to the site-packages directory and must also be quoted (since file names can contain literal commas). This file is written when the package is installed by pip, but it might not be written for other installation methods. - Hence, even if we can assume that this file is accurate - when it exists, we cannot assume that it always exists. + Assume the file is accurate if it exists. """ text = self.read_text('installed-files.txt') - # We need to prepend the .egg-info/ subdir to the lines in this file. - # But this subdir is only available in the PathDistribution's self._path - # which is not easily accessible from this base class... + # Prepend the .egg-info/ subdir to the lines in this file. + # But this subdir is only available from PathDistribution's + # self._path. subdir = getattr(self, '_path', None) if not text or not subdir: return - with contextlib.suppress(Exception): - ret = [ - str((subdir / line).resolve().relative_to(self.locate_file(''))) - for line in text.splitlines() - ] - return map('"{}"'.format, ret) + + paths = ( + (subdir / name) + .resolve() + .relative_to(self.locate_file('').resolve()) + .as_posix() + for name in text.splitlines() + ) + return map('"{}"'.format, paths) def _read_files_egginfo_sources(self): """ @@ -539,7 +568,7 @@ return text and map('"{}"'.format, text.splitlines()) @property - def requires(self): + def requires(self) -> Optional[List[str]]: """Generated requirements specified for this Distribution""" reqs = self._read_dist_info_reqs() or self._read_egg_info_reqs() return reqs and list(reqs) @@ -618,7 +647,7 @@ vars(self).update(kwargs) @property - def path(self): + def path(self) -> List[str]: """ The sequence of directory path that a distribution finder should search. @@ -629,7 +658,7 @@ return vars(self).get('path', sys.path) @abc.abstractmethod - def find_distributions(self, context=Context()): + def find_distributions(self, context=Context()) -> Iterable[Distribution]: """ Find distributions. @@ -764,7 +793,9 @@ of Python that do not have a PathFinder find_distributions(). """ - def find_distributions(self, context=DistributionFinder.Context()): + def find_distributions( + self, context=DistributionFinder.Context() + ) -> Iterable["PathDistribution"]: """ Find distributions. @@ -784,19 +815,19 @@ path.search(prepared) for path in map(FastPath, paths) ) - def invalidate_caches(cls): + def invalidate_caches(cls) -> None: FastPath.__new__.cache_clear() class PathDistribution(Distribution): - def __init__(self, path: SimplePath): + def __init__(self, path: SimplePath) -> None: """Construct a distribution. :param path: SimplePath indicating the metadata directory. """ self._path = path - def read_text(self, filename): + def read_text(self, filename: StrPath) -> Optional[str]: with suppress( FileNotFoundError, IsADirectoryError, @@ -806,9 +837,11 @@ ): return self._path.joinpath(filename).read_text(encoding='utf-8') + return None + read_text.__doc__ = Distribution.read_text.__doc__ - def locate_file(self, path): + def locate_file(self, path: StrPath) -> pathlib.Path: return self._path.parent / path @property @@ -841,7 +874,7 @@ return name -def distribution(distribution_name): +def distribution(distribution_name) -> Distribution: """Get the ``Distribution`` instance for the named package. :param distribution_name: The name of the distribution package as a string. @@ -850,7 +883,7 @@ return Distribution.from_name(distribution_name) -def distributions(**kwargs): +def distributions(**kwargs) -> Iterable[Distribution]: """Get all ``Distribution`` instances in the current environment. :return: An iterable of ``Distribution`` instances. @@ -867,7 +900,7 @@ return Distribution.from_name(distribution_name).metadata -def version(distribution_name): +def version(distribution_name) -> str: """Get the version string for the named package. :param distribution_name: The name of the distribution package to query. @@ -901,7 +934,7 @@ return EntryPoints(eps).select(**params) -def files(distribution_name): +def files(distribution_name) -> Optional[List[PackagePath]]: """Return a list of files for the named package. :param distribution_name: The name of the distribution package to query. @@ -910,11 +943,11 @@ return distribution(distribution_name).files -def requires(distribution_name): +def requires(distribution_name) -> Optional[List[str]]: """ Return a list of requirements for the named package. - :return: An iterator of requirements, suitable for + :return: An iterable of requirements, suitable for packaging.requirement.Requirement. """ return distribution(distribution_name).requires diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/importlib_metadata/_compat.py new/importlib_metadata-6.6.0/importlib_metadata/_compat.py --- old/importlib_metadata-6.3.0/importlib_metadata/_compat.py 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/importlib_metadata/_compat.py 2023-04-22 14:56:31.000000000 +0200 @@ -1,6 +1,9 @@ +import os import sys import platform +from typing import Union + __all__ = ['install', 'NullFinder', 'Protocol'] @@ -70,3 +73,10 @@ """ is_pypy = platform.python_implementation() == 'PyPy' return val + is_pypy + + +if sys.version_info >= (3, 9): + StrPath = Union[str, os.PathLike[str]] +else: + # PathLike is only subscriptable at runtime in 3.9+ + StrPath = Union[str, "os.PathLike[str]"] # pragma: no cover diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/importlib_metadata/_meta.py new/importlib_metadata-6.6.0/importlib_metadata/_meta.py --- old/importlib_metadata-6.3.0/importlib_metadata/_meta.py 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/importlib_metadata/_meta.py 2023-04-22 14:56:31.000000000 +0200 @@ -49,7 +49,7 @@ A minimal subset of pathlib.Path required by PathDistribution. """ - def joinpath(self) -> _T: + def joinpath(self, other: Union[str, _T]) -> _T: ... # pragma: no cover def __truediv__(self, other: Union[str, _T]) -> _T: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/importlib_metadata.egg-info/PKG-INFO new/importlib_metadata-6.6.0/importlib_metadata.egg-info/PKG-INFO --- old/importlib_metadata-6.3.0/importlib_metadata.egg-info/PKG-INFO 2023-04-10 04:27:32.000000000 +0200 +++ new/importlib_metadata-6.6.0/importlib_metadata.egg-info/PKG-INFO 2023-04-22 14:56:52.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: importlib-metadata -Version: 6.3.0 +Version: 6.6.0 Summary: Read metadata from Python packages Home-page: https://github.com/python/importlib_metadata Author: Jason R. Coombs @@ -57,7 +57,7 @@ * - importlib_metadata - stdlib - * - 5.0 + * - 6.5 - 3.12 * - 4.13 - 3.11 @@ -70,7 +70,7 @@ Usage ===== -See the `online documentation <https://importlib_metadata.readthedocs.io/>`_ +See the `online documentation <https://importlib-metadata.readthedocs.io/>`_ for usage details. `Finder authors @@ -94,7 +94,7 @@ * Project home: https://github.com/python/importlib_metadata * Report bugs at: https://github.com/python/importlib_metadata/issues * Code hosting: https://github.com/python/importlib_metadata - * Documentation: https://importlib_metadata.readthedocs.io/ + * Documentation: https://importlib-metadata.readthedocs.io/ For Enterprise ============== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/importlib_metadata.egg-info/SOURCES.txt new/importlib_metadata-6.6.0/importlib_metadata.egg-info/SOURCES.txt --- old/importlib_metadata-6.3.0/importlib_metadata.egg-info/SOURCES.txt 2023-04-10 04:27:32.000000000 +0200 +++ new/importlib_metadata-6.6.0/importlib_metadata.egg-info/SOURCES.txt 2023-04-22 14:56:52.000000000 +0200 @@ -44,6 +44,7 @@ prepare/example2/pyproject.toml prepare/example2/example2/__init__.py tests/__init__.py +tests/_context.py tests/_path.py tests/fixtures.py tests/py39compat.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/tests/_context.py new/importlib_metadata-6.6.0/tests/_context.py --- old/importlib_metadata-6.3.0/tests/_context.py 1970-01-01 01:00:00.000000000 +0100 +++ new/importlib_metadata-6.6.0/tests/_context.py 2023-04-22 14:56:31.000000000 +0200 @@ -0,0 +1,13 @@ +import contextlib + + +# from jaraco.context 4.3 +class suppress(contextlib.suppress, contextlib.ContextDecorator): + """ + A version of contextlib.suppress with decorator support. + + >>> @suppress(KeyError) + ... def key_error(): + ... {}[''] + >>> key_error() + """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/tests/_path.py new/importlib_metadata-6.6.0/tests/_path.py --- old/importlib_metadata-6.3.0/tests/_path.py 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/tests/_path.py 2023-04-22 14:56:31.000000000 +0200 @@ -78,6 +78,11 @@ path.write_text(content, encoding='utf-8') +@create.register +def _(content: str, path): + path.write_text(content, encoding='utf-8') + + class Recording: """ A TreeMaker object that records everything that would be written. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/tests/fixtures.py new/importlib_metadata-6.6.0/tests/fixtures.py --- old/importlib_metadata-6.3.0/tests/fixtures.py 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/tests/fixtures.py 2023-04-22 14:56:31.000000000 +0200 @@ -9,9 +9,9 @@ import contextlib from .py39compat import FS_NONASCII -from typing import Dict, Union from . import _path +from ._path import FilesSpec try: @@ -85,15 +85,8 @@ self.fixtures.enter_context(self.add_sys_path(self.site_dir)) -# Except for python/mypy#731, prefer to define -# FilesDef = Dict[str, Union['FilesDef', str, bytes]] -FilesDef = Dict[ - str, Union[Dict[str, Union[Dict[str, Union[str, bytes]], str, bytes]], str, bytes] -] - - class DistInfoPkg(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "distinfo_pkg-1.0.0.dist-info": { "METADATA": """ Name: distinfo-pkg @@ -135,7 +128,7 @@ class DistInfoPkgWithDot(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "pkg_dot-1.0.0.dist-info": { "METADATA": """ Name: pkg.dot @@ -150,7 +143,7 @@ class DistInfoPkgWithDotLegacy(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "pkg.dot-1.0.0.dist-info": { "METADATA": """ Name: pkg.dot @@ -177,7 +170,7 @@ class EggInfoPkg(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "egginfo_pkg.egg-info": { "PKG-INFO": """ Name: egginfo-pkg @@ -217,7 +210,7 @@ class EggInfoPkgPipInstalledNoToplevel(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "egg_with_module_pkg.egg-info": { "PKG-INFO": "Name: egg_with_module-pkg", # SOURCES.txt is made from the source archive, and contains files @@ -252,7 +245,7 @@ class EggInfoPkgPipInstalledNoModules(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "egg_with_no_modules_pkg.egg-info": { "PKG-INFO": "Name: egg_with_no_modules-pkg", # SOURCES.txt is made from the source archive, and contains files @@ -282,7 +275,7 @@ class EggInfoPkgSourcesFallback(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "sources_fallback_pkg.egg-info": { "PKG-INFO": "Name: sources_fallback-pkg", # SOURCES.txt is made from the source archive, and contains files @@ -308,7 +301,7 @@ class EggInfoFile(OnSysPath, SiteDir): - files: FilesDef = { + files: FilesSpec = { "egginfo_file.egg-info": """ Metadata-Version: 1.0 Name: egginfo_file @@ -328,38 +321,12 @@ build_files(EggInfoFile.files, prefix=self.site_dir) -def build_files(file_defs, prefix=pathlib.Path()): - """Build a set of files/directories, as described by the +# dedent all text strings before writing +orig = _path.create.registry[str] +_path.create.register(str, lambda content, path: orig(DALS(content), path)) - file_defs dictionary. Each key/value pair in the dictionary is - interpreted as a filename/contents pair. If the contents value is a - dictionary, a directory is created, and the dictionary interpreted - as the files within it, recursively. - - For example: - - {"README.txt": "A README file", - "foo": { - "__init__.py": "", - "bar": { - "__init__.py": "", - }, - "baz.py": "# Some code", - } - } - """ - for name, contents in file_defs.items(): - full_name = prefix / name - if isinstance(contents, dict): - full_name.mkdir() - build_files(contents, prefix=full_name) - else: - if isinstance(contents, bytes): - with full_name.open('wb') as f: - f.write(contents) - else: - with full_name.open('w', encoding='utf-8') as f: - f.write(DALS(contents)) + +build_files = _path.build def build_record(file_defs): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/importlib_metadata-6.3.0/tests/test_main.py new/importlib_metadata-6.6.0/tests/test_main.py --- old/importlib_metadata-6.3.0/tests/test_main.py 2023-04-10 04:27:13.000000000 +0200 +++ new/importlib_metadata-6.6.0/tests/test_main.py 2023-04-22 14:56:31.000000000 +0200 @@ -1,12 +1,15 @@ import re import pickle import unittest +import warnings import importlib import importlib_metadata +import contextlib import itertools import pyfakefs.fake_filesystem_unittest as ffs from . import fixtures +from ._context import suppress from importlib_metadata import ( Distribution, EntryPoint, @@ -20,6 +23,13 @@ ) +@contextlib.contextmanager +def suppress_known_deprecation(): + with warnings.catch_warnings(record=True) as ctx: + warnings.simplefilter('default', category=DeprecationWarning) + yield ctx + + class BasicTests(fixtures.DistInfoPkg, unittest.TestCase): version_pattern = r'\d+\.\d+(\.\d)?' @@ -44,6 +54,9 @@ assert "metadata" in str(ctx.exception) + # expected to fail until ABC is enforced + @suppress(AssertionError) + @suppress_known_deprecation() def test_abc_enforced(self): with self.assertRaises(TypeError): type('DistributionSubclass', (Distribution,), {})()