1717
1818logged = False
1919
20+
2021def apply ():
2122 # The Python site module can call us more than once.
2223 # We need to actually do this the last time,
2324 # But we only want to show the notice once.
2425 global logged
2526 if not logged :
26- print ("🐎 This Python uses horse-with-no-namespace "
27- "to make pkg_resources namespace packages compatible "
28- "with PEP 420 namespace packages." )
27+ print (
28+ "🐎 This Python uses horse-with-no-namespace "
29+ "to make pkg_resources namespace packages compatible "
30+ "with PEP 420 namespace packages." ,
31+ file = sys .stderr ,
32+ )
2933 logged = True
3034
3135 # Only patch pkg_resources if it is installed...
@@ -38,12 +42,15 @@ def apply():
3842 # to update __path__ using pkgutil.extend_path instead
3943 def declare_namespace (packageName ):
4044 parent_locals = sys ._getframe (1 ).f_locals
41- parent_locals ["__path__" ] = pkgutil .extend_path (parent_locals ["__path__" ], packageName )
45+ parent_locals ["__path__" ] = pkgutil .extend_path (
46+ parent_locals ["__path__" ], packageName
47+ )
48+
4249 pkg_resources .declare_namespace = declare_namespace
4350
4451 # Remove existing namespace package modules that were already created
4552 # by other .pth files, possibly with an incomplete __path__
4653 for name , module in list (sys .modules .items ()):
4754 loader = getattr (module , "__loader__" , None )
48- if loader and loader .__class__ .__name__ == ' NamespaceLoader' :
55+ if loader and loader .__class__ .__name__ == " NamespaceLoader" :
4956 del sys .modules [name ]
0 commit comments