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

Fix ast deprecation warnings up to Python 3.13. #434

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

fschulze
Copy link
Contributor

Wasn't so trivial after all ...

The changes have less specific types than before, as all of ast.Num, ast.Str and ast.Index become ast.Constant. This has been the case since Python 3.9 and it worked fine. I added additional isinstance checks. Not sure those are required or even harmful for some usecases.

Node.lineno can't be None, but also can't be omitted. I added ast.copy_location and ast.fix_missing_locations calls, but I'm not sure they do the desired thing at each place, as I don't fully understand what the places they are used are actually doing.

For the visit_FunctionDef transformer I couldn't find a more elegant solution to fix mypy. The type_params doesn't seem to be required, as the tests work without, but the type definition (and docs) seems to say otherwise.

@coveralls
Copy link

coveralls commented Dec 19, 2024

Pull Request Test Coverage Report for Build 12408949077

Details

  • 41 of 42 (97.62%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 92.34%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/chameleon/codegen.py 19 20 95.0%
Totals Coverage Status
Change from base Build 12408666775: -0.01%
Covered Lines: 3921
Relevant Lines: 4172

💛 - Coveralls

@malthe malthe merged commit 2b14af4 into malthe:master Dec 22, 2024
27 checks passed
@malthe
Copy link
Owner

malthe commented Dec 22, 2024

@fschulze I don't understand the point about having to fix-up location, see https://github.com/malthe/chameleon/actions/runs/12455642989 – testing this commit: 9155eb4.

This seems to run just fine across the different versions.

@fschulze
Copy link
Contributor Author

It failed with AttributeError for the other cases where I added it. I don't understand it either, as I already wrote in the description of this PR.

@malthe malthe mentioned this pull request Dec 22, 2024
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