Skip to content

Create .editorconfig #1225

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

Merged
merged 21 commits into from
Aug 12, 2025
Merged

Create .editorconfig #1225

merged 21 commits into from
Aug 12, 2025

Conversation

kingbuzzman
Copy link
Member

@kingbuzzman kingbuzzman commented Aug 12, 2025

Adds:

  • .editorconfig for auto setting tabs/auto trimming up of files
  • editorconfig-checker action to check that all the rules are validated correctly
  • Fixes all the files that the checker identified as an issue
    • I gave up on the rst for now, as that would be a LOT of changes -- this is a TODO!!!

@kingbuzzman kingbuzzman requested a review from Copilot August 12, 2025 14:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a comprehensive EditorConfig setup to standardize code formatting across the repository. The PR introduces an .editorconfig file with rules for various file types and implements automated checking via GitHub Actions to enforce these formatting standards.

  • Creates .editorconfig with specific formatting rules for different file types (Python, YAML, JSON, etc.)
  • Adds automated EditorConfig validation through GitHub Actions workflow
  • Fixes formatting issues in test files to comply with the new EditorConfig rules

Reviewed Changes

Copilot reviewed 5 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.editorconfig Defines formatting standards for various file types including indentation, line endings, and character encoding
.editorconfig-checker.json Configuration for the EditorConfig checker with exclusions and disabled rules
.github/workflows/main.yml Adds EditorConfig validation job to CI pipeline
tests/test_fixtures.py Reformats code to comply with EditorConfig rules, fixing line breaks and indentation
tests/test_django_settings_module.py Reformats multiline function calls and dictionary definitions to match EditorConfig standards

@webknjaz
Copy link
Member

I'd recommend putting the checker into tox or pre-commit configs since those would have better cross-env integrations and aren't locked to just the CI.

@kingbuzzman
Copy link
Member Author

kingbuzzman commented Aug 12, 2025

@webknjaz that is a lot more work, since there is no easy way to "pip install" ec.

I'm not against this, this is just to at least get the ball rolling.


How would you approach this? Installing ec seamlessly into the tox environment?

@webknjaz
Copy link
Member

webknjaz commented Aug 12, 2025

It has a native integration with the pre-commit framework: https://github.com/editorconfig-checker/editorconfig-checker/blob/main/.pre-commit-hooks.yaml. So just add a .pre-commit-config.yaml pointing to the repo. Call pre-commit run --all-files in tox.ini and make sure you have a job calling that tox env in CI.

In my projects, it looks like this: https://github.com/ansible/awx-plugins/actions/runs/16881280962/job/47817646031.

Overall, having pre-commit invoked in CI through tox probably deserves a dedicated PR. Once it's in, adding any new linters and/or formatters would be going through the pre-commit framework and would work in CI, locally through tox and even if editor integrations somehow call pre-commit outside this infra.
Additionally, I recommend enabling https://pre-commit.ci in this repo to get a PR integration with formatting back-pushes.


Also, there's a wrapper that does work with pip install: https://pypi.org/p/editorconfig-checker. But I'd still go the pre-commit route. Though, maybe it's easier to use this in the scope of this PR until there's pre-commit based infra.

@kingbuzzman
Copy link
Member Author

PS. I did this quick PR to ensure the authors would catch issues like putting tabs into places were the norm is spaces and I or others not to have to point it out.

@webknjaz
Copy link
Member

PS. I did this quick PR to ensure the authors would catch issues like putting tabs into places were the norm is spaces and I or others not to have to point it out.

Then, I'd definitelly go for the pre-commit framework as it has native fixers for this sort of things: https://github.com/ansible/awx-plugins/blob/12091e4/.pre-commit-config.yaml#L65-L68. Check out https://pre-commit.com/hooks.html for more fun stuff.

@kingbuzzman
Copy link
Member Author

kingbuzzman commented Aug 12, 2025

@webknjaz I see, I get it; but @bluetech is going to have to authorize pre-commit.ci

Does it make sense to merge this in the interim, while we wait for the integration? Seems to me that the only thing we would remove is the changes to .github/workflows/main.yml -- everything else would stay in place. Plus, adding the hook config files.

What do you think?

This PR being a stop-gap.

@webknjaz
Copy link
Member

@kingbuzzman I edited one of the previous comments with the pip install option if that works for you. Otherwise, whatever works for you 🤷‍♂️

@webknjaz
Copy link
Member

is going to have to authorize pre-commit.ci

Note that his is a nice to have. Using it in GHA through tox isn't blocked as the GH App isn't needed for that. I'm rather surprised that there's no linting job in CI already.

@kingbuzzman
Copy link
Member Author

Also, there's a wrapper that does work with pip install: pypi.org/p/editorconfig-checker. But I'd still go the pre-commit route. Though, maybe it's easier to use this in the scope of this PR until there's pre-commit based infra.

OH wow. I completely missed this! -- ok ok, let me patch it 😇

@kingbuzzman kingbuzzman marked this pull request as ready for review August 12, 2025 15:08
@kingbuzzman
Copy link
Member Author

@webknjaz DOPE suggestions as always! Thank you so much!! ❤️

@kingbuzzman kingbuzzman merged commit 8dd6acf into main Aug 12, 2025
21 checks passed
@kingbuzzman kingbuzzman deleted the dev/editorconfig branch August 12, 2025 15:11
@lode-braced
Copy link

@kingbuzzman a note while pulling this into my PR: The new linting seems to freak out on pycache files in my local editor: tests/pycache/test_unittest.cpython-311-pytest-8.4.1.pyc:
Wrong line endings or no final newline
Not all lines have the correct end of line character
89-91: Trailing whitespace
119-123: Trailing whitespace
169-171: Trailing whitespace
194-195: Trailing whitespace
224-229: Trailing whitespace

Is it worth making an issue to manage exclusions, or may I be doing something wrong on my setup?

@webknjaz
Copy link
Member

It should be fixed in the repo

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.

3 participants