Skip to content
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

Python 3.13 #79

Closed
alexmojaki opened this issue Jan 24, 2024 · 12 comments · Fixed by #80
Closed

Python 3.13 #79

alexmojaki opened this issue Jan 24, 2024 · 12 comments · Fixed by #80

Comments

@alexmojaki
Copy link
Owner

ipython/ipython#14303

@alexmojaki
Copy link
Owner Author

@15r10nk please can you take a look?

@15r10nk
Copy link
Collaborator

15r10nk commented Jan 26, 2024

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.
python/cpython#114616

@alexmojaki
Copy link
Owner Author

Thank you!

@pawamoy
Copy link

pawamoy commented Aug 21, 2024

@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 ☺️

@alexmojaki
Copy link
Owner Author

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.

@15r10nk
Copy link
Collaborator

15r10nk commented Aug 21, 2024

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)

@pawamoy
Copy link

pawamoy commented Aug 21, 2024

@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
Copy link

pawamoy commented Aug 21, 2024

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

@15r10nk
Copy link
Collaborator

15r10nk commented Aug 21, 2024

@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).

@pawamoy
Copy link

pawamoy commented Aug 22, 2024

@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 😄

@15r10nk
Copy link
Collaborator

15r10nk commented Aug 22, 2024

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 😃.

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.

@pawamoy
Copy link

pawamoy commented Aug 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants