Skip to content

Ruff rules UP for pyupgrade#7550

Closed
cclauss wants to merge 1 commit intoArduPilot:masterfrom
cclauss:ruff-rules-UP
Closed

Ruff rules UP for pyupgrade#7550
cclauss wants to merge 1 commit intoArduPilot:masterfrom
cclauss:ruff-rules-UP

Conversation

@cclauss
Copy link
Copy Markdown
Contributor

@cclauss cclauss commented Mar 19, 2026

Make all of ruff's pyupgrade rules mandatory in pre-commit.

This pull request makes the minimum Python v3.10, which matches the default Python of the oldest Standard Support Ubuntu LTS as recommended at:

Related to:

@Hwurzburg Hwurzburg requested a review from peterbarker March 19, 2026 11:26
@cclauss cclauss force-pushed the ruff-rules-UP branch 2 times, most recently from 64a7241 to 388b9fe Compare March 20, 2026 05:11
@cclauss cclauss marked this pull request as ready for review March 20, 2026 05:24
@cclauss cclauss changed the title ruff rules UP for pyupgrade Ruff rules UP for pyupgrade Mar 21, 2026
@cclauss cclauss force-pushed the ruff-rules-UP branch 2 times, most recently from 11379cc to f812cbd Compare March 24, 2026 23:49
Copy link
Copy Markdown
Contributor

@khancyr khancyr left a comment

Choose a reason for hiding this comment

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

conflict with #7554, #7555, #7552 need wait

@cclauss cclauss requested a review from khancyr March 25, 2026 08:52
Copy link
Copy Markdown
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

I'm OK with this PR except for the enforced upgrade.

Not saying we can't do it, but not part of a general other PR and not without general agreement.

I'd like to have minimum Python version the same for both the Wiki and the normal firmware, just for the simpler story.

Comment thread pyproject.toml Outdated
Comment thread update.py Outdated
@cclauss cclauss force-pushed the ruff-rules-UP branch 2 times, most recently from 97e260d to a698b6a Compare March 25, 2026 11:20
@cclauss
Copy link
Copy Markdown
Contributor Author

cclauss commented Mar 25, 2026

Set tool.ruff.target-version = "py38"

Used from __future__ import annotations to allow EOL Python 3.8 to use modern type hint syntax.

@cclauss cclauss requested a review from peterbarker March 25, 2026 12:08
@peterbarker
Copy link
Copy Markdown
Contributor

OK, so this looks good. How was it tested?

I'm a little concerned about
image

... so I'd like to know that this was actually tested on 3.8

@cclauss
Copy link
Copy Markdown
Contributor Author

cclauss commented Mar 26, 2026

Why are you concerned about from __future__ import annotations on legacy Python 3.8?

% uvx python3.8 # https://docs.astral.sh/uv

Python 3.8.20 (default, Oct  2 2024, 16:12:59)
[Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import annotations
>>> d: dict | list | None = {key: value for value, key in enumerate("abcdefg")}
>>> d
{'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6}
>>> type(d)
<class 'dict'>
>>> __annotations__
{'d': 'dict | list | None'}

Without uv, this could be tested on legacy Python 3.8.10 with:
% docker run -it ubuntu:20.04
# apt update ; apt install -y python3 ; python3

@cclauss
Copy link
Copy Markdown
Contributor Author

cclauss commented Mar 27, 2026

Status?

  • The forced update has been removed.
  • The testing of from __future__ import annotations has been provided.

@cclauss cclauss force-pushed the ruff-rules-UP branch 2 times, most recently from e43ce6b to f864403 Compare April 1, 2026 11:08
Comment thread pyproject.toml Outdated
@cclauss cclauss requested a review from khancyr April 1, 2026 11:33
@cclauss cclauss force-pushed the ruff-rules-UP branch 5 times, most recently from 011a492 to b84468d Compare April 1, 2026 23:10
@cclauss cclauss force-pushed the ruff-rules-UP branch 3 times, most recently from 33e7354 to 3d4d463 Compare April 11, 2026 11:43
@cclauss cclauss closed this Apr 25, 2026
@cclauss cclauss deleted the ruff-rules-UP branch April 25, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants