get_resource_reader: IndentationError: unexpected indent #13135
Open
Description
MWE:
-
Set up venv:
uv venv
Using CPython 3.13.1 interpreter at: /usr/bin/python Creating virtual environment at: .venv Activate with: source .venv/bin/activate
-
Activate:
source .venv/bin/activate
-
Install pytest:
uv pip install pytest
Resolved 4 packages in 4ms Installed 4 packages in 7ms + iniconfig==2.0.0 + packaging==24.2 + pluggy==1.5.0 + pytest==8.3.4
-
Run it:
pytest
Traceback (most recent call last): File ".venv/bin/pytest", line 5, in <module> from pytest import console_main File ".venv/lib/python3.13/site-packages/pytest/__init__.py", line 9, in <module> from _pytest.assertion import register_assert_rewrite File ".venv/lib/python3.13/site-packages/_pytest/assertion/__init__.py", line 11, in <module> from _pytest.assertion import rewrite File ".venv/lib/python3.13/site-packages/_pytest/assertion/rewrite.py", line 294 def get_resource_reader(self, name: str) -> TraversableResources: IndentationError: unexpected indent
The file in question:
# ...
def get_data(self, pathname: str | bytes) -> bytes:
"""Optional PEP302 get_data API."""
with open(pathname, "rb") as f:
return f.read()
from importlib.resources.abc import TraversableResources
def get_resource_reader(self, name: str) -> TraversableResources:
from importlib.resources.readers import FileReader
return FileReader(types.SimpleNamespace(path=self._rewritten_names[name]))
# ...