GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Restore importlib.metadata to the version that worked. · python/cpython@9130df2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib/importlib/metadata
    • __init__.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/importlib/metadata/__init__.py‎

Copy file name to clipboardExpand all lines: Lib/importlib/metadata/__init__.py
+5-15Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class _EntryPointMatch(types.SimpleNamespace):
136136
extras: str
137137

138138

139+
from typing import Optional, List, cast, Match
140+
139141
class EntryPoint:
140142
"""An entry point as defined by Python packaging conventions.
141143
@@ -202,7 +204,7 @@ class EntryPoint:
202204
value: str
203205
group: str
204206

205-
dist: Distribution | None = None
207+
dist: Optional[Distribution] = None
206208

207209
def __init__(self, name: str, value: str, group: str) -> None:
208210
vars(self).update(name=name, value=value, group=group)
@@ -212,7 +214,7 @@ def load(self) -> Any:
212214
is indicated by the value, return that module. Otherwise,
213215
return the named object.
214216
"""
215-
match = self.pattern.match(self.value)
217+
match = cast(Match, self.pattern.match(self.value))
216218
module = import_module(match.group('module'))
217219
attrs = filter(None, (match.group('attr') or '').split('.'))
218220
return functools.reduce(getattr, attrs, module)
@@ -230,23 +232,11 @@ def attr(self) -> str:
230232
return match.group('attr')
231233

232234
@property
233-
def extras(self) -> list[str]:
235+
def extras(self) -> List[str]:
234236
match = self.pattern.match(self.value)
235237
assert match is not None
236238
return re.findall(r'\w+', match.group('extras') or '')
237239

238-
@property
239-
def _match(self) -> _EntryPointMatch:
240-
match = self.pattern.match(self.value)
241-
if not match:
242-
raise ValueError(
243-
'Invalid object reference. '
244-
'See https://packaging.python.org'
245-
'/en/latest/specifications/entry-points/#data-model',
246-
self.value,
247-
)
248-
return _EntryPointMatch(**match.groupdict())
249-
250240
def _for(self, dist):
251241
vars(self).update(dist=dist)
252242
return self

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.