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

Fix black & isort incompability (again) & standardize linter line-length arguments #655

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

Ana06
Copy link
Member

@Ana06 Ana06 commented Feb 5, 2025

In ba2e1ef I set a consistent maximum line length in isort and black to try to address the conflicts when formatting long import lines But it is insufficient because isort and black format these lines differently. This PR resolves the issue by configuring isort to use the black profile (--profile black). This ensures consistent formatting and avoid conflicts.

Additionally, this PR standardizes the way the maximum line length argument is passed to all linters, using the --<argument_name>=<number> format consistently.

Incompatibility example

isort --line-length 120 (without --profile black)

from vboxcommon import (ensure_hostonlyif_exists, ensure_vm_running, ensure_vm_shutdown, get_vm_uuid, restore_snapshot,
                        run_vboxmanage)

black --line-length=120

from vboxcommon import (
    ensure_hostonlyif_exists,
    ensure_vm_running,
    ensure_vm_shutdown,
    get_vm_uuid,
    restore_snapshot,
    run_vboxmanage,
)

Ana06 added 2 commits February 5, 2025 11:38
Configure isort to use the black profile (`--profile black`) to ensure
consistent formatting of long import lines.  This prevents conflicts
between isort and black, which would otherwise format these lines
differently. Example:

`isort --line-length 120` (without `--profile black`):
```
from vboxcommon import (ensure_hostonlyif_exists, ensure_vm_running, ensure_vm_shutdown, get_vm_uuid, restore_snapshot,
                        run_vboxmanage)
```

`black --line-length=120`:
```
from vboxcommon import (
    ensure_hostonlyif_exists,
    ensure_vm_running,
    ensure_vm_shutdown,
    get_vm_uuid,
    restore_snapshot,
    run_vboxmanage,
)
```
Consistently use the `--<argument_name>=<number>` format for the
maximum line length argument across all linters.
@Ana06 Ana06 added the CI Related to CI label Feb 5, 2025
@Ana06 Ana06 self-assigned this Feb 5, 2025
@Ana06 Ana06 requested a review from williballenthin February 5, 2025 10:54
@Ana06 Ana06 merged commit 5916533 into mandiant:main Feb 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Related to CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants