1717 NullFinder ,
1818 PyPy_repr ,
1919 install ,
20- )
20+ )
2121
2222from configparser import ConfigParser
2323from contextlib import suppress
3737 'metadata' ,
3838 'requires' ,
3939 'version' ,
40- ]
40+ ]
4141
4242
4343class PackageNotFoundError (ModuleNotFoundError ):
@@ -49,13 +49,13 @@ def __str__(self):
4949
5050 @property
5151 def name (self ):
52- name , = self .args
52+ ( name ,) = self .args
5353 return name
5454
5555
5656class EntryPoint (
57- PyPy_repr ,
58- collections . namedtuple ( 'EntryPointBase' , 'name value group' ) ):
57+ PyPy_repr , collections . namedtuple ( 'EntryPointBase' , 'name value group' )
58+ ):
5959 """An entry point as defined by Python packaging conventions.
6060
6161 See `the packaging docs on entry points
@@ -67,7 +67,7 @@ class EntryPoint(
6767 r'(?P<module>[\w.]+)\s*'
6868 r'(:\s*(?P<attr>[\w.]+))?\s*'
6969 r'(?P<extras>\[.*\])?\s*$'
70- )
70+ )
7171 """
7272 A regular expression describing the syntax for an entry point,
7373 which might look like:
@@ -115,7 +115,7 @@ def _from_config(cls, config):
115115 cls (name , value , group )
116116 for group in config .sections ()
117117 for name , value in config .items (group )
118- ]
118+ ]
119119
120120 @classmethod
121121 def _from_text (cls , text ):
@@ -139,7 +139,7 @@ def __reduce__(self):
139139 return (
140140 self .__class__ ,
141141 (self .name , self .value , self .group ),
142- )
142+ )
143143
144144
145145class PackagePath (pathlib .PurePosixPath ):
@@ -217,9 +217,8 @@ def discover(cls, **kwargs):
217217 raise ValueError ("cannot accept context and kwargs" )
218218 context = context or DistributionFinder .Context (** kwargs )
219219 return itertools .chain .from_iterable (
220- resolver (context )
221- for resolver in cls ._discover_resolvers ()
222- )
220+ resolver (context ) for resolver in cls ._discover_resolvers ()
221+ )
223222
224223 @staticmethod
225224 def at (path ):
@@ -234,20 +233,20 @@ def at(path):
234233 def _discover_resolvers ():
235234 """Search the meta_path for resolvers."""
236235 declared = (
237- getattr (finder , 'find_distributions' , None )
238- for finder in sys .meta_path
239- )
236+ getattr (finder , 'find_distributions' , None ) for finder in sys .meta_path
237+ )
240238 return filter (None , declared )
241239
242240 @classmethod
243241 def _local (cls , root = '.' ):
244242 from pep517 import build , meta
243+
245244 system = build .compat_system (root )
246245 builder = functools .partial (
247246 meta .build ,
248247 source_dir = root ,
249248 system = system ,
250- )
249+ )
251250 return PathDistribution (zipp .Path (meta .build_as_zip (builder )))
252251
253252 @property
@@ -264,7 +263,7 @@ def metadata(self):
264263 # effect is to just end up using the PathDistribution's self._path
265264 # (which points to the egg-info file) attribute unchanged.
266265 or self .read_text ('' )
267- )
266+ )
268267 return email .message_from_string (text )
269268
270269 @property
@@ -331,9 +330,10 @@ def _deps_from_requires_text(cls, source):
331330 section_pairs = cls ._read_sections (source .splitlines ())
332331 sections = {
333332 section : list (map (operator .itemgetter ('line' ), results ))
334- for section , results in
335- itertools .groupby (section_pairs , operator .itemgetter ('section' ))
336- }
333+ for section , results in itertools .groupby (
334+ section_pairs , operator .itemgetter ('section' )
335+ )
336+ }
337337 return cls ._convert_egg_info_reqs_to_simple_reqs (sections )
338338
339339 @staticmethod
@@ -357,6 +357,7 @@ def _convert_egg_info_reqs_to_simple_reqs(sections):
357357 requirement. This method converts the former to the
358358 latter. See _test_deps_from_requires_text for an example.
359359 """
360+
360361 def make_condition (name ):
361362 return name and 'extra == "{name}"' .format (name = name )
362363
@@ -445,33 +446,35 @@ def zip_children(self):
445446 names = zip_path .root .namelist ()
446447 self .joinpath = zip_path .joinpath
447448
448- return dict .fromkeys (
449- child .split (posixpath .sep , 1 )[0 ]
450- for child in names
451- )
449+ return dict .fromkeys (child .split (posixpath .sep , 1 )[0 ] for child in names )
452450
453451 def is_egg (self , search ):
454452 base = self .base
455453 return (
456454 base == search .versionless_egg_name
457455 or base .startswith (search .prefix )
458- and base .endswith ('.egg' ))
456+ and base .endswith ('.egg' )
457+ )
459458
460459 def search (self , name ):
461460 for child in self .children ():
462461 n_low = child .lower ()
463- if (n_low in name .exact_matches
464- or n_low .startswith (name .prefix )
465- and n_low .endswith (name .suffixes )
466- # legacy case:
467- or self .is_egg (name ) and n_low == 'egg-info' ):
462+ if (
463+ n_low in name .exact_matches
464+ or n_low .startswith (name .prefix )
465+ and n_low .endswith (name .suffixes )
466+ # legacy case:
467+ or self .is_egg (name )
468+ and n_low == 'egg-info'
469+ ):
468470 yield self .joinpath (child )
469471
470472
471473class Prepared :
472474 """
473475 A prepared search for metadata on a possibly-named package.
474476 """
477+
475478 normalized = ''
476479 prefix = ''
477480 suffixes = '.dist-info' , '.egg-info'
@@ -484,8 +487,7 @@ def __init__(self, name):
484487 return
485488 self .normalized = name .lower ().replace ('-' , '_' )
486489 self .prefix = self .normalized + '-'
487- self .exact_matches = [
488- self .normalized + suffix for suffix in self .suffixes ]
490+ self .exact_matches = [self .normalized + suffix for suffix in self .suffixes ]
489491 self .versionless_egg_name = self .normalized + '.egg'
490492
491493
@@ -513,9 +515,8 @@ def find_distributions(self, context=DistributionFinder.Context()):
513515 def _search_paths (cls , name , paths ):
514516 """Find metadata directories in paths heuristically."""
515517 return itertools .chain .from_iterable (
516- path .search (Prepared (name ))
517- for path in map (FastPath , paths )
518- )
518+ path .search (Prepared (name )) for path in map (FastPath , paths )
519+ )
519520
520521
521522class PathDistribution (Distribution ):
@@ -528,9 +529,15 @@ def __init__(self, path):
528529 self ._path = path
529530
530531 def read_text (self , filename ):
531- with suppress (FileNotFoundError , IsADirectoryError , KeyError ,
532- NotADirectoryError , PermissionError ):
532+ with suppress (
533+ FileNotFoundError ,
534+ IsADirectoryError ,
535+ KeyError ,
536+ NotADirectoryError ,
537+ PermissionError ,
538+ ):
533539 return self ._path .joinpath (filename ).read_text (encoding = 'utf-8' )
540+
534541 read_text .__doc__ = Distribution .read_text .__doc__
535542
536543 def locate_file (self , path ):
@@ -578,15 +585,11 @@ def entry_points():
578585
579586 :return: EntryPoint objects for all installed packages.
580587 """
581- eps = itertools .chain .from_iterable (
582- dist .entry_points for dist in distributions ())
588+ eps = itertools .chain .from_iterable (dist .entry_points for dist in distributions ())
583589 by_group = operator .attrgetter ('group' )
584590 ordered = sorted (eps , key = by_group )
585591 grouped = itertools .groupby (ordered , by_group )
586- return {
587- group : tuple (eps )
588- for group , eps in grouped
589- }
592+ return {group : tuple (eps ) for group , eps in grouped }
590593
591594
592595def files (distribution_name ):
0 commit comments