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

pre-commit: pyupgrade #1352

Merged
merged 5 commits into from
Apr 5, 2024
Merged

pre-commit: pyupgrade #1352

merged 5 commits into from
Apr 5, 2024

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Apr 2, 2024

Stop using deprecated type annotations and imports.

Stop using deprecated type annotations and imports.
@codecov-commenter
Copy link

codecov-commenter commented Apr 2, 2024

Codecov Report

Attention: Patch coverage is 97.86096% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 84.32%. Comparing base (5879755) to head (be95d2b).

Files Patch % Lines
pypesto/objective/aesara/base.py 50.00% 2 Missing ⚠️
pypesto/objective/julia/petabJl.py 0.00% 1 Missing ⚠️
pypesto/visualize/sampling.py 83.33% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1352      +/-   ##
===========================================
+ Coverage    84.25%   84.32%   +0.06%     
===========================================
  Files          157      157              
  Lines        12871    12911      +40     
===========================================
+ Hits         10845    10887      +42     
+ Misses        2026     2024       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dweindl dweindl self-assigned this Apr 2, 2024
@dweindl dweindl marked this pull request as ready for review April 2, 2024 18:14
Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

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

Add to ".git-blame-ignore-revs"?

@dweindl
Copy link
Member Author

dweindl commented Apr 2, 2024

Add to ".git-blame-ignore-revs"?

Yes, but only after merging.

Copy link
Contributor

@FFroehlich FFroehlich left a comment

Choose a reason for hiding this comment

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

rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py39-plus"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not automatically picked up from python-requires in setup.cfg?

Copy link
Member Author

Choose a reason for hiding this comment

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

At least I didn't find that documented.

Copy link
Contributor

Choose a reason for hiding this comment

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

mmh, yeah pyupgrade doesn't seem to do it out of the box. I don't think ruff reads options from setup.cfg, only pyproject.toml, but we could anyways move all of the information to a single file, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

but we could anyways move all of the information to a single file, right?

Yes, it would be good switch to fully switch to pyproject.toml, but that's something for another day.

@dweindl
Copy link
Member Author

dweindl commented Apr 3, 2024

👍 please add 64efde1 to https://github.com/ICB-DCM/pyPESTO/blob/develop/.git-blame-ignore-revs

After merge. Hash will change.

and use ruff (UP, https://docs.astral.sh/ruff/rules/#pyupgrade-up)

👍 Didn't notice it was available through ruff.

@@ -1,7 +1,8 @@
import logging
import warnings
from collections.abc import Sequence
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any particular reason to use this one? Seems like just an extra import to me.

Copy link
Member Author

@dweindl dweindl Apr 3, 2024

Choose a reason for hiding this comment

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

Yes. typing.Sequence is deprecated since python 3.9.

Copy link
Contributor

@Doresic Doresic left a comment

Choose a reason for hiding this comment

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

Thank you! It's nice to have it changed everywhere.
One question, more for my info than anything else.

Comment on lines -92 to +95
petab_problem: "petab.Problem",
petab_problem: petab.Problem,
model: AmiciModel,
edatas: list["amici.ExpData"],
edatas: list[amici.ExpData],
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought that adding " " on petab and amici objects was good for tests not to break if the module is imported, but petab and amici are not installed. I think I tried having it like this, but then tests were failing. Why is it ok to change now?

Copy link
Member Author

Choose a reason for hiding this comment

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

tl;dr: from __future__ import annotations

details: https://peps.python.org/pep-0563/

@dweindl dweindl merged commit 321ee9d into ICB-DCM:develop Apr 5, 2024
18 checks passed
@dweindl dweindl deleted the maint_pyupgrade branch April 5, 2024 07:45
This was referenced Apr 9, 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.

6 participants