Skip to content

Commit

Permalink
Migrate pkg_resources -> importlib_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
dotboris committed Dec 7, 2023
1 parent a078e09 commit 2fdd972
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
9 changes: 8 additions & 1 deletion coveo_stew/ci/mypy_runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import atexit
from contextlib import ExitStack
import importlib_resources
import re
from pathlib import Path
from typing import Generator, Optional, Union
Expand Down Expand Up @@ -28,7 +31,11 @@ def _mypy_config_path(self) -> Optional[Path]:
return None

if self.set_config is True:
return Path(pkg_resources.resource_filename("coveo_stew", "package_resources/mypy.ini"))
config_ref = importlib_resources.files("coveo_stew") / "package_resources/mypy.ini"
stack = ExitStack()
atexit.register(stack)
config_path = stack.enter_context(importlib_resources.as_file(config_ref))
return config_path

assert isinstance(self.set_config, str) # mypy
return self._pyproject.project_path / self.set_config
Expand Down
35 changes: 34 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ junit-xml = "*"
packaging = "*"
toml = "*"
tomlkit = "*"
importlib-resources = "^6.1.1"


[tool.poetry.dev-dependencies]
Expand Down

0 comments on commit 2fdd972

Please sign in to comment.