|
31 | 31 | from importlib import import_module
|
32 | 32 | from importlib.abc import MetaPathFinder
|
33 | 33 | from itertools import starmap
|
34 |
| -from typing import List, Mapping, Optional |
| 34 | +from typing import List, Mapping, Optional, cast |
35 | 35 |
|
36 | 36 |
|
37 | 37 | __all__ = [
|
@@ -352,7 +352,7 @@ class Distribution(metaclass=abc.ABCMeta):
|
352 | 352 | """A Python distribution package."""
|
353 | 353 |
|
354 | 354 | @abc.abstractmethod
|
355 |
| - def read_text(self, filename): |
| 355 | + def read_text(self, filename) -> Optional[str]: |
356 | 356 | """Attempt to load metadata file given by the name.
|
357 | 357 |
|
358 | 358 | :param filename: The name of the file in the distribution info.
|
@@ -426,14 +426,15 @@ def metadata(self) -> _meta.PackageMetadata:
|
426 | 426 | The returned object will have keys that name the various bits of
|
427 | 427 | metadata. See PEP 566 for details.
|
428 | 428 | """
|
429 |
| - text = ( |
| 429 | + opt_text = ( |
430 | 430 | self.read_text('METADATA')
|
431 | 431 | or self.read_text('PKG-INFO')
|
432 | 432 | # This last clause is here to support old egg-info files. Its
|
433 | 433 | # effect is to just end up using the PathDistribution's self._path
|
434 | 434 | # (which points to the egg-info file) attribute unchanged.
|
435 | 435 | or self.read_text('')
|
436 | 436 | )
|
| 437 | + text = cast(str, opt_text) |
437 | 438 | return _adapters.Message(email.message_from_string(text))
|
438 | 439 |
|
439 | 440 | @property
|
|
0 commit comments