Skip to content

Enable pyupgrade and apply fixes - #1496

Draft
ulgens wants to merge 5 commits into
TeamCOMPAS:devfrom
ulgens:ruff-pyupgrade
Draft

ulgens wants to merge 5 commits into
TeamCOMPAS:devfrom
ulgens:ruff-pyupgrade

Conversation

@ulgens

@ulgens ulgens commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Modernizes the code and cleans the practices from older Python versions

https://docs.astral.sh/ruff/rules/#pyupgrade-up

@ulgens ulgens changed the title Enable pyupgrade and update fixes Enable pyupgrade and apply fixes Sep 27, 2026
@ulgens
ulgens marked this pull request as ready for review September 27, 2026 07:42

@ilyamandel ilyamandel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I realise these are all minor changes, but given the extensive range of changes, I'd be grateful if someone with more python expertise than me could take a look; will ask on our Slack channel, but pinging @pauldisberg , @avigna , @SimonStevenson , @FloorBroekgaarden , @jeffriley ...

@warrickball

Copy link
Copy Markdown
Collaborator

This PR looks to me like a mixture of objective improvements (no reason not to drop excess brackets) and style choices (which I'll leave up to the core devs). The style choices looks like mostly changes to type hinting and changes to variable formatting (specifically toward f-strings).

I'm not sure the value in making all the style changes but in any case it's more difficult to discuss the changes when they're all mixed together like this. Could you split them up into separate PRs for different broad groupings? E.g. type hints, string formatting, excess brackets, then maybe "other stuff"?

@avivajpeyi

Copy link
Copy Markdown
Collaborator

I think this also forces users to use py>=3.9

(x: dict = {} from 3.9 i think?)

@ilyamandel -- do you know if any users are using py <3.9? This PR would break the tools for those users i think...

@ulgens

ulgens commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

like a mixture of objective improvements (no reason not to drop excess brackets) and style choices (which I'll leave up to the core devs).

All changes are coming from single ruleset: https://docs.astral.sh/ruff/rules/?linter=pyupgrade-up The overall goal is to modernize the code, make use of newer Python features and remove the old ones. This helps to have a common language (convention) with other Python developers and making the project future proof. I don't categorize these changes as stylistic vs functional. In the ruff's context, a style related linting would be the ruff format command and we would see changes like

Mstar  =  7.64*10**10

to

Mstar = 7.64*10**10

it's more difficult to discuss the changes when they're all mixed together like this.

Not sure we would like to discuss every item from https://docs.astral.sh/ruff/rules/?linter=pyupgrade-up individiually, but I'm okay with making smaller PRs. Will create one for type hints and then let's see how it goes.

@ulgens

ulgens commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

I think this also forces users to use py>=3.9

I can set the target version to 3.8, not sure why I chose 3.9, but 3.8 EOL'd two years ago and it's not getting any security updates - I wouldn't recommend anyone to keep using it: https://devguide.python.org/versions/

I'd also recommend following https://scientific-python.org/specs/spec-0000/ and keeping the support window shorter than 7 years.

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.

4 participants