Skip to content

Commit 2ae929a

Browse files
committed
remove usage of pkg_resources
1 parent d062c3e commit 2ae929a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

pre_commit_mirror_maker/make_repo.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
from __future__ import annotations
22

3+
import importlib.resources
34
import json
45
import os.path
56
import subprocess
67

7-
import pkg_resources
8-
98
from pre_commit_mirror_maker.languages import ADDITIONAL_DEPENDENCIES
109
from pre_commit_mirror_maker.languages import LIST_VERSIONS
1110

1211

13-
def format_files(src: str, dest: str, **fmt_vars: str) -> None:
12+
def format_files(src: os.PathLike[str], dest: str, **fmt_vars: str) -> None:
1413
"""Copies all files inside src into dest while formatting the contents
1514
of the files into the output.
1615
@@ -47,9 +46,17 @@ def _commit_version(
4746
**fmt_vars: str,
4847
) -> None:
4948
# 'all' writes the .version and .pre-commit-hooks.yaml files
50-
for lang in ('all', language):
51-
src = pkg_resources.resource_filename('pre_commit_mirror_maker', lang)
52-
format_files(src, repo, language=language, version=version, **fmt_vars)
49+
files = importlib.resources.files('pre_commit_mirror_maker')
50+
with importlib.resources.as_file(files) as files_p:
51+
for lang in ('all', language):
52+
src = files_p.joinpath(lang)
53+
format_files(
54+
src,
55+
repo,
56+
language=language,
57+
version=version,
58+
**fmt_vars,
59+
)
5360

5461
hooks_yaml = os.path.join(repo, 'hooks.yaml')
5562
if os.path.exists(hooks_yaml):

0 commit comments

Comments
 (0)