[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-04-13 00:00:18 +00:00
parent 72ad6dc953
commit f4cd1ba0d6
813 changed files with 66015 additions and 58839 deletions

View file

@ -1,6 +1,9 @@
import os
from distutils import log
from __future__ import annotations
import itertools
import os
from distutils import log
flatten = itertools.chain.from_iterable
@ -17,7 +20,7 @@ class Installer:
filename, ext = os.path.splitext(self._get_target())
filename += self.nspkg_ext
self.outputs.append(filename)
log.info("Installing %s", filename)
log.info('Installing %s', filename)
lines = map(self._gen_nspkg_line, nsp)
if self.dry_run:
@ -25,7 +28,7 @@ class Installer:
list(lines)
return
with open(filename, 'wt') as f:
with open(filename, 'w') as f:
f.writelines(lines)
def uninstall_namespaces(self):
@ -33,38 +36,38 @@ class Installer:
filename += self.nspkg_ext
if not os.path.exists(filename):
return
log.info("Removing %s", filename)
log.info('Removing %s', filename)
os.remove(filename)
def _get_target(self):
return self.target
_nspkg_tmpl = (
"import sys, types, os",
"has_mfs = sys.version_info > (3, 5)",
"p = os.path.join(%(root)s, *%(pth)r)",
'import sys, types, os',
'has_mfs = sys.version_info > (3, 5)',
'p = os.path.join(%(root)s, *%(pth)r)',
"importlib = has_mfs and __import__('importlib.util')",
"has_mfs and __import__('importlib.machinery')",
(
"m = has_mfs and "
"sys.modules.setdefault(%(pkg)r, "
"importlib.util.module_from_spec("
"importlib.machinery.PathFinder.find_spec(%(pkg)r, "
"[os.path.dirname(p)])))"
'm = has_mfs and '
'sys.modules.setdefault(%(pkg)r, '
'importlib.util.module_from_spec('
'importlib.machinery.PathFinder.find_spec(%(pkg)r, '
'[os.path.dirname(p)])))'
),
(
"m = m or "
"sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))"
'm = m or '
'sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))'
),
"mp = (m or []) and m.__dict__.setdefault('__path__',[])",
"(p not in mp) and mp.append(p)",
'(p not in mp) and mp.append(p)',
)
"lines for the namespace installer"
'lines for the namespace installer'
_nspkg_tmpl_multi = (
'm and setattr(sys.modules[%(parent)r], %(child)r, m)',
)
"additional line(s) when a parent package is indicated"
'additional line(s) when a parent package is indicated'
def _get_root(self):
return "sys._getframe(1).f_locals['sitedir']"