Skip to content

Fix compatibility with Python 3.15#554

Merged
agronholm merged 14 commits into
agronholm:masterfrom
hrnciar:python3.15
May 23, 2026
Merged

Fix compatibility with Python 3.15#554
agronholm merged 14 commits into
agronholm:masterfrom
hrnciar:python3.15

Conversation

@hrnciar
Copy link
Copy Markdown
Contributor

@hrnciar hrnciar commented May 20, 2026

  • Drop removed debug_override parameter from cache_from_source() call
  • Accept extra positional args in source_to_code() for new fullname parameter
  • Guard no_type_check_decorator import behind version check (removed in 3.15)

Assisted-by: Cursor

Changes

Fixes #.

Checklist

If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):

  • You've added tests (in tests/) added which would fail without your patch
  • You've updated the documentation (in docs/, in case of behavior changes or new
    features)
  • You've added a new changelog entry (in docs/versionhistory.rst).

If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.

Updating the changelog

If there are no entries after the last release, use **UNRELEASED** as the version.
If, say, your patch fixes issue #999, the entry should look like this:

* Fix big bad boo-boo in the pytest plugin (#999 <https://github.com/agronholm/typeguard/issues/999>_; PR by @yourgithubaccount)

If there's no issue linked, just link to your pull request instead by updating the
changelog after you've created the PR.

@coveralls
Copy link
Copy Markdown

coveralls commented May 20, 2026

Coverage Status

coverage: 94.923% (+0.01%) from 94.911% — hrnciar:python3.15 into agronholm:master

@agronholm
Copy link
Copy Markdown
Owner

To prove 3.15 compatibility, this should add 3.15 to the test matrix.

Copy link
Copy Markdown
Owner

@agronholm agronholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't looking good, but I'm willing to give you a chance to fix it.

Comment thread src/typeguard/_importhook.py Outdated
Comment thread docs/versionhistory.rst Outdated
Comment thread tests/dummymodule.py
Comment thread src/typeguard/_importhook.py Outdated
- Drop removed debug_override parameter from cache_from_source() call
- Accept extra positional args in source_to_code() for new fullname parameter
- Guard no_type_check_decorator import behind version check (removed in 3.15)
- Add Python 3.15 to the test matrix
@agronholm
Copy link
Copy Markdown
Owner

Please do not force push your changes. If you do, I won't know what you changed in response to my feedback.

@hrnciar
Copy link
Copy Markdown
Contributor Author

hrnciar commented May 21, 2026

I am sorry, I was about to reply in the above conversation.

@agronholm
Copy link
Copy Markdown
Owner

You added 3.15 to tox configuration but it's still missing from the Github Actions workflow.

@agronholm
Copy link
Copy Markdown
Owner

Alright, getting better! Is there any place where the new fullname argument could be passed to?

@hrnciar
Copy link
Copy Markdown
Contributor Author

hrnciar commented May 21, 2026

From the 3.15 documentation:

Many functions related to compiling or parsing Python code, such as compile(), ast.parse(), symtable.symtable(), and importlib.abc.InspectLoader.source_to_code(), now allow the module name to be passed. It is needed to unambiguously filter syntax warnings by module name. (Contributed by Serhiy Storchaka in gh-135801.)

In our case, it could be used in the two _call_with_frames_removed calls (ast.parse and compile).

@agronholm
Copy link
Copy Markdown
Owner

From the 3.15 documentation:

Many functions related to compiling or parsing Python code, such as compile(), ast.parse(), symtable.symtable(), and importlib.abc.InspectLoader.source_to_code(), now allow the module name to be passed. It is needed to unambiguously filter syntax warnings by module name. (Contributed by Serhiy Storchaka in gh-135801.)

In our case, it could be used in the two _call_with_frames_removed calls (ast.parse and compile).

If you could do that on 3.15, that'd be great.

Comment thread pyproject.toml
@agronholm
Copy link
Copy Markdown
Owner

Looks like I introduced mypy errors with my simplification. Those need to be undone. Otherwise this looks good now!

@hrnciar
Copy link
Copy Markdown
Contributor Author

hrnciar commented May 21, 2026

Thank you for the help!

Copy link
Copy Markdown
Owner

@agronholm agronholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@agronholm agronholm merged commit 2e63076 into agronholm:master May 23, 2026
20 of 21 checks passed
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 this pull request may close these issues.

3 participants