-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when parsing explicit tuples for trimming #77
Comments
Hmmm I'm actually seeing other issues:
...
("unwrap_annotated", False),
): external("011c334b854b*.html")}{( # <-- closing and reopening dict? happens both on python 3.8 and 3.10
("annotations_path", "brief"),
...
|
If you want to try it in my own repo: git clone https://github.com/mkdocstrings/python
git checkout end-to-end-tests
make setup # install dependencies in venvs (needs uv, install with pipx)
# then you can activate the venv of your choice to test
. .venvs/3.8/bin/activate
# and run the tests
duty test match=end_to_end snapshot=create
# at this point, possible syntax error, try fixing it
# run tests again
duty test match=end_to_end # probably telling values are missing
# try trimming
duty test match=end_to_end snapshot=trim # probably breaking syntax For reference: mkdocstrings/python#157. |
Uhh, I think I know the problem. The code range of a tuple ast node does not include the braces. I think this breaks some internal logic in inline-snapshot. |
no, this is not the problem. Can you remove args = [f"--inline-snapshot={snapshot}"] if snapshot else []
if not snapshot:
args+=["-n","auto"]
ctx.run(
pytest.run(*args, "tests", config_file="config/pytest.ini", select=match, color="yes"),
title=pyprefix("Running tests"),
command=f"pytest -c config/pytest.ini -n auto -k{match!r} --color=yes tests",
) this should solve your problem. I don't know if it is possible to use inline-snapshot with xdist but I will notify the user if he tries to. |
Oh damn, yes, it felt like race conditions but I didn't think about pytest-xdist! Good catch. I'll do what you suggest and disable it when inline snapshot modifies files 👍 |
OK, it's working. So sorry for this bad tendency I have to open invalid issues on your repositories 🙇 |
nothing to sorry about. I'm currently implementing a check for xdist which should save everyone after you from this mistake. |
The snapshots, once created, will contain explicit tuples with a single element. It looks like inline-snapshot has trouble parsing them when trimming, because it removes too much code, leaving the test module in a broken state.
Run
pytest --inline-snapshot=create
. The snapshots will look something like this:Optionally format the test module with
ruff
, and runpytest --inline-snaphost=trim
.It leaves me with something like this in my own test module:
I'll try to create a proper reproduction a bit later.
The text was updated successfully, but these errors were encountered: