Skip to content

Commit 68122e8

Browse files
committed
Intermediate changes
1 parent 8e1b86e commit 68122e8

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

contrib/python/importlib-metadata/py3/.dist-info/METADATA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: importlib_metadata
3-
Version: 8.2.0
3+
Version: 8.4.0
44
Summary: Read metadata from Python packages
55
Author-email: "Jason R. Coombs" <jaraco@jaraco.com>
66
Project-URL: Source, https://github.com/python/importlib_metadata

contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import json
88
import email
99
import types
10-
import inspect
1110
import pathlib
1211
import operator
1312
import textwrap
@@ -232,9 +231,26 @@ def matches(self, **params):
232231
>>> ep.matches(attr='bong')
233232
True
234233
"""
234+
self._disallow_dist(params)
235235
attrs = (getattr(self, param) for param in params)
236236
return all(map(operator.eq, params.values(), attrs))
237237

238+
@staticmethod
239+
def _disallow_dist(params):
240+
"""
241+
Querying by dist is not allowed (dist objects are not comparable).
242+
>>> EntryPoint(name='fan', value='fav', group='fag').matches(dist='foo')
243+
Traceback (most recent call last):
244+
...
245+
ValueError: "dist" is not suitable for matching...
246+
"""
247+
if "dist" in params:
248+
raise ValueError(
249+
'"dist" is not suitable for matching. '
250+
"Instead, use Distribution.entry_points.select() on a "
251+
"located distribution."
252+
)
253+
238254
def _key(self):
239255
return self.name, self.value, self.group
240256

@@ -378,6 +394,17 @@ def locate_file(self, path: str | os.PathLike[str]) -> SimplePath:
378394
"""
379395
Given a path to a file in this distribution, return a SimplePath
380396
to it.
397+
398+
This method is used by callers of ``Distribution.files()`` to
399+
locate files within the distribution. If it's possible for a
400+
Distribution to represent files in the distribution as
401+
``SimplePath`` objects, it should implement this method
402+
to resolve such objects.
403+
404+
Some Distribution providers may elect not to resolve SimplePath
405+
objects within the distribution by raising a
406+
NotImplementedError, but consumers of such a Distribution would
407+
be unable to invoke ``Distribution.files()``.
381408
"""
382409

383410
@classmethod
@@ -1136,11 +1163,10 @@ def _get_toplevel_name(name: PackagePath) -> str:
11361163
>>> _get_toplevel_name(PackagePath('foo.dist-info'))
11371164
'foo.dist-info'
11381165
"""
1139-
return _topmost(name) or (
1140-
# python/typeshed#10328
1141-
inspect.getmodulename(name) # type: ignore
1142-
or str(name)
1143-
)
1166+
# Defer import of inspect for performance (python/cpython#118761)
1167+
import inspect
1168+
1169+
return _topmost(name) or (inspect.getmodulename(name) or str(name))
11441170

11451171

11461172
def _top_level_inferred(dist):

contrib/python/importlib-metadata/py3/ya.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
PY3_LIBRARY()
44

5-
VERSION(8.2.0)
5+
VERSION(8.4.0)
66

77
LICENSE(Apache-2.0)
88

0 commit comments

Comments
 (0)