Skip to content

precommit: Black#5490

Closed
Borda wants to merge 2 commits intoultralytics:masterfrom
Borda:pre-commit/black
Closed

precommit: Black#5490
Borda wants to merge 2 commits intoultralytics:masterfrom
Borda:pre-commit/black

Conversation

@Borda
Copy link
Copy Markdown
Contributor

@Borda Borda commented Nov 3, 2021

use Black as default codebase formatting
Resolves #4983

This PR defines Black as pre-commit hook and lets the bot fix it... 🐰

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

WARNING ⚠️ this PR is very large, summary may not cover all changes.

🌟 Summary

Summarization of GitHub Pull Request in Ultralytics YOLOv5 repository with code diffs.

📊 Key Changes

  • Code formatting improved with stylistic changes such as indentation, quotation adjustments, and spacing for better readability.
  • Type hinting improved for better code clarity in function arguments.
  • Updated console message text to be enclosed in quotes for improved clarity and consistency.
  • Minor syntax improvements, such as removing unnecessary list creation and redundant lambda variable declarations.

🎯 Purpose & Impact

  • 🔍 Code Readability: The reformatting improves code readability, making it easier for developers to understand the codebase.
  • 👁️ Visibility: Explicit type-hints offer better visibility of expected function inputs, enhancing maintainability.
  • 📈 Consistency: Consistent use of quotations and message formatting promotes uniform coding standards.
  • Quality: Small syntax improvements add up to a general increase in code quality.

@glenn-jocher
Copy link
Copy Markdown
Member

@Borda thanks for the PR! I think Black may be a bit too much for us right now. I actually do like some of the updates, in particular the 0. -> 0.0, and the 1E6 -> 1e6, but others I'd rather skip like listing imports one per line. Is there a way to enable only certain changes, or is Black an all-or-none linter?

In the meantime I made a new PR to fix as many 0. -> 0.0 as I could fine using PyCharm search and replace in #5491.

@Borda
Copy link
Copy Markdown
Contributor Author

Borda commented Nov 3, 2021

well, an alternative is YAPF (#5494), you can check how it looks like in my personal repo:
https://github.com/Borda/pyImSegm/blob/c52e709f9fcd90bcc6ab06e515685fd4c4e6c301/setup.cfg#L43-L52

there is also just autopep8 fixer, https://pypi.org/project/autopep8/
I made it as a draft just to open discussion :]

@glenn-jocher
Copy link
Copy Markdown
Member

glenn-jocher commented Dec 8, 2021

@Borda closing this to focus on yapf and readme per our convo. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐

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.

use formatting Isort/YAPF/Black

2 participants