Skip to content

Format Python code with ruff format - #790

Merged
julianoes merged 4 commits into
mavlink:mainfrom
cclauss:ruff-format
Sep 9, 2025
Merged

Format Python code with ruff format#790
julianoes merged 4 commits into
mavlink:mainfrom
cclauss:ruff-format

Conversation

@cclauss

@cclauss cclauss commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

% ruff format # https://docs.astral.sh/ruff/formatter

 160 files changed, 30014 insertions(+), 32975 deletions(-)

Improve readability while removing 2,961 unnecessary lines.

ruff format should be added to code generation processes.

Comment thread .github/workflows/main.yml Outdated
python3 -m pip install pycodestyle
export PATH=$PATH:$HOME/.local/bin
pycodestyle examples/*
pycodestyle --max-line-length=88 examples/*

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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'd go with 100.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason for 88 (not 100) was explained in that URL.

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.

Interesting. I used to be strongly in favor of 80 but it does make it awkward when you want to have variable names that actually explain what they are instead of acronyms or abbreviations.

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.

For the simple examples, I'm just going to leave it at the default pycodestyle 79 for now.

Comment thread .github/workflows/main.yml Outdated
python3 -m pip install pycodestyle
export PATH=$PATH:$HOME/.local/bin
pycodestyle examples/*
pycodestyle --max-line-length=88 examples/*

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'd go with 100.

Comment thread mavsdk/action.py
class OrbitYawBehavior(Enum):
"""
Yaw behaviour during orbit flight.
Yaw behaviour during orbit flight.

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.

Auto-generated!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please read the commit message.

ruff format should be added to code generation processes.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Thanks!

@cclauss cclauss mentioned this pull request Sep 9, 2025

@julianoes julianoes 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.

Alright, let me get this in and add in the other PRs on top of it.

Comment thread .github/workflows/main.yml Outdated
python3 -m pip install pycodestyle
export PATH=$PATH:$HOME/.local/bin
pycodestyle examples/*
pycodestyle --max-line-length=88 examples/*

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.

Interesting. I used to be strongly in favor of 80 but it does make it awkward when you want to have variable names that actually explain what they are instead of acronyms or abbreviations.

Comment thread other/tools/run_protoc.sh Outdated
@@ -96,4 +96,6 @@ function generate {

echo "[+] Generating plugins from "
generate
python3 -m pip install --upgrade ruff
ruff format

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.

Comment thread .github/workflows/main.yml Outdated
python3 -m pip install pycodestyle
export PATH=$PATH:$HOME/.local/bin
pycodestyle examples/*
pycodestyle --max-line-length=88 examples/*

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.

For the simple examples, I'm just going to leave it at the default pycodestyle 79 for now.

Comment thread mavsdk/action.py
class OrbitYawBehavior(Enum):
"""
Yaw behaviour during orbit flight.
Yaw behaviour during orbit flight.

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.

Thanks!

@julianoes
julianoes merged commit 9692e6e into mavlink:main Sep 9, 2025
9 checks passed
@cclauss
cclauss deleted the ruff-format branch September 10, 2025 04:32
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.

2 participants