executing icon indicating copy to clipboard operation
executing copied to clipboard

Python 3.13

Open alexmojaki opened this issue 1 year ago • 3 comments

https://github.com/ipython/ipython/issues/14303

alexmojaki avatar Jan 24 '24 20:01 alexmojaki

@15r10nk please can you take a look?

alexmojaki avatar Jan 24 '24 20:01 alexmojaki

The main problem is that the show_caches=True argument has no effect any more.

This should be solvable.

I submitted a bug report because the documentation looks not complete. https://github.com/python/cpython/issues/114616

15r10nk avatar Jan 26 '24 17:01 15r10nk

Thank you!

alexmojaki avatar Jan 26 '24 18:01 alexmojaki

@15r10nk I'm having another issue on Python 3.13, maybe more related to inline-snapshot:

  tests/test_end_to_end.py:121: in <module>
      snapshots_signatures = snapshot({(
  .venvs/3.13/lib/python3.13/site-packages/inline_snapshot/_inline_snapshot.py:644: in __call__
      return self.func(*args, **kwargs)
  .venvs/3.13/lib/python3.13/site-packages/inline_snapshot/_inline_snapshot.py:691: in snapshot
      expr = Source.executing(frame)
  .venvs/3.13/lib/python3.13/site-packages/executing/executing.py:283: in executing
      assert_(new_stmts <= stmts)
  .venvs/3.13/lib/python3.13/site-packages/executing/executing.py:80: in assert_
      raise AssertionError(str(message))
  E   AssertionError

Should I open a new issue on inline-snapshot? Let me know :relaxed:

pawamoy avatar Aug 21 '24 13:08 pawamoy

That sounds like a concerning failure in executing. Try redefining snapshot like this:

import inspect

import executing


def snapshot(*_args, **_kwargs):
    frame = inspect.currentframe().f_back
    executing.Source.executing(frame)

and see if you still get the same error.

alexmojaki avatar Aug 21 '24 13:08 alexmojaki

Interesting, I think you are right here. Is your example reproducible with this feature branch?

If yes, I would like to reproduce it myself (just point me to your commit)

15r10nk avatar Aug 21 '24 14:08 15r10nk

@15r10nk if you're addressing to me:

git clone https://github.com/mkdocstrings/python
cd python
git checkout end-to-end-tests
uv venv --python 3.13
uv pip install -e .
uv pip install -r devdeps.txt
. .venv/bin/activate
python -m pytest tests -c config/pytest.ini -n auto

@alexmojaki thanks for your help!

pawamoy avatar Aug 21 '24 14:08 pawamoy

Interesting, if I move the snapshot variables in another module, the error disappears (snapshots_thing = inline_snapshot.snapshot({...})).

pawamoy avatar Aug 21 '24 15:08 pawamoy

@pawamoy I think I'm missing something:

❯ python -m pytest tests -c config/pytest.ini -n auto
================================================================================================ test session starts ================================================================================================
platform linux -- Python 3.13.0rc1+, pytest-8.3.2, pluggy-1.5.0
Using --randomly-seed=4245363505
rootdir: /home/frank/projects/mkdocstrings_stuff/python/config
configfile: pytest.ini
plugins: inline-snapshot-0.12.1, xdist-3.6.1, cov-5.0.0, randomly-3.15.0
12 workers [468 items]
............................................................................................................................................................................................................. [ 43%]
............................................................................................................................................................................................................. [ 87%]
..........................................................                                                                                                                                                    [100%]

-------- coverage: platform linux, python 3.13.0-candidate-1 ---------
Name                                            Stmts   Miss Branch BrPart   Cover
----------------------------------------------------------------------------------
src/mkdocstrings_handlers/python/__init__.py        2      0      0      0 100.00%
src/mkdocstrings_handlers/python/debug.py          63     63     16      0   0.00%
src/mkdocstrings_handlers/python/handler.py       179     40     74      9  72.73%
src/mkdocstrings_handlers/python/rendering.py     229     49     96      9  79.08%
tests/conftest.py                                  30      0     20      0 100.00%
tests/helpers.py                                   29      0      4      0 100.00%
tests/snapshots.py                                  3      0      0      0 100.00%
tests/test_end_to_end.py                           51      0     28      0 100.00%
tests/test_handler.py                              63      1     22      1  97.65%
tests/test_rendering.py                            45      0     18      0 100.00%
tests/test_themes.py                                8      0      6      0 100.00%
----------------------------------------------------------------------------------
TOTAL                                             702    153    284     19  77.89%

================================================================================================== inline snapshot ==================================================================================================
INFO: inline-snapshot was disabled because you used xdist
=============================================================================================== 468 passed in 16.21s ================================================================================================

I use the commit 45c10d1048bb90b25e8b72bb863504d9bf46cae8 of your branch.

I think you are also not using the 3.13 feature branch of executing. It is probably luck that executing is still able to find the ast.Call nodes (because the bytecodes have not changed).

15r10nk avatar Aug 21 '24 18:08 15r10nk

@15r10nk try commit 2771f35 instead, sorry, I pushed to the branch in the mean time.

I think you are also not using the 3.13 feature branch of executing.

I am definitely not, as I wasn't aware there was such a branch to test :smile:

pawamoy avatar Aug 22 '24 16:08 pawamoy

This is the problem:

import inspect
import executing

def snapshot(*_args):
    frame = inspect.currentframe().f_back
    executing.Source.executing(frame)

def external(v):
    pass
snapshot(external(''))
{'': external}

I used pysource-minimize to minimize the code from your test down to this :smiley:.

The good thing is that it is not a problem in the new 3.13 branch any more.

@alexmojaki is it ok to ignore this? executing should never throw exceptions but return None if it has a problem to find a node. But the problem here is that we are using a currently not supported python version.

15r10nk avatar Aug 22 '24 21:08 15r10nk

@15r10nk thank you so much, awesome to hear this is already fixed :) pysource-minimize is really an amazing tool!

pawamoy avatar Aug 22 '24 21:08 pawamoy